Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitea should fail gracefully when OIDC IDP has problems #8930

Closed
2 of 7 tasks
cruwe opened this issue Nov 12, 2019 · 7 comments · Fixed by #14802
Closed
2 of 7 tasks

gitea should fail gracefully when OIDC IDP has problems #8930

cruwe opened this issue Nov 12, 2019 · 7 comments · Fixed by #14802
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@cruwe
Copy link

cruwe commented Nov 12, 2019

First, thank you very much for developing gitea!

2019/11/12 07:36:17 ...uth/oauth2/oauth2.go:173:createProvider() [W] Failed to create OpenID Connect Provider with name '<...>' with url 'https://keycloak-management-infra.router.default.svc.cluster.local/auth/realms/<...>/.well-known/openid-configuration': Get https://keycloak-management-infra.router.default.svc.cluster.local/auth/realms/<...>/.well-known/openid-configuration: x509: certificate signed by unknown authority
2019/11/12 07:36:17 routers/init.go:92:GlobalInit() [F] Failed to initialize OAuth2 support: Get https://keycloak-management-infra.router.default.svc.cluster.local/auth/realms/<...>/.well-known/openid-configuration: x509: certificate signed by unknown authority

Description

When gitea has been configured against an OIDC IDP and when between restarts the IDP's endpoint stops being served with "proper/correct" certificates, gitea fails to start, running in a restart loop with a container built from the upstream Dockerfile.

Instead, I would like gitea to fail gracefully, disabling the IDP in question and allowing to login with other authentication sources (local admin comes to mind) to fix the problem "in app". I stumbled upon the issue when trying to "migrate" an instance over differently built experimental OpenShift clusters via the persistent volume. I "solved" the issue by deleting the corresponding row in "login_source" on the database.

The issue is minor, stems from operator weirdness in my case and is fixable. Abstracting from my specifics, however, I can imagine cases where a certificates' best-before-date may have been reached. I agree for various reasons that one should not trust such a certificate any more, especially for an IDP.
However, it would be nice to be able to fix such issues without reverting to fiddling with the database.

Thank you very much for your consideration! Cheers!

Screenshots

@lunny lunny added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Nov 12, 2019
@lunny
Copy link
Member

lunny commented Nov 12, 2019

Maybe an option on Auth Source.

@xeals
Copy link

xeals commented May 30, 2020

This is an ongoing issue and surfaces in more than just certificate issues.

I have a self-hosted instance of an OIDC provider (Keycloak) that occasionally fails for completely random reasons. Since it's behind a proxy, when it fails the proxy will return a plaintext "502 Bad Gateway" response, which Gitea happily tries to parse and brings itself down when it doesn't work.

2020/05/30 18:57:23 ...uth/oauth2/oauth2.go:174:createProvider() [W] Failed to create OpenID Connect Provider with name 'keycloak' with url 'https://keycloak.example.com/auth/realms/universe/.well-known/openid-configuration': invalid character 'B' after top-level value
2020/05/30 18:57:23 routers/init.go:142:GlobalInit() [F] Failed to initialize OAuth2 support: invalid character 'B' after top-level value
Received signal 15; terminating.

@kowalski7cc
Copy link

Yep, my personal keycloak failed and I have no time to fix it. So now I'm unable to use my gitea...

@kowalski7cc
Copy link

I worked it around by creating a new instance of keycloak on the same URL and deleting it from the settings page.

zeripath added a commit to zeripath/gitea that referenced this issue Feb 25, 2021
Instead of causing a log.Fatal, we should handle broken OAuth2
providers by disabling them.

Fix go-gitea#8930

Signed-off-by: Andrew Thornton <art27@cantab.net>
techknowlogick added a commit that referenced this issue Feb 26, 2021
Instead of causing a log.Fatal, we should handle broken OAuth2
providers by disabling them.

Fix #8930

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
zeripath added a commit to zeripath/gitea that referenced this issue Feb 26, 2021
Backport go-gitea#14802

Instead of causing a log.Fatal, we should handle broken OAuth2
providers by disabling them.

Fix go-gitea#8930

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
6543 pushed a commit that referenced this issue Feb 26, 2021
Backport #14802

Instead of causing a log.Fatal, we should handle broken OAuth2
providers by disabling them.

Fix #8930

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@netcicd
Copy link

netcicd commented Mar 23, 2021

I understand that this is a solution for some, but I can no longer re-enable keycloak. So in my case the cure is worse than the problem. Rebooting gitea in order to see if the connection does not help.

@zeripath
Copy link
Contributor

@netcicd I don't understand. Why can't you re-enable keycloak?

@netcicd
Copy link

netcicd commented Mar 24, 2021

@zeripath thx for your rapid response. My monitor made the check-box invisible :) Can re-enable indeed this way (but this is hardly usable)
This implies that a user needs to log in as admin to get it working again. I use Keycloak and Gitea in Docker. Gitea boots faster than Keycloak and some form of retry /graceful recovery should be possible. I can imagine that you can configure a timeout as a solution: e.g. if Keycloak does not come back within say 5 min, only then disable. Or make it configurable.

@go-gitea go-gitea locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants