Skip to content

feat: auto-redirect to OIDC IdP (#991) - #1029

Open
DerDummePunkt wants to merge 3 commits into
gotify:masterfrom
DerDummePunkt:github_1007_option_to_redirect_to_idp_when_logged_out
Open

feat: auto-redirect to OIDC IdP (#991)#1029
DerDummePunkt wants to merge 3 commits into
gotify:masterfrom
DerDummePunkt:github_1007_option_to_redirect_to_idp_when_logged_out

Conversation

@DerDummePunkt

Copy link
Copy Markdown
Contributor

This PR attempts to implement the missing part of #991

Add GOTIFY_OIDC_AUTO_REDIRECT (with default false) to skip the login page and redirect straight to the configured OIDC provider. Only takes effect when local auth is disabled, since local login would otherwise be unreachable.

Add GOTIFY_OIDC_AUTO_REDIRECT_REQUIRE_REAUTH (default false) to send prompt=login on that redirect, so logging out of Gotify doesn't silently log the user back in via an existing IdP session. Does not end that IdP session, so other apps using it are unaffected.

Wire both flags through gotifyinfo/injected UI config and the WebUI login page, which now redirects instead of showing the OIDC button when enabled.

Added helperfunction to emit warnigns via FutureLog in config builder/parser

@DerDummePunkt
DerDummePunkt requested a review from a team as a code owner August 15, 2026 10:11
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.26%. Comparing base (ef41eba) to head (5ae0c1e).

Files with missing lines Patch % Lines
config/parse.go 89.47% 1 Missing and 1 partial ⚠️
api/oidc.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1029      +/-   ##
==========================================
+ Coverage   74.78%   75.26%   +0.48%     
==========================================
  Files          66       66              
  Lines        3541     3570      +29     
==========================================
+ Hits         2648     2687      +39     
+ Misses        688      674      -14     
- Partials      205      209       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Add GOTIFY_OIDC_AUTO_REDIRECT to skip the login page and redirect
straight to the configured OIDC provider. Only takes effect when
local auth is disabled, since local login would otherwise be
unreachable.

Add GOTIFY_OIDC_AUTO_REDIRECT_REQUIRE_REAUTH (default false) to send
prompt=login on that redirect, so logging out of Gotify doesn't
silently log the user back in via an existing IdP session. Does not
end that IdP session, so other apps using it are unaffected.

Wire both flags through gotifyinfo/injected UI config and the WebUI
login page, which now redirects instead of showing the OIDC button
when enabled.
@DerDummePunkt
DerDummePunkt force-pushed the github_1007_option_to_redirect_to_idp_when_logged_out branch from 69d7eb8 to d764fd9 Compare August 15, 2026 12:35

@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.

Thanks for the contribution.

Comment thread gotify-server.env.example Outdated
# GOTIFY_OIDC_AUTO_REDIRECT is also in effect.
#
# Type: boolean
# GOTIFY_OIDC_AUTO_REDIRECT_REQUIRE_REAUTH=false

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 rename this to GOTIFY_OIDC_PROMPT with type text and default login. This should be used for both login and elevate. And be independent of the auto redirect feature.

@DerDummePunkt DerDummePunkt Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, but if we do that, since we then pass whatever is the value of that env var to the IdP as a url param, I would suggest we also check the value provided against the allowed values according to the oidc spec
I really dont want to pass any unvalidated data to a login system

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.

I think it's okay to do this unvalidated as this setting set by administrators. If the spec changes we'd have to adjust the validation, so I don't think there is much benefit in validating it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, yes, if a protocol you use changes, you have might have to adjust the code.

If i remember correctly, the OIDC spec follows semnatic versioning, that means future minor version bumps shouldnt remove existing params or values, only add to it.

I already added validation as func parseOIDCPrompt to config/parse.go

func parseOIDCPrompt(target *string, env string) error {
	raw, ok, err := lookupEnv(env)
	if err != nil {
		return err
	}
	if !ok {
		return nil
	}
	values := strings.Fields(raw)
	hasNone := false
	for _, value := range values {
		if !validOIDCPromptValues[value] {
			return fmt.Errorf(
				"invalid value for %s (%q): must be a space-delimited combination of none, login, consent, select_account",
				env, raw,
			)
		}
		hasNone = hasNone || value == "none"
	}
	if hasNone && len(values) > 1 {
		return fmt.Errorf("invalid value for %s (%q): none must not be combined with other values", env, raw)
	}
	*target = raw
	return nil
}

I think its worth doing, it protects gotify admins from faulty configs and protects OIDC IdP system from some injection vectors.

Comment thread gotify-server.env.example Outdated
Comment thread ui/src/user/Login.tsx
Comment thread model/gotifyinfo.go
Comment thread config/config.go Outdated
*GOTIFY_OIDC_AUTO_REDIRECT now takes effect reagardless of wether
GOTIFY_LOCALAUTH_ENABLED is true or not
* replaced GOTIFY_OIDC_AUTO_REDIRECT_REQUIRE_REAUTH with
  GOTIFY_OIDC_PROMPT: type string that can take in any combination of
  prompt params according to the oidc spec
* added url param redirect to /login ui route, when set to false, auto
  redirect to idp is skipped and the login form is displayed, allowing
  local users to login with username and password
@DerDummePunkt

DerDummePunkt commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Im pretty confident the prompt params are correct and to spec, but I'm having trouble testing value combinations, it seems I have discovered a bug in authelia 🤷‍♂️

I will test mutliple prompt values against one of my dev keycloak instances later, but configuring keycloak is always such a pain in the a**, I doint have time for that right now

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