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

boyscout: configuration fix #255

Merged
merged 1 commit into from
Oct 30, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.vauthenticator.server.oauth2.clientapp

import com.fasterxml.jackson.databind.ObjectMapper
import com.vauthenticator.server.account.adapter.jdbc.JdbcAccountRepository
import com.vauthenticator.server.account.domain.AccountRepository
import com.vauthenticator.server.cache.CacheOperation
import com.vauthenticator.server.cache.RedisCacheOperation
import com.vauthenticator.server.oauth2.clientapp.adapter.cache.CachedClientApplicationRepository
import com.vauthenticator.server.oauth2.clientapp.adapter.cache.ClientApplicationCacheContentConverter
import com.vauthenticator.server.oauth2.clientapp.adapter.dynamodb.DynamoDbClientApplicationRepository
import com.vauthenticator.server.oauth2.clientapp.adapter.jdbc.JdbcClientApplicationRepository
import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository
import com.vauthenticator.server.oauth2.clientapp.domain.ReadClientApplication
import com.vauthenticator.server.oauth2.clientapp.domain.StoreClientApplication
Expand All @@ -14,7 +17,9 @@ import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
import org.springframework.data.redis.core.RedisTemplate
import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.security.crypto.password.PasswordEncoder
import software.amazon.awssdk.services.dynamodb.DynamoDbClient
import java.time.Duration
Expand All @@ -23,16 +28,20 @@ import java.time.Duration
class ClientApplicationConfig {


@Bean("clientApplicationRepository")
@Profile("experimental_database_persistence")
fun jdbcClientApplicationRepository(jdbcTemplate: JdbcTemplate, objectMapper: ObjectMapper) : ClientApplicationRepository =
JdbcClientApplicationRepository(jdbcTemplate, objectMapper)

@Bean("clientApplicationRepository")
@ConditionalOnProperty(
name = ["vauthenticator.dynamo-db.client-application.cache.enabled"],
havingValue = "false",
matchIfMissing = true
)
fun clientApplicationRepository(
@Profile("!experimental_database_persistence")
fun dynamoDbClientApplicationRepository(
dynamoDbClient: DynamoDbClient,
passwordEncoder: PasswordEncoder,
objectMapper: ObjectMapper,
@Value("\${vauthenticator.dynamo-db.client-application.table-name}") clientAppTableName: String
) = DynamoDbClientApplicationRepository(dynamoDbClient, clientAppTableName)

Expand All @@ -42,9 +51,9 @@ class ClientApplicationConfig {
havingValue = "true",
matchIfMissing = false
)
@Profile("!experimental_database_persistence")
fun cachedClientApplicationRepository(
dynamoDbClient: DynamoDbClient,
passwordEncoder: PasswordEncoder,
clientApplicationCacheOperation: CacheOperation<String, String>,
objectMapper: ObjectMapper,
@Value("\${vauthenticator.dynamo-db.client-application.cache.enabled:false}") withCash: Boolean,
Expand All @@ -61,6 +70,7 @@ class ClientApplicationConfig {
havingValue = "true",
matchIfMissing = false
)
@Profile("!experimental_database_persistence")
fun clientApplicationCacheOperation(
redisTemplate: RedisTemplate<*, *>,
@Value("\${vauthenticator.dynamo-db.client-application.cache.ttl}") ttl: Duration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class PermissionConfig {
)
@Profile("!experimental_database_persistence")
fun dynamoDbRoleRepository(
mapper: ObjectMapper,
dynamoDbClient: DynamoDbClient,
@Value("\${vauthenticator.dynamo-db.role.table-name}") roleTableName: String,
@Value("\${vauthenticator.dynamo-db.role.protected-from-delete}") protectedRoleFromDeletion: List<String>
Expand Down
Loading