Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyfrs committed Aug 8, 2024
1 parent 885df9d commit a28a326
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ services:
DB_NAME: stock
DB_USERNAME: selforder
DB_PASSWORD: self@Order123!
ADMIN_ACCESS_TOKEN: token
ports:
- "8081:8081"
restart: always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.fiap.stock.application.config

import io.swagger.v3.oas.annotations.enums.SecuritySchemeType
import io.swagger.v3.oas.annotations.security.SecurityScheme
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpMethod
Expand All @@ -19,6 +20,11 @@ import org.springframework.security.web.SecurityFilterChain
bearerFormat = "JWT",
scheme = "bearer"
)
@ConditionalOnProperty(
value = ["security.enable"],
havingValue = "true",
matchIfMissing = true
)
class JWTSecurityConfig {
@Bean
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"properties": [
{
"name": "admin.access-token",
"type": "java.lang.String",
"description": "Description for admin-access-token."
},
{
"name": "payment-provider.mock",
"type": "java.lang.String",
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/application-live.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
security:
enable: true

spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: ${COGNITO_ISSUER_URI}
jwk-set-uri: ${COGNITO_JWK_SET_URI}
3 changes: 0 additions & 3 deletions src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
admin:
access-token: token

payment-provider:
mock: true
12 changes: 3 additions & 9 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@ spring:
non_contextual_creation: true
ddl-auto: validate
globally_quoted_identifiers: true
security:
oauth2:
resourceserver:
jwt:
issuer-uri: https://cognito-idp.us-east-1.amazonaws.com/us-east-1_ygM5FRn7D
jwk-set-uri: https://cognito-idp.us-east-1.amazonaws.com/us-east-1_ygM5FRn7D/.well-known/jwks.json

admin:
access-token: ${ADMIN_ACCESS_TOKEN}

server:
port: 8081

security:
enable: false
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class PostgreSQLContainerInitializer :
companion object {
private val instance: PostgreSQLContainerInitializer =
PostgreSQLContainerInitializer()
.withDatabaseName("stockdb")
.withUsername("stock")
.withPassword("stock")
.withDatabaseName("database")
.withUsername("database")
.withPassword("database")
.waitingFor(forListeningPort())
}

Expand Down

0 comments on commit a28a326

Please sign in to comment.