Skip to content

Commit 2495025

Browse files
committed
authcodegrant samples->oauth2webclient samples
The authcodegrant samples were initially meant to be very simple demonstration of authorization code flow. However, it has become obvious since then that the real intent of the demo is how to use the WebClient with OAuth (there is no other reason to do authorization code flow unless you use the token to make a request). The samples have been migrated to oauth2webclient and oauth2webclient-webflux respectively. They have been improved: * The sample demonstrates usage with annotations, webclient directly, form login oauth2Login, and public APIs * The samples externalize the endpoint that is requested in the sample making it easier to try other endpoints * The UI no longer relies on a data structure for the result of the endpoint also making it easier to try other endpoints Issue: gh-4921
1 parent 438d291 commit 2495025

30 files changed

+582
-421
lines changed

samples/boot/authcodegrant-webflux/src/integration-test/java/sample/OAuth2AuthorizationCodeGrantApplicationTests.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

samples/boot/authcodegrant-webflux/src/main/resources/application.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

samples/boot/authcodegrant-webflux/src/main/resources/templates/github-repos.html

Lines changed: 0 additions & 26 deletions
This file was deleted.

samples/boot/authcodegrant/src/integration-test/java/org/springframework/security/samples/OAuth2AuthorizationCodeGrantApplicationTests.java

Lines changed: 0 additions & 183 deletions
This file was deleted.

samples/boot/authcodegrant/src/main/resources/application.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

samples/boot/authcodegrant/src/main/resources/templates/github-repos.html

Lines changed: 0 additions & 28 deletions
This file was deleted.

samples/boot/authcodegrant-webflux/README.adoc renamed to samples/boot/oauth2webclient-webflux/README.adoc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
= OAuth 2.0 Authorization Code Grant Sample
1+
= OAuth 2.0 WebClient (WebFlux) Sample
22

33
== GitHub Repositories
44

5-
This guide provides instructions on setting up the sample application, which leverages the OAuth 2.0 Authorization Code Grant, and displays a list of public GitHub repositories that are accessible to the authenticated user.
5+
This guide provides instructions on setting up the sample application, which leverages WebClient OAuth2 integration to display a list of public GitHub repositories that are accessible to the authenticated user.
66

77
This includes repositories owned by the authenticated user, repositories where the authenticated user is a collaborator, and repositories that the authenticated user has access to through an organization membership.
88

@@ -17,7 +17,7 @@ The following sections provide detailed steps for setting up the sample and cove
1717

1818
To use GitHub's OAuth 2.0 authorization system, you must https://github.com/settings/applications/new[Register a new OAuth application].
1919

20-
When registering the OAuth application, ensure the *Authorization callback URL* is set to `http://localhost:8080/github-repos`.
20+
When registering the OAuth application, ensure the *Authorization callback URL* is set to `http://localhost:8080/login/oauth2/code/client-id`.
2121

2222
The Authorization callback URL (redirect URI) is the path in the application that the end-user's user-agent is redirected back to after they have authenticated with GitHub and have granted access to the OAuth application on the _Authorize application_ page.
2323

@@ -36,12 +36,11 @@ spring:
3636
oauth2:
3737
client:
3838
registration: <1>
39-
github: <2>
40-
client-id: github-client-id
41-
client-secret: github-client-secret
42-
scope: public_repo
43-
redirect-uri-template: "{baseUrl}/github-repos"
44-
client-name: GitHub Repositories
39+
client-id: <2>
40+
client-id: replace-with-client-id
41+
client-secret: replace-with-client-secret
42+
provider: github
43+
scopes: read:user,public_repo
4544
----
4645
+
4746
.OAuth Client properties
@@ -57,7 +56,7 @@ spring:
5756

5857
Launch the Spring Boot 2.0 sample and go to `http://localhost:8080`.
5958
You are then redirected to the default _auto-generated_ form login page.
60-
Log in using *'user'* (username) and *'password'* (password) and then you'll be redirected to GitHub for authentication.
59+
Log in using *'user'* (username) and *'password'* (password) or click the link to authenticate with GitHub and then you'll be redirected to GitHub for authentication.
6160

6261
After authenticating with your GitHub credentials, the next page presented to you is "Authorize application".
6362
This page will ask you to *Authorize* the application you created in the previous step.

0 commit comments

Comments
 (0)