question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support OAuth 2.0 Authorization Code flow with PKCE

See original GitHub issue

Is your feature request related to a problem?

In the light of the new IETF related to OAuth 2.0 for Browser-Based Apps (see 4. Overview), an application running in a browser and using the Authorization Code flow should be using PKCE (Proof Key for Code Exchange) for increased security. It is not the case currently with swagger-ui. This article by Brock Allen also touches on the subject.

Describe the solution you’d like

Everytime the authorizationCode flow is used (these are based on the PKCE IETF linked above):

  1. A code_verifier is generated (potentially using uuid4 like they do in oidc-client-js). This value needs to stored somewhere because it needs to be sent on the Token request (looking at the code, I figured win.swaggerUIRedirectOauth2 would be the right place to store this).
  2. Create the code_challenge for the code_verifier (hashed using SHA256) and send this on the Authorize request alongside the code_challenge_method.

Describe alternatives you’ve considered

  • I’ve considered using additionalQueryStringParams to feed in the code_verifier and the code_challenge, but these values need to be generated on each authorize request.
  • I’ve considered using the Inject JavaScript functionality, but I feel like I would be replacing whole methods from swagger-ui which would bind me to a certain version of the code.

Additional context

I feel this is something that should be introduced into swagger-ui because of the added security it provides. Everybody would and should benefit from it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:15
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
poveilleuxcommented, May 18, 2019

@fuzzzerd Thank you for the tip. This is my first ever pull request on a public repository on GitHub, so I did not know that’s how it works. I will do that to submit my pull request.

1reaction
poveilleuxcommented, May 13, 2019

I will try to submit a pull request for this feature request this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authorization Code Flow with Proof Key for Code Exchange ...
Learn about the OAuth 2.0 grant type, Authorization Code Flow with Proof Key for Code Exchange (PKCE). · Use this grant type for...
Read more >
Implement the OAuth 2.0 Authorization Code with PKCE Flow
This tutorial shows you how to migrate from the OAuth 2.0 Implicit flow to the more secure Authorization Code with PKCE flow.
Read more >
PKCE for OAuth 2.0
PKCE (RFC 7636) is an extension to the Authorization Code flow to prevent CSRF and authorization code injection attacks. PKCE is not a...
Read more >
OAuth 2.0 Authorization Code Flow with PKCE | Docs
An extension to the authorization code flow to prevent several attacks and to be able to perform the OAuth exchange from public clients...
Read more >
Authorization Code Flow With PKCE - Cloudentity
Authorization code grant with the Proof Key of Code Exchange (PKCE) is an extension of the standard authorization code grant OAuth flow.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found