Skip to content

feat: #1007 - Option to disable local login when OIDC is enabled - #1020

Open
DerDummePunkt wants to merge 1 commit into
gotify:masterfrom
DerDummePunkt:github_1007_option_to_disable_local_login_when_oidc_enabled
Open

feat: #1007 - Option to disable local login when OIDC is enabled #1020
DerDummePunkt wants to merge 1 commit into
gotify:masterfrom
DerDummePunkt:github_1007_option_to_disable_local_login_when_oidc_enabled

Conversation

@DerDummePunkt

Copy link
Copy Markdown

This PR attempts to implement #1007

Adds configurable local authentication through GOTIFY_LOCALAUTH_ENABLED, defaults to true to preserve existing behavior.

When local authentication is disabled:

  • The server does not register POST /auth/local/login.
  • Basic Auth with local Gotify user credentials is rejected by authentication middleware.
  • The check for a local admin account and subsequent creation is skipped.
  • The UI hides the local username/password login form, registration button, and password-based elevation form.
  • The UI receives the public localauth flag through injected window.config.
  • GET /gotifyinfo exposes the same flag as localauth.

The server exits with a fatal error when both local authentication and OIDC are disabled, preventing startup without an available login method.

disable local login when OIDC is enabled

- Add GOTIFY_LOCALAUTH_ENABLED, defaulting to true
- Block local login and Basic Auth when disabled
- Expose local auth state to the UI and hide local login flows
- Skip default local admin creation when local auth is disabled
- Require either local auth or OIDC at startup
@DerDummePunkt
DerDummePunkt requested a review from a team as a code owner August 4, 2026 18:33

@jmattheis jmattheis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far. I've some remarks and haven't tested it manually.

Comment thread auth/authentication.go
Comment on lines +150 to +152
if !a.LocalAuthEnabled {
return authStateSkip, nil
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of skipping this should error and abort.

  • Create a new authState named authStateAuthDisabled
  • Return 403 with the message "local authentication is disabled" in the evaluate method.

Comment thread router/router.go

g.Group("/user").Use(authentication.Optional).POST("", userHandler.CreateUser)

g.POST("/auth/local/login", sessionHandler.Login)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint should still be registered. 404 seems like a weird response. It should instead return 403 with message "local authentication is disabled"

Comment thread app.go
Comment on lines +88 to +90
if !conf.LocalAuthEnabled && !conf.OIDC.Enabled {
log.Fatal().Msg("either local authentication or OIDC must be enabled")
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this check to the end of config.Get, so it's included in the futureLogs that is used in this method?

Comment thread model/gotifyinfo.go
//
// required: true
// example: true
LocalAuth bool `json:"localauth"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LocalAuth bool `json:"localauth"`
LocalAuth bool `json:"localAuth"`

Case this with camel case:

$ rg localauth
docs/spec.json
2943:        "localauth",
2947:        "localauth": {

model/gotifyinfo.go
21:     LocalAuth bool `json:"localauth"`

ui/src/user/Login.tsx
20:    const localAuthEnabled = config.get('localauth');

ui/src/common/ElevationForm.tsx
18:    const localAuthEnabled = config.get('localauth');

ui/src/config.ts
8:    localauth: boolean;
22:    localauth: true,

ui/serve.go
21:     LocalAuth bool              `json:"localauth"`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants