PMT-14: Add Spring Security with Oauth2

This commit is contained in:
Dominik Säume 2024-09-27 12:16:41 +02:00
parent 701c2b7cd3
commit 1e65f834f5
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
2 changed files with 18 additions and 1 deletions

View file

@ -48,6 +48,11 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
// Postgres
runtimeOnly("org.postgresql:postgresql")
// Lombok
@ -57,6 +62,7 @@ dependencies {
// Test
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.boot:spring-boot-testcontainers")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:postgresql")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

View file

@ -7,3 +7,14 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/pmt
spring.datasource.username=pmt_user
spring.datasource.password=pmt123
spring.jpa.hibernate.ddl-auto=create-drop
# JWT Auth
spring.security.oauth2.client.registration.keycloak.client-id=employee-management-service
spring.security.oauth2.client.registration.keycloak.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.keycloak.scope=openid
spring.security.oauth2.client.provider.keycloak.issuer-uri=https://keycloak.szut.dev/auth/realms/szut
spring.security.oauth2.client.provider.keycloak.user-name-attribute=preferred_username
spring.security.oauth2.resourceserver.jwt.issuer-uri=https://keycloak.szut.dev/auth/realms/szut
# Debugging
logging.level.org.springframework.security=DEBUG