-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Adding OAuth2 Authentication Sources through the CLI Requires Manual Intervention through UI in order to work #8356
Comments
#183 has a good discussion that's relevant to this |
I've been fooling around with this more after building Gitea from source. I've narrowed it down to a "no provider found" error in the |
Sorry if the question is too dumb but, have you tried using quotes in your parameters when invoking from shell? For instance, change: A big gotcha with URLs is that they usually contain characters like |
@guillep2k I did try that, unfortunately I still got a 500. Inspecting it through the UI (after it's populated through the CLI) yields the exact URL I want. The actual request to |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions. |
Came here to say this, I've tried many things, checked the |
Unfortunately a simple restart doesn't seem to fix this. I think this means that this isn't going to be viable for my employer. |
I confirm a restart fixes the problem, if it doesn't for you, you probably have another problem. Does it work when you input the exact same config in the web UI? |
I'll investigate further. It's possible that that I've got something mistyped in the command line. Thanks for letting me know. |
Can confirm that this works. It appears that I misspelled |
Hi. Are there any news about this bug? @lunny |
It seems the command code is the same as creating OAuth2 login source via UI. The only different is diff --git a/cmd/admin.go b/cmd/admin.go
index 25faaae18..b11719be3 100644
--- a/cmd/admin.go
+++ b/cmd/admin.go
@@ -615,10 +615,11 @@ func runAddOauth(c *cli.Context) error {
}
return models.CreateLoginSource(&models.LoginSource{
- Type: models.LoginOAuth2,
- Name: c.String("name"),
- IsActived: true,
- Cfg: parseOAuth2Config(c),
+ Type: models.LoginOAuth2,
+ Name: c.String("name"),
+ IsActived: true,
+ IsSyncEnabled: false,
+ Cfg: parseOAuth2Config(c),
})
} |
Could |
I don't think so. |
You are showing the difference in database saving. My guess is: the data from that table is only loaded on application start. When adding from the UI it is added to the in-memory providers, when called from the cli, it is not. That's why a restart fixes the problem.
19 Dec 2020 09:42:57 Lunny Xiao <notifications@github.com>:
… It seems the command code is the same as creating OAuth2 login source via UI. The only different isdiff --git a/cmd/admin.go b/cmd/admin.go
index 25faaae18..b11719be3 100644
--- a/cmd/admin.go
+++ b/cmd/admin.go
@@ -615,10 +615,11 @@ func runAddOauth(c *cli.Context) error {
}
return models.CreateLoginSource(&models.LoginSource{
- Type: models.LoginOAuth2,
- Name: c.String("name"),
- IsActived: true,
- Cfg: parseOAuth2Config(c),
+ Type: models.LoginOAuth2,
+ Name: c.String("name"),
+ IsActived: true,
+ IsSyncEnabled: false,
+ Cfg: parseOAuth2Config(c),
})
}
—
|
First off, thanks for a great product so far!
[x]
):Description
The most straightforward way to reproduce this IMO is:
gitea admin auth add-oauth --name keycloakoidc --provider openidConnect --key gitea --secret <MY-GITEA-CLIENT-SECRET> --auto-discover-url http://<MY-KEYCLOAK-DOMAIN>/auth/realms/<MY-KEYCLOAK-REALM>/.well-known/openid-configuration --config=/home/gitea/conf/app.ini
/home/gitea/gitea admin auth add-oauth --name gitlab --provider gitlab --key gitea --secret <MY-GITEA-CLIENT-SECRET> --custom-auth-url https://gitlab.com/oauth/authorize --custom-token-url https://gitlab.com/oauth/token --custom-profile-url https://gitlab.com/api/v3/user --config=/home/gitea/conf/app.ini
These commands both succeed and you get the appropriate
Sign in with
buttons appearing on the sign in page, as shown below:However, clicking on this link immediately gives a 500 error (screenshot below):
The server logs don't produce much more there, just
[Macaron] 2019-10-02 17:02:02: Completed GET /user/oauth2/gitlab 500 Internal Server Error in 7.243256ms
.However : if you had
DISABLE_REGISTRATION = false
in yourapp.ini
, and at this point you register as a local (non-external) user with admin privileges through the UI, and then go toSite Administration->Authentication Sources
, click to edit the authentication source that you just created through the CLI, and just click update (no changes whatsoever, see below)Then you will notice that if you sign out and go back to the sign in page, then clicking the
Sign in with
Gitlab button works, it takes you out to Gitlab.com instead of returning a 500.In summary, as the title of this issue suggests, creating OAuth2 authentication sources through the CLI requires a manual, one-time intervention through the UI to make them work. In most cases this isn't a big deal, but it's a showstopper if you're trying to automate the deployment of Gitea. Thanks!
The text was updated successfully, but these errors were encountered: