https://github.com/zitadel/zitadel-java
https://github.com/zitadel/zitadel-java
examples java zitadel
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zitadel/zitadel-java
- Owner: zitadel
- License: apache-2.0
- Created: 2022-11-23T10:09:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-01T07:18:34.000Z (about 1 year ago)
- Last Synced: 2024-03-01T08:30:08.740Z (about 1 year ago)
- Topics: examples, java, zitadel
- Language: Java
- Homepage:
- Size: 614 KB
- Stars: 12
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## ZITADEL Example Project with Spring Boot and Spring Security
This example contains two Spring Boot Apps (_api_ and _app_) which use the [ZITADEL](https://zitadel.com/) SaaS identity provider as OpenID Provider.
- The app _web_ uses the internal OAuth2 access token (opaque token) provided by ZITADEL to access the _api_.
- The _api_ acts as an OAuth2 resource server.# Features
- OpenID Connect based Login
- Logout support via OpenID Connect end session endpoint
- Access Token Relay
- Opaque Reference Tokens and Token Introspection# Applications
To run the example you need to configure the applications in ZITADEL and provide the generated properties.
Please check out the full guides ([web](https://zitadel.com/docs/examples/login/java-spring) and [api](https://zitadel.com/docs/examples/secure-api/java-spring)) on this example as well.## API
The Spring Boot app _api_ is configured as an API in ZITADEL and uses the Spring Security Resource Server support.
Base URL: http://localhost:18090
## Web
The Spring Boot app _web_ is configured as confidential Web App and OpenID Connect client in ZITADEL and uses the Spring Security OAuth2 client library
for authentication.Base URL: `http://localhost:18080/webapp`
Redirect URI:
```
http://localhost:18080/webapp/login/oauth2/code/zitadel
```Post Logout URL:
```
http://localhost:18080/webapp
```# Build
```
mvn clean package -DskipTests
```# Run
The _api_ application requires the following JVM Properties to be configured:
```bash
# Run the api application in one terminal
java \
-Dspring.security.oauth2.resourceserver.opaquetoken.introspection-uri= \
-Dspring.security.oauth2.resourceserver.opaquetoken.client-id= \
-Dspring.security.oauth2.resourceserver.opaquetoken.client-secret= \
-jar api/target/api-0.0.2-SNAPSHOT.jar
```The _web_ application requires the following JVM Properties to be configured:
```bash
# Run the web application in another terminal
java \
-Dspring.security.oauth2.client.provider.zitadel.issuer-uri= \
-Dspring.security.oauth2.client.registration.zitadel.client-id= \
-jar web/target/web-0.0.2-SNAPSHOT.jar
```Open your browser and navigate to http://localhost:18080/webapp/
# Misc
- This example uses opaque reference tokens as access tokens
- For the sake of simplicity CSRF protection and https are disabled
- Note in order to allow `http://` URIs we need to enable the `development mode in the respective client configuration.