IdentityPython / pyop

OpenID Connect Provider (OP) library in Python.
Apache License 2.0
87 stars 33 forks source link

Add pkce support #38

Closed maxxiefjv closed 3 years ago

maxxiefjv commented 3 years ago

Add PKCE support when requested by the client. Used reference is displayed in RFC 7636. Only for the authorization_code flow.

https://datatracker.ietf.org/doc/html/rfc7636

New requests optionally include the query parameters: code_challenge and code_challenge_method on the initial authorize request, then on token_endpoint it is required to contain a code_verifier parameter containing the code_verifier used to create the hash passed earlier as code_challenge.

annejan commented 3 years ago

This helps a lot, hope it gets merged quickly . .

c00kiemon5ter commented 3 years ago

Hello @maxxiefjv and thanks for this effort. I can see that pyoidc (aka oic) already implements PKCE support. Is there a reason we cannot use that support directly?

see,

maxxiefjv commented 3 years ago

Hi @c00kiemon5ter,

Thanks for the reply!

Sorry for my late response. To be honest, I missed that implementation completely. Although, it seems to me its an incomplete extension? Or I am missing some features here? (Also, I believe that your library does not use the Client class extensively, making the use of the functions in their classes not so straight forward as one might like?)

Reusing as much code as possible, I now changed the code_verifier to use the function included in the OIC provider extension (which also allows the removal of the dependency on the nacl library). Note though, that this function lacks plaintext support, even though the RFC7637 (https://datatracker.ietf.org/doc/html/rfc7636#section-4.2) standard shows that should be supported. Hence, I removed the test.

Looking forward to your thoughts on this

c00kiemon5ter commented 3 years ago

thank you @maxxiefjv