Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: add PKCE support to AuthorizationCodeFlow (#470)
* Initial test code for a PKCE enabled Authorization Code Flow * WIP: work on README.md * Script to initialize keycloak by adding client via REST API. * Improve keycloak init script and some code cleanup. Still WIP. * WIP: work on README.md * Working PKCE AuthorizationCodeFlow. Some cleanup of test classes. * Add scopes back to the AuthorizationCodeRequestUrl creation. * Simplify code by moving PKCE entirely into the AuthorizationCodeFlow class. Add documentation. * Remove wildcard imports as that seems to be the way to do things here. * Add @SInCE annotation in JavaDoc to the PKCE parameters of the autorization url class. * Add PKCE unit test, documentation and minor cleanup of dependencies for code sample. * Add PKCE unit test, documentation and minor cleanup of dependencies for code sample. * Annotate PKCE with Beta annotation. * Responding to code review comments * Responding to more PR comments * Improve Keycloak PKCE sample documentation * Add license header with copyright to new files. Improve documentation.
- Loading branch information
Showing
9 changed files
with
466 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Instructions for the Keycloak OAuth2 with PKCE Command-Line Sample | ||
|
||
## Browse Online | ||
|
||
[Browse Source][browse-source], or main file [PKCESample.java][main-source]. | ||
|
||
## Command-Line Instructions | ||
|
||
**Prerequisites:** install [Java 7 or higher][install-java], [git][install-git], and | ||
[Maven][install-maven]. You may need to set your `JAVA_HOME`. | ||
You'll also need [Docker][install-docker]. | ||
|
||
1. Check out the sample code: | ||
|
||
```bash | ||
git clone https://github.com/google/google-oauth-java-client.git | ||
cd google-oauth-java-client | ||
``` | ||
|
||
2. Run keycloak in a docker container: | ||
|
||
``` | ||
docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:10.0.1 | ||
``` | ||
|
||
3. Run the sample: | ||
|
||
```bash | ||
mvn install | ||
mvn exec:java -pl samples/keycloak-pkce-cmdline-sample | ||
``` | ||
|
||
This will open up the Keycloak login page where you can log in with the username/password specified | ||
when running the Keycloak docker container above (`admin / admin`). Once you log in, the application | ||
will print out a message that it successfully obtained an access token. | ||
|
||
[browse-source]: https://github.com/google/google-oauth-java-client/tree/dev/samples/keycloak-pkce-cmdline-sample | ||
[main-source]: https://github.com/google/google-oauth-java-client/blob/dev/samples/keycloak-pkce-cmdline-sample/src/main/java/com/google/api/services/samples/keycloak/cmdline/PKCESample.java | ||
[install-java]: https://java.com/ | ||
[install-git]: https://git-scm.com | ||
[install-maven]: https://maven.apache.org | ||
[install-docker]: https://docs.docker.com/get-docker/ |
Oops, something went wrong.