Skip to content

Commit

Permalink
config
Browse files Browse the repository at this point in the history
  • Loading branch information
mrFlick72 committed Oct 27, 2024
1 parent 9adad27 commit 2383795
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/main/kotlin/com/vauthenticator/server/mfa/MfaConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.vauthenticator.server.mfa

import com.hubspot.jinjava.Jinjava
import com.vauthenticator.document.repository.DocumentRepository
import com.vauthenticator.server.account.adapter.jdbc.JdbcAccountRepository
import com.vauthenticator.server.account.domain.AccountRepository
import com.vauthenticator.server.communication.NoReplyEMailConfiguration
import com.vauthenticator.server.communication.adapter.JinJavaTemplateResolver
Expand All @@ -15,13 +16,16 @@ import com.vauthenticator.server.mask.SensitiveDataMaskerResolver
import com.vauthenticator.server.mask.SensitiveEmailMasker
import com.vauthenticator.server.mask.SensitivePhoneMasker
import com.vauthenticator.server.mfa.adapter.dynamodb.DynamoMfaAccountMethodsRepository
import com.vauthenticator.server.mfa.adapter.jdbc.JdbcMfaAccountMethodsRepository
import com.vauthenticator.server.mfa.domain.*
import com.vauthenticator.server.ticket.domain.TicketCreator
import com.vauthenticator.server.ticket.domain.TicketRepository
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.mail.javamail.JavaMailSender
import software.amazon.awssdk.services.dynamodb.DynamoDbClient
import software.amazon.awssdk.services.sns.SnsClient
Expand All @@ -30,8 +34,9 @@ import java.util.*
@Configuration(proxyBeanMethods = false)
class MfaConfig {

@Bean
fun mfaAccountMethodsRepository(
@Bean("mfaAccountMethodsRepository")
@Profile("!experimental_database_persistence")
fun dynamoDbMfaAccountMethodsRepository(
keyRepository: KeyRepository,
dynamoDbClient: DynamoDbClient,
@Value("\${key.master-key}") masterKey: String,
Expand All @@ -46,6 +51,19 @@ class MfaConfig {
MasterKid(masterKey)
) { MfaDeviceId(UUID.randomUUID().toString()) }

@Bean("mfaAccountMethodsRepository")
@Profile("experimental_database_persistence")
fun jdbcMfaAccountMethodsRepository(
keyRepository: KeyRepository,
jdbcTemplate: JdbcTemplate,
@Value("\${key.master-key}") masterKey: String
): MfaAccountMethodsRepository =
JdbcMfaAccountMethodsRepository(
jdbcTemplate,
keyRepository,
MasterKid(masterKey)
) { MfaDeviceId(UUID.randomUUID().toString()) }

@Bean
fun sensitiveEmailMasker() = SensitiveEmailMasker()

Expand Down

0 comments on commit 2383795

Please sign in to comment.