Closed druchoo closed 2 years ago
Your report is appreciated. Please star this repository to motivate its developers! :star:
redirect url should be: https://homer.myco.com/api/v3/oauth2/auth
please check change and try again
@adubovikov with "redirect_uri": "https://homer.myco.com/api/v3/oauth2/auth"
I get:
Looking at the code it seems auth
is already appended from "provider_name": "auth"
?
And n the Okta config Sign-in redirect URIs
is set to https://homer.myco.com/api/v3/oauth2/auth
..
EDIT:
And if Okta is configured with https://homer.myco.com/api/v3/oauth2/auth/auth
we get:
{"data":{},"message":"oauth2: cannot fetch token: 400 Bad Request\nResponse: {\"error\":\"invalid_grant\",\"error_description\":\"The authorization code is invalid or has expired.\"}"}
@druchoo because we use "provider" as param and in your case you have "auth" -> that makes /auth/auth
if you want, change the param to "okta".
https://github.com/sipcapture/homer-app/blob/master/router/v1/user.go#L57
//Oauth2 Request
acc.GET("/oauth2/auth/:provider", urc.AuthSericeRequest)
can you please provide the debug log of homer-app, specially during request of api/v3/oauth2/auth/"provider" (auth)
thank you
i think you should register correct redirect_uri by OKTA with 2 auth - https://homer.myco.com/api/v3/oauth2/auth/auth
or if you will change your provider name to "okta" it will be -> https://homer.myco.com/api/v3/oauth2/auth/okta
@druchoo any progress ?
@adubovikov I am @druchoo's colleague working on this Oauth. We are seeing the following in the debug log:
{"level":"debug","msg":"Doing AuthSericeRequest for provider: okta","time":"2021-12-10T13:00:21Z"}
{"level":"error","msg":"AuthSericeRequest OAuth2Config Exchange is invalid:oauth2: cannot fetch token: 400 Bad Request\nResponse:
{\"error\":\"invalid_grant\",\"error_description\":\"The authorization code is invalid or has expired.\"}","time":"2021-12-10T13:00:21Z"}
{"level":"debug","msg":"================================","time":"2021-12-10T13:00:21Z"}
{"level":"debug","msg":"--------request body-------","time":"2021-12-10T13:00:21Z"}
{"json":"","level":"info","msg":"Payload","time":"2021-12-10T13:00:21Z"}
{"level":"info","msg":"---------------------------","time":"2021-12-10T13:00:21Z"}
{"level":"debug","msg":"-------- response body --------","time":"2021-12-10T13:00:21Z"}
{"json":"{\"data\":{},\"message\":\"oauth2: cannot fetch token: 400 Bad Request\nResponse:
{\\"error\\":\\"invalid_grant\\",\\"error_description\\":\\"The authorization code is invalid or has expired.\\"}\"}","level":"info","msg":"Payload","time":"2021-12-10T13:00:21Z"}
{"level":"debug","msg":"-------------------------------","time":"2021-12-10T13:00:21Z"}
@adubovikov - any progress on this? Do you need any more info from us?
Is the issue because of this? https://devforum.okta.com/t/v1-token-400-error-when-token-has-expired/8637/11
@pgopu lets say, this is not the "standard" way to do it. Anyway, lets try:
https://github.com/sipcapture/homer-app/commit/5a2f51128302283148151f9fbd9114d1351bc083
and in the config:
oauth2.auth_style = 1
@adubovikov - I tried with latest master, and updated the config to include auth_style=1. I got the following error:
{"data":{},"message":"oauth2: cannot fetch token: 400 Bad Request\nResponse: {\"error\":\"invalid_grant\",\"error_description\":\"PKCE verification failed.\"}"}
https://github.com/sipcapture/homer-app/commit/aa75dd5c8c45dc265038f07aa389eb37337565a0
before I will check, does Okta have a free accounts to check auth ?
@adubovikov - I have tried with your latest commit (aa75dd5) still the same result PKCE verification failed.
@pgopu this is as far as we can go without having access to the affected platform (we do not) If you'd like to sponsor this change request, please consider a donation to the project
Would you like to sign up on okta? https://developer.okta.com/signup/
I will check with my team about your request.
I know its almost Christmas, but It is not realistic to expect OSS developers to signup with any 3rd party service when requested to support it freely :) jokes aside, if you would like to express this process, we appreciate any counter support
@adubovikov - I have tested with some changes done in homer-app code in my fork https://github.com/pgopu/homer-app to make it work with Okta Oauth2. You can check the code in that branch.
I still have one issue with Okta is that it is not able to match the code_challenger and code_verifier when used https://github.com/sipcapture/homer-app/blob/d4f20880d224b6cd5f857048d5899eb89aac4718/utils/heputils/heputils.go#L357 function.
It worked when I hardcoded their documented values. https://developer.okta.com/docs/guides/implement-grant-type/authcodepkce/main/#create-the-proof-key-for-code-exchange
Could you please take a look at the changes, and advise on next steps? Thank you!
@adubovikov - we still need to merge the changes from my branch. Shall I create a PR for you? My branch is https://github.com/pgopu/homer-app. Please take a look at newer changes to GenCodeChallengeS256 function in my branch: https://github.com/pgopu/homer-app.
@adubovikov here is the PR: https://github.com/sipcapture/homer-app/pull/463 with all the changes. I have tested with Okta Oauth. All the parameters that were added are needed particularly for Okta, might be optional for other Oauth providers.
@pgopu merged :-) lets test ?
@adubovikov - Sure! Will test and update here. Thank you!
@adubovikov - tested and it works!!! 👯
@adubovikov - Could you please cut the release?
@pgopu pushed and released!
@pgopu I am closing the ticket. Thanks to everybody!
Trying to configure Okta OAuth following examples from https://github.com/sipcapture/homer-app/issues/440 with the following config.
The flow seems to kick off but in the end UI redirects to
https://homer.myco.com/api/v3/oauth2/auth?code=xxxx&state=yyy
and receive the error: