Update oauth login samples
Closes gh-29
This commit is contained in:
committed by
Steve Riesenberg
parent
6548ff0876
commit
52cc331d9c
@@ -1,6 +1,6 @@
|
||||
= OAuth 2.0 Authorization Server Sample
|
||||
|
||||
This sample demonstrates Authorization Server with the `client_credentials` grant type. This authorization server is configured to generate JWT tokens signed with the `RS256` algorithm.
|
||||
This sample demonstrates Authorization Server with the `authorization_code` and `client_credentials` grant types, as well as OpenID Connect 1.0. This authorization server is configured to generate JWT tokens signed with the `RS256` algorithm.
|
||||
|
||||
* <<running-the-tests, Running the tests>>
|
||||
* <<running-the-app, Running the app>>
|
||||
@@ -19,29 +19,11 @@ Or import the project into your IDE and run `OAuth2AuthorizationServerApplicatio
|
||||
|
||||
=== What is it doing?
|
||||
|
||||
The tests are making requests to the token endpoint with the `client_credentials` grant type using the `client_secret_basic` authentication method, and subsequently verifying them using the token introspection endpoint.
|
||||
The tests are making requests to the token endpoint with the `client_credentials` grant type using the `client_secret_basic` authentication method, and subsequently verifying the access token from the response using the token introspection endpoint.
|
||||
|
||||
The introspection endpoint response is used to verify the token (decode the JWT in this case), returning the payload including the requested scope:
|
||||
The introspection endpoint response is used to verify the token (decode the JWT in this case), returning the payload including the requested scope.
|
||||
|
||||
```json
|
||||
{
|
||||
"active": true,
|
||||
"aud": [
|
||||
"messaging-client"
|
||||
],
|
||||
"client_id": "messaging-client",
|
||||
"exp": 1627070941,
|
||||
"iat": 1627070641,
|
||||
"iss": "http://localhost:9000",
|
||||
"jti": "987599e3-1048-4fe8-89df-ad113aef2d6c",
|
||||
"nbf": 1627070641,
|
||||
"scope": "message:read",
|
||||
"sub": "messaging-client",
|
||||
"token_type": "Bearer"
|
||||
}
|
||||
```
|
||||
|
||||
Note that Spring Security does not require the token introspection endpoint when configured to use the Bearer scheme with JWTs, this is simply used for demonstration purposes.
|
||||
NOTE: Spring Security does not require the token introspection endpoint when configured to use the Bearer scheme with JWTs, this is simply used for demonstration purposes.
|
||||
|
||||
[[running-the-app]]
|
||||
== Running the app
|
||||
@@ -106,31 +88,9 @@ Which will return something like the following:
|
||||
[[testing-with-a-resource-server]]
|
||||
== Testing with a resource server
|
||||
|
||||
This sample can be used in conjunction with a resource server, such as the https://github.com/spring-projects/spring-security-samples/tree/main/servlet/spring-boot/java/oauth2/resource-server/hello-security[resource-server sample] in this project.
|
||||
This sample can be used in conjunction with a resource server, such as the https://github.com/spring-projects/spring-security-samples/tree/main/servlet/spring-boot/java/oauth2/resource-server/hello-security[resource-server sample] in this project which is pre-configured to work with this authorization server sample out of the box.
|
||||
|
||||
To change the sample to point to this authorization server, simply find this property in that project's `application.yml`:
|
||||
|
||||
```yaml
|
||||
spring:
|
||||
security:
|
||||
oauth2:
|
||||
resourceserver:
|
||||
jwt:
|
||||
jwk-set-uri: ${mockwebserver.url}/.well-known/jwks.json
|
||||
```
|
||||
|
||||
And change the property to:
|
||||
|
||||
```yaml
|
||||
spring:
|
||||
security:
|
||||
oauth2:
|
||||
resourceserver:
|
||||
jwt:
|
||||
jwk-set-uri: http://localhost:9000/oauth2/jwks
|
||||
```
|
||||
|
||||
And then you can run that app similarly to the authorization server:
|
||||
You can run that app similarly to the authorization server:
|
||||
|
||||
```bash
|
||||
./gradlew bootRun
|
||||
|
||||
Reference in New Issue
Block a user