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 oAuth Fails #148

Closed
kaysersoze opened this issue Nov 2, 2023 · 18 comments
Closed

Gitea oAuth Fails #148

kaysersoze opened this issue Nov 2, 2023 · 18 comments
Labels
bug Something isn't working

Comments

@kaysersoze
Copy link

When attempting to authenticate via Gitea oAuth, I always receive the message:

Error 400
Bad Request

Cannot complete user auth

From looking at the code at https://github.com/thomiceli/opengist/blob/master/internal/web/auth.go#L141C2-L144C3, it appears that this is failing in gothic's CompleteUserAuth but I don't' have any way to see why it's failing.

Is this a known issue (with hopefully a simple fix) and/or is there a way for me to see what the exact error that gothic is returning?

The rest of the flow (ie. redirecting to Gitea, authorizing the application) seems to be working properly.

Thanks in advance.

Screenshot 2023-11-02 at 2 34 44 PM
@thomiceli
Copy link
Owner

The error might be written in the callback url ?

@kaysersoze
Copy link
Author

The error might be written in the callback url ?

At a OG_LOG_LEVEL of trace I only get the following in the Opengist log:

opengist | 6:17PM INF HTTP URI=/oauth/gitea/callback?code=KIOwQCdGB0Q3g8sCUFbeLgfTCWfvHAnEfBktyNf2Y0Za&state=S6_eOnt15-uW6ij7t6mOKvaGT1ZJMLYRPWl2RTfl9ZqIW2wFDucmjcp6jcnWk2iCyPGSCh7t3e4QqiP4IneQgQ%3D%3D ip=192.168.0.XXX method=GET status=400

@yedajiang44
Copy link

yedajiang44 commented Nov 8, 2023

see here

@graphixillusion
Copy link

I'm having the exact same issue using Authentik as oAuth. I think everything is configured correctly in authenthik but i get error 400 in opengist. Any clue?

@thomiceli
Copy link
Owner

I'm having the exact same issue using Authentik as oAuth. I think everything is configured correctly in authenthik but i get error 400 in opengist. Any clue?

Does your openid url ends with /.well-known/openid-configuration ?

Anyway yes, the error should be more explicit than it is right now

@thomiceli thomiceli added the bug Something isn't working label Nov 19, 2023
@graphixillusion
Copy link

graphixillusion commented Nov 19, 2023

Does your openid url ends with /.well-known/openid-configuration ?

Yep, the address ends with that. Authenthik manage these urls like this:

https://domain/application/o/opengist/.well-known/openid-configuration

opengist is the name given inside authentik

@graphixillusion
Copy link

@thomiceli ok with the new version the error msg is this:

Error 400
Bad Request
Cannot complete user auth: securecookie: the value is too long

@ghost
Copy link

ghost commented Nov 26, 2023

Same here while adding a Codeberg login.

Set redirect URI to https://opengist.example.com/oauth/gitea/callback
Set Codeberg URL, id and secret as an env variable.

But logging in with Codeberg results in Unregistered Redirect URI.

Nice to see at least the GitHub option works fine.

@thomiceli
Copy link
Owner

thomiceli commented Dec 17, 2023

Same here while adding a Codeberg login.

Set redirect URI to https://opengist.example.com/oauth/gitea/callback Set Codeberg URL, id and secret as an env variable.

But logging in with Codeberg results in Unregistered Redirect URI.

Nice to see at least the GitHub option works fine.

Codeberg is working fine for me.

By any chance did you put literally opengist.example.com in your redirect URI ?

@graphixillusion
Copy link

With the last 1.6.0 i'm still getting this error using authentik

Bad Request
Cannot complete user auth: securecookie: the value is too long: 4224

Is there something that can be adjusted authentik side to make it work?

@ghost
Copy link

ghost commented Jan 4, 2024

Same here while adding a Codeberg login.
Set redirect URI to https://opengist.example.com/oauth/gitea/callback Set Codeberg URL, id and secret as an env variable.
But logging in with Codeberg results in Unregistered Redirect URI.

Nice to see at least the GitHub option works fine.

Codeberg is working fine for me.

By any chance did you put literally opengist.example.com in your redirect URI ?

That is an example, but I used my actual domain.

@thomiceli
Copy link
Owner

With the last 1.6.0 i'm still getting this error using authentik

Bad Request Cannot complete user auth: securecookie: the value is too long: 4224

Is there something that can be adjusted authentik side to make it work?

I don't know about authentik at all but I will check

Same here while adding a Codeberg login.
Set redirect URI to https://opengist.example.com/oauth/gitea/callback Set Codeberg URL, id and secret as an env variable.
But logging in with Codeberg results in Unregistered Redirect URI.

Nice to see at least the GitHub option works fine.

Codeberg is working fine for me.
By any chance did you put literally opengist.example.com in your redirect URI ?

That is an example, but I used my actual domain.

What version of Codeberg do you use ?

@thomiceli
Copy link
Owner

With the last 1.6.0 i'm still getting this error using authentik

Bad Request Cannot complete user auth: securecookie: the value is too long: 4224

Is there something that can be adjusted authentik side to make it work?

@graphixillusion what if you only select 'profile' on your authentik provider scopes ?

Screenshot 2024-01-05 at 05 21 24

@graphixillusion
Copy link

graphixillusion commented Jan 5, 2024

With the last 1.6.0 i'm still getting this error using authentik
Bad Request Cannot complete user auth: securecookie: the value is too long: 4224
Is there something that can be adjusted authentik side to make it work?

@graphixillusion what if you only select 'profile' on your authentik provider scopes ?

Screenshot 2024-01-05 at 05 21 24

Selecting only profile in the scopes section i have this error (version 1.6.1):

Error 400
Bad Request
Cannot complete user auth: securecookie: the value is too long: 4124

@thomiceli
Copy link
Owner

Same here while adding a Codeberg login.
Set redirect URI to https://opengist.example.com/oauth/gitea/callback Set Codeberg URL, id and secret as an env variable.
But logging in with Codeberg results in Unregistered Redirect URI.

Nice to see at least the GitHub option works fine.

Codeberg is working fine for me.
By any chance did you put literally opengist.example.com in your redirect URI ?

That is an example, but I used my actual domain.

@SudoVanilla Can you ensure, when you create your Codeberg oauth application, that this option is checked ?

Screenshot 2024-01-08 at 00 10 24

@ghost
Copy link

ghost commented Jan 7, 2024

image

This option was not ticked.
Now it works, since I enabled that!

@nervous-inhuman
Copy link

nervous-inhuman commented Jan 16, 2024

With the last 1.6.0 i'm still getting this error using authentik
Bad Request Cannot complete user auth: securecookie: the value is too long: 4224
Is there something that can be adjusted authentik side to make it work?

@graphixillusion what if you only select 'profile' on your authentik provider scopes ?
Screenshot 2024-01-05 at 05 21 24

Selecting only profile in the scopes section i have this error (version 1.6.1):

Error 400 Bad Request Cannot complete user auth: securecookie: the value is too long: 4124

+1

Also having issues with Authentik and OpenGist, same error as @graphixillusion is having (also after redusing the scope to profile)

I have opened a new issue to track this separately: #212

@GhaziTriki
Copy link

@thomiceli it looks like the issue is back. Everything was working fine until I upgrade gitea and opengist. I get Unregistered Redirect URI. I double check everything, I don't see any issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants