Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 13 add keycloak support to the demo app #14

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,5 @@ application-local.yml


/project_concatenated.txt
.env
.vscode/settings.json
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"debug.javascript.defaultRuntimeExecutable": {
"pwa-node": "/Users/devon/.local/share/mise/shims/node"
},
"python.defaultInterpreterPath": "/Users/devon/.local/share/mise/installs/python/3.13.1/bin/python"
"python.defaultInterpreterPath": "/Users/devon/.local/share/mise/installs/python/3.13.2/bin/python"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Tests are currently not working. This will be fixed in the future. For now, jus
#### **Database**
The demo uses MariaDB as the default database. You can quickly spin up a MariaDB instance using Docker:
```bash
docker run -p 127.0.0.1:3306:3306 --name springuserframework \
docker run -p 127.0.0.1:3307:3306 --name springuserframework \
-e MARIADB_ROOT_PASSWORD=springuserroot \
-e MARIADB_DATABASE=springuser \
-e MARIADB_USER=springuser \
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = 'com.digitalsanctuary.springuser.demo'
version = '1.0.0-SNAPSHOT'
version = '1.0.1-SNAPSHOT'

java {
toolchain {
Expand Down Expand Up @@ -37,7 +37,7 @@ repositories {

dependencies {
// DigitalSanctuary Spring User Framework
implementation 'com.digitalsanctuary:ds-spring-user-framework:3.0.1'
implementation 'com.digitalsanctuary:ds-spring-user-framework:3.1.0-SNAPSHOT'

// Spring Boot starters
implementation 'org.springframework.boot:spring-boot-starter-actuator'
Expand Down
60 changes: 54 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.8"

services:
myapp-db:
Expand All @@ -11,8 +10,9 @@ services:
MYSQL_DATABASE: springuser
MYSQL_USER: springuser
MYSQL_PASSWORD: springuser
MYSQL_TCP_PORT: 3307
ports:
- "3306:3306"
- "3307:3307"
healthcheck:
test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ]
start_period: 1m
Expand All @@ -38,7 +38,7 @@ services:
environment:
PERMIT_DOCKER: connected-networks
ONE_DIR: 1
DMS_DEBUG: 1
DMS_DEBUG: 0
SPOOF_PROTECTION: 0
REPORT_RECIPIENT: 1
ENABLE_SPAMASSASSIN: 0
Expand All @@ -56,6 +56,7 @@ services:
retries: 5

myapp-main:
profiles: ['backend']
image: spring-user-framework-demo
container_name: springuser-app
build:
Expand All @@ -67,25 +68,72 @@ services:
mailserver:
condition: service_healthy
ports:
- "8080:8080"
- "8081:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:mariadb://myapp-db:3306/springuser?createDatabaseIfNotExist=true
SPRING_DATASOURCE_URL: jdbc:mariadb://myapp-db:3307/springuser?createDatabaseIfNotExist=true
SPRING_DATASOURCE_USERNAME: springuser
SPRING_DATASOURCE_PASSWORD: springuser
SPRING_PROFILES_ACTIVE: dev
SPRING_PROFILES_ACTIVE: docker-keycloak
SPRING_MAIL_HOST: mailserver
SPRING_MAIL_PORT: 25
SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH: "false"
SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE: "false"
SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_REQUIRED: "false"
DS_SPRING_USER_KEYCLOAK_CLIENT_ID: ds-spring-user-framework-demo
DS_SPRING_USER_KEYCLOAK_CLIENT_SECRET: FTp1j7sGvc4g3MFdghEX4n7RPhbu86PQ
DS_SPRING_USER_KEYCLOAK_PROVIDER_ISSUER_URI: http://keycloak:8080/realms/master
DS_SPRING_USER_KEYCLOAK_PROVIDER_AUTHORIZATION_URI: http://keycloak:8080/realms/master/protocol/openid-connect/auth
DS_SPRING_USER_KEYCLOAK_PROVIDER_TOKEN_URI: http://keycloak:8080/realms/master/protocol/openid-connect/token
DS_SPRING_USER_KEYCLOAK_PROVIDER_USER_INFO_URI: http://keycloak:8080/realms/master/protocol/openid-connect/userinfo
DS_SPRING_USER_KEYCLOAK_PROVIDER_JWK_SET_URI: http://keycloak:8080/realms/master/protocol/openid-connect/certs
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 10s
retries: 5

keycloak:
profiles: ['keycloak']
container_name: keycloak.openid-provider
image: quay.io/keycloak/keycloak:25.0.6
command:
- start
- --verbose
- --import-realm
ports:
- "8080:8080"
- "8443:8443"
- "9000:9000"
volumes:
- ./keycloak/ssl:/opt/keycloak/ssl/
- ./keycloak/realm:/opt/keycloak/data/import/
environment:
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
KC_DB: mariadb
KC_DB_URL: jdbc:mariadb://myapp-db:3307/springuser
KC_DB_USERNAME: springuser
KC_DB_PASSWORD: springuser
KC_RUN_IN_CONTAINER: true
KC_HOSTNAME: 0.0.0.0
KC_HTTP_ENABLED: true
KC_HTTP_HOST: 0.0.0.0
KC_HEALTH_ENABLED: true
KC_METRICS_ENABLED: true
KC_HTTPS_CERTIFICATE_FILE: /opt/keycloak/ssl/certificate.pem
KC_HTTPS_CERTIFICATE_KEY_FILE: /opt/keycloak/ssl/key.pem
healthcheck:
test: ['CMD-SHELL', '[ -f /tmp/HealthCheck.java ] || echo "public class HealthCheck { public static void main(String[] args) throws java.lang.Throwable { System.exit(java.net.HttpURLConnection.HTTP_OK == ((java.net.HttpURLConnection)new java.net.URL(args[0]).openConnection()).getResponseCode() ? 0 : 1); } }" > /tmp/HealthCheck.java && java /tmp/HealthCheck.java http://localhost:8080/auth/health/live']
interval: 5s
timeout: 5s
retries: 20
depends_on:
myapp-db:
condition: service_healthy

volumes:
maildata:
mailstate:
maillogs:
userdb:
keycloak:
Loading