Remove auth_mode
This commit is contained in:
@@ -620,13 +620,9 @@ func (s *Server) handleWebConfig(w http.ResponseWriter, _ *http.Request, v *visi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) configResponse(v *visitor) *apiConfigResponse {
|
func (s *Server) configResponse(v *visitor) *apiConfigResponse {
|
||||||
authMode := ""
|
authUser := ""
|
||||||
username := ""
|
if s.config.AuthUserHeader != "" && v != nil && v.User() != nil {
|
||||||
if s.config.AuthUserHeader != "" {
|
authUser = v.User().Name
|
||||||
authMode = "proxy"
|
|
||||||
if v != nil && v.User() != nil {
|
|
||||||
username = v.User().Name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return &apiConfigResponse{
|
return &apiConfigResponse{
|
||||||
BaseURL: "", // Will translate to window.location.origin
|
BaseURL: "", // Will translate to window.location.origin
|
||||||
@@ -643,9 +639,8 @@ func (s *Server) configResponse(v *visitor) *apiConfigResponse {
|
|||||||
WebPushPublicKey: s.config.WebPushPublicKey,
|
WebPushPublicKey: s.config.WebPushPublicKey,
|
||||||
DisallowedTopics: s.config.DisallowedTopics,
|
DisallowedTopics: s.config.DisallowedTopics,
|
||||||
ConfigHash: s.config.Hash(),
|
ConfigHash: s.config.Hash(),
|
||||||
AuthMode: authMode,
|
|
||||||
AuthLogoutURL: s.config.AuthLogoutURL,
|
AuthLogoutURL: s.config.AuthLogoutURL,
|
||||||
Username: username,
|
AuthUser: authUser,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -483,9 +483,8 @@ type apiConfigResponse struct {
|
|||||||
WebPushPublicKey string `json:"web_push_public_key"`
|
WebPushPublicKey string `json:"web_push_public_key"`
|
||||||
DisallowedTopics []string `json:"disallowed_topics"`
|
DisallowedTopics []string `json:"disallowed_topics"`
|
||||||
ConfigHash string `json:"config_hash"`
|
ConfigHash string `json:"config_hash"`
|
||||||
AuthMode string `json:"auth_mode,omitempty"` // "proxy" if auth-user-header is set, empty otherwise
|
|
||||||
AuthLogoutURL string `json:"auth_logout_url,omitempty"` // URL to redirect to on logout (only for proxy auth)
|
AuthLogoutURL string `json:"auth_logout_url,omitempty"` // URL to redirect to on logout (only for proxy auth)
|
||||||
Username string `json:"username,omitempty"` // Authenticated username (for proxy auth)
|
AuthUser string `json:"auth_user,omitempty"` // Authenticated username (for proxy auth, empty if not using proxy auth)
|
||||||
}
|
}
|
||||||
|
|
||||||
type apiAccountBillingPrices struct {
|
type apiAccountBillingPrices struct {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ var config = {
|
|||||||
web_push_public_key: "",
|
web_push_public_key: "",
|
||||||
disallowed_topics: ["docs", "static", "file", "app", "account", "settings", "signup", "login", "v1"],
|
disallowed_topics: ["docs", "static", "file", "app", "account", "settings", "signup", "login", "v1"],
|
||||||
config_hash: "dev", // Placeholder for development; actual value is generated server-side
|
config_hash: "dev", // Placeholder for development; actual value is generated server-side
|
||||||
auth_mode: "", // "proxy" if auth-user-header is set, empty otherwise
|
|
||||||
auth_logout_url: "", // URL to redirect to on logout (only for proxy auth)
|
auth_logout_url: "", // URL to redirect to on logout (only for proxy auth)
|
||||||
username: "", // Authenticated username (for proxy auth)
|
auth_user: "", // Authenticated username (non-empty if using proxy auth)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -343,9 +343,9 @@ class AccountApi {
|
|||||||
async sync() {
|
async sync() {
|
||||||
try {
|
try {
|
||||||
// For proxy auth, store the username from config if not already in session
|
// For proxy auth, store the username from config if not already in session
|
||||||
if (config.auth_mode === "proxy" && config.username && !session.exists()) {
|
if (config.auth_user && !session.exists()) {
|
||||||
console.log(`[AccountApi] Proxy auth: storing session for user ${config.username}`);
|
console.log(`[AccountApi] Proxy auth: storing session for user ${config.auth_user}`);
|
||||||
await session.store(config.username, ""); // Empty token for proxy auth
|
await session.store(config.auth_user, ""); // Empty token for proxy auth
|
||||||
}
|
}
|
||||||
if (!session.exists()) {
|
if (!session.exists()) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ const ProfileIcon = () => {
|
|||||||
|
|
||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
// For proxy auth, redirect to the logout URL if configured
|
// For proxy auth, redirect to the logout URL if configured
|
||||||
if (config.auth_mode === "proxy") {
|
if (config.auth_user) {
|
||||||
if (config.auth_logout_url) {
|
if (config.auth_logout_url) {
|
||||||
await db().delete();
|
await db().delete();
|
||||||
localStorage.removeItem("user");
|
localStorage.removeItem("user");
|
||||||
@@ -158,8 +158,8 @@ const ProfileIcon = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Determine if logout button should be shown
|
// Determine if logout button should be shown (hide if proxy auth without logout URL)
|
||||||
const showLogout = config.auth_mode !== "proxy" || config.auth_logout_url;
|
const showLogout = !config.auth_user || config.auth_logout_url;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const Login = () => {
|
|||||||
|
|
||||||
// Redirect to app if using proxy authentication
|
// Redirect to app if using proxy authentication
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (config.auth_mode === "proxy") {
|
if (config.auth_user) {
|
||||||
window.location.href = routes.app;
|
window.location.href = routes.app;
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user