-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d68238
commit 6108bbc
Showing
7 changed files
with
2,285 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
## Spring Boot Security OAuth2 Example Application ![build status](https://github.com/stojsavljevic/spring-security-oauth2/actions/workflows/maven.yml/badge.svg) | ||
# Spring Boot Security OAuth2 Example Application ![build status](https://github.com/stojsavljevic/spring-security-oauth2/actions/workflows/maven.yml/badge.svg) | ||
|
||
This example showcases Spring Security 6 OAuth2 configuration for both the client and resource server. | ||
|
||
Demonstrates Spring Security 6 OAuth2 configuration for client and resource server. | ||
## Getting Started | ||
|
||
To begin, utilize Keycloak for authentication. The recommended starting point is to build the Keycloak image using `docker-compose` and the `docker-compose.yaml` file within the `keycloak` directory. Once the image is built, start it. It will automatically import the `SpringBootKeycloak` realm from `realm-import.json`, which includes the `oauth2-client` client and the user `user/user`. Keycloak is available on port 8080, administrator credentials are `admin/admin`. | ||
|
||
Uses Keycloak (or GitHub) for authentication. Make sure that Keycloak is properly configured (realm, client, users, roles...). Client needs to have Service Accounts Enabled for client credentials flow. | ||
If you prefer to use a different Keycloak instance, ensure that Keycloak is correctly configured with the necessary realms, clients, users, and roles. The client must have Service Accounts Enabled for the client credentials flow. Adjust the `application.yaml` in both modules according to your specific settings. | ||
|
||
## Usage | ||
|
||
Configured using Spring Security properties. | ||
The `spring-security-oauth2-client` module communicates with the `spring-security-oauth2-resource-server` to retrieve the username. Refer to [spring-security-oauth2-client/README.md](spring-security-oauth2-client/README.md) for a list of endpoints that demonstrate various authentication mechanisms. | ||
|
||
|
||
`spring-security-oauth2-client` calls `spring-security-oauth2-resource-server` to get username from it. | ||
|
||
|
||
Before using application configure `application.yaml` in both modules. |
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,15 @@ | ||
version: '3' | ||
services: | ||
keycloak: | ||
image: quay.io/keycloak/keycloak:23.0.1 | ||
command: | ||
- "start-dev" | ||
- "--import-realm" | ||
ports: | ||
- "8080:8080" | ||
volumes: | ||
- ./realm-import.json:/opt/keycloak/data/import/realm-import.json | ||
environment: | ||
KEYCLOAK_ADMIN: admin | ||
KEYCLOAK_ADMIN_PASSWORD: admin | ||
KEYCLOAK_IMPORT: /opt/keycloak/data/import/realm-import.json |
Oops, something went wrong.