-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add support for PKCE #265
Merged
Merged
Add support for PKCE #265
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ce9584d
Added support for PKCE
gdasson bdf3f0c
Added support for PKCE - Updated unit tests and fixed formatting
gdasson 232093f
Added support for PKCE - Updated keycloak setup to enable PKCE for e2…
gdasson ef147fd
Added support for PKCE - Updated go.mod with dependencies
gdasson c627e8d
Added support for PKCE - Fixed linting issues
gdasson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,5 @@ type AuthorizationState struct { | |
State string | ||
Nonce string | ||
RequestedURL string | ||
CodeVerifier string | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Update this test and the random one to also include a check for the code verifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nacx : Thanks for the review. Yes, there is a way to configure keycloak to enforce PKCE use by client. Infact, I also used keycloak for my local testing. In the UI, It's available under Client > Advanced > Proof Key for Code Exchange Code Challenge Method > Set it to S256. (However, I am not sure if the same setting is available through the Keycloak admin API)
Here is a screenshot from the UI:
![image](https://private-user-images.githubusercontent.com/38967728/375150298-e99369f2-1386-4a8a-91b2-262e7ee21df1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNzU1MDIsIm5iZiI6MTczOTI3NTIwMiwicGF0aCI6Ii8zODk2NzcyOC8zNzUxNTAyOTgtZTk5MzY5ZjItMTM4Ni00YThhLTkxYjItMjYyZTdlZTIxZGYxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDEyMDAwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRlM2NlMTVlZTlhZGVlNmFjMTU1MzhlZjUzYTM0M2QyZDY0ODE5N2Y2Mjc3Yzk3NjlkNjBjMzRkY2I0NjliMzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.35GYvRdkGZN1DeclX_XluKPKd8t0_UZptHQAmiBp90Q)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client is created and configured here: https://github.com/istio-ecosystem/authservice/blob/main/e2e/keycloak/setup-keycloak.sh#L50-L58
Let's see if PKCE can be configured in that script.
Actually, there is probably no need to create another suite. The
istio
suite also uses Keycloak, so we can just change thekeycloak
suite and we should have all cases covered.Testing ti locally should be easy:
Or you can start the infra and run the tests from your IDE: https://github.com/istio-ecosystem/authservice/blob/main/DEVELOPMENT.md#running-tests-from-your-ide
Keycloak will be accessible on
https://localhost:9443
(admin / admin)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this to the keycloak setup script sould do the trick, to enforce PKCE server-side:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added and ran e2e tests, they run fine. Also physically checked the setting in the UI before destroying infra.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I run the e2e with this setting but without the changes in the PR and they were failing, complaining about the missing query params, so all good!