-
Notifications
You must be signed in to change notification settings - Fork 694
Ory Hydra cannot parse the base64 encoded code_verifier parameter on token request #628
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
Comments
Interesting. I've seen this library work with at least IdentityServer4, and I believe others used other IDSes successfully with code/pkce. You mention that "[the code is] 33 characters at the mooment" but I count 46 in the one you posted, which is more than the required minimum of 43. Is it possible that this is a problem with your IDS implementation or configuration? On the other hand, looking at your configuration for the JS library, it's significantly different from my attempt at using Code/PKCE, specifically the redirect uri (which is mentioned in your error message):
Hope that helps. |
Hi @jeroenheijmans thanks for the help. After I wrote this I actually tried switching out my Hydra endpoint and client ID with the one you have (I think I found your example repo), and it worked completely correctly.
Sorry for the confusion, the encoded string is indeed not 33 but actually 45 long which I think comes from here https://github.com/manfredsteyer/angular-oauth2-oidc/blob/master/projects/lib/src/oauth-service.ts#L2091. What is 33 long is the number of decoded bytes that that maps to. I have now tried changing the generated nonce length to 46 rather then 45 and now it works with Ory Hydra and IdentityServer4. Now the reason behind this escapes me at the moment, I may open an issue up in the Hydra repo to see if anyone there can explain. |
Okay let us know what you find, and whether we might close this issue for now until we know the culprit is on the angular library side? |
The more I look at this, the |
I think this is on purpose. Base64 is just that, and base64 url-encoded is something else. The latter is required by the spec. In fact, part 4.2 of the spec adds even more 'magic' to this, for fully compliant implementations. It might be that your server only supports |
Hi @jeroenheijmans after reading the spec, I am close to convinced the The modified implementation is like this, I quoted the parts of the spec so you can see my reasoning.
|
Hi @jeroenheijmans ,I am also facing the same issue posted by @jfyne regarding base64 encoding using with using Ory Hydra as my identity provider
can we have a solution for this as PR already raised by @jfyne |
Correct implementation of rfc7636 section 4.1
Branch got merged, I presume this is now fixed in version 9. Closing the issue, let us know if it persisted nonetheless. |
@jeroenheijmans I have tested with the new release, everything works as expected. Thanks! |
My Problem
I am trying to implement Code Flow + PKCE, using Ory Hydra as my identity provider. I am unable to retrieve a token. I believe the problem originates with this library and the way it generates the
code_verifier
parameter for token request (although I am not certain).My config:
What works so far is the redirect to login with
initCodeFlow()
, I am redirected back to my angular app and thenangular-oauth2-oidc
attempts to request the token. This is where it starts to go wrong. The request that is made (I formatted it as CURL because its easy to read):The bit that is apparently not working is this:
The response I get from Hydra is this
Now tracking this down to their code base the
error_hint
field is useful we see this code https://github.com/ory/fosite/blob/master/handler/pkce/handler.go#L176-L203. I've also used the Go playground to replicate it: https://play.golang.net/p/vVz7UOVd7-y. I have also noticed if I change the length of the verifier string by 1 character it parses successfully (its 33 characters at the moment).Have I misconfigured the library somehow? Is this a bug?
Expected behavior
A valid token exchange.
The text was updated successfully, but these errors were encountered: