style: スタイルを修正

This commit is contained in:
2023-09-19 16:21:35 +09:00
parent e05db6dd91
commit 8ab55cb248
13 changed files with 28 additions and 27 deletions
@@ -4,7 +4,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.ConfigurationPropertiesScan
import org.springframework.boot.runApplication
@SpringBootApplication
@ConfigurationPropertiesScan
class SpringApplication
@@ -6,7 +6,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class DatabaseConfig {
@@ -22,10 +21,8 @@ class DatabaseConfig {
password = dbConfig.password
)
}
}
@ConfigurationProperties("hideout.database")
data class DatabaseConnectConfig(
val url: String,
@@ -38,7 +38,8 @@ class SecurityConfig {
http
.exceptionHandling {
it.defaultAuthenticationEntryPointFor(
LoginUrlAuthenticationEntryPoint("/login"), MediaTypeRequestMatcher(MediaType.TEXT_HTML)
LoginUrlAuthenticationEntryPoint("/login"),
MediaTypeRequestMatcher(MediaType.TEXT_HTML)
)
}
.oauth2ResourceServer {
@@ -50,7 +51,6 @@ class SecurityConfig {
return http.build()
}
@Bean
@Order(2)
fun defaultSecurityFilterChain(http: HttpSecurity): SecurityFilterChain {
@@ -121,7 +121,6 @@ class SecurityConfig {
}
}
@ConfigurationProperties("hideout.security.jwt")
@ConditionalOnProperty(name = ["hideout.security.jwt.generate"], havingValue = "")
data class JwkConfig(
@@ -8,7 +8,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement
import org.springframework.transaction.annotation.TransactionManagementConfigurer
import javax.sql.DataSource
@Configuration
@EnableTransactionManagement
class SpringTransactionConfig(val datasource: DataSource) : TransactionManagementConfigurer {
@@ -1,5 +1,6 @@
package dev.usbharu.hideout.controller
import dev.usbharu.hideout.controller.generated.DefaultApi
import dev.usbharu.hideout.domain.model.hideout.dto.JwtToken
import dev.usbharu.hideout.service.api.UserAuthApiService
import org.springframework.http.HttpStatus
@@ -87,7 +87,6 @@ class RegisteredClientRepositoryImpl(private val database: Database) : Registere
}
}
// org/springframework/security/oauth2/server/authorization/client/oauth2-registered-client-schema.sql
object RegisteredClient : Table("registered_client") {
val id = varchar("id", 100)
@@ -108,7 +107,6 @@ object RegisteredClient : Table("registered_client") {
}
fun ResultRow.toRegisteredClient(): SpringRegisteredClient {
fun resolveClientAuthenticationMethods(string: String): ClientAuthenticationMethod {
return when (string) {
ClientAuthenticationMethod.CLIENT_SECRET_BASIC.value -> ClientAuthenticationMethod.CLIENT_SECRET_BASIC
@@ -160,7 +158,6 @@ fun ResultRow.toRegisteredClient(): SpringRegisteredClient {
.scopes { it.addAll(clientScopes) }
.clientSettings(ClientSettings.withSettings(JsonUtil.jsonToMap(this[clientSettings])).build())
val tokenSettingsMap = JsonUtil.jsonToMap<String, Any>(this[tokenSettings])
val withSettings = TokenSettings.withSettings(tokenSettingsMap)
if (tokenSettingsMap.containsKey(ConfigurationSettingNames.Token.ACCESS_TOKEN_FORMAT)) {
@@ -10,7 +10,6 @@ import io.ktor.http.*
import org.koin.core.annotation.Single
import org.springframework.stereotype.Service
@Service
interface APCreateService {
suspend fun receiveCreate(create: Create): ActivityPubResponse
@@ -11,7 +11,6 @@ import io.ktor.http.*
import org.koin.core.annotation.Single
import org.springframework.stereotype.Service
@Service
interface APUndoService {
suspend fun receiveUndo(undo: Undo): ActivityPubResponse
@@ -105,7 +105,6 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
it[deviceCodeMetadata] = deviceCode?.metadata?.let { it1 -> JsonUtil.mapToJson(it1) }
}
}
}
override fun remove(authorization: OAuth2Authorization?) {
@@ -176,7 +175,6 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
}
fun ResultRow.toAuthorization(): OAuth2Authorization {
val registeredClientId = this[Authorization.registeredClientId]
val registeredClient = registeredClientRepository.findById(registeredClientId)
@@ -186,7 +184,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
val principalName = this[Authorization.principalName]
val authorizationGrantType = this[Authorization.authorizationGrantType]
val authorizedScopes = this[Authorization.authorizedScopes]?.split(",").orEmpty().toSet()
val attributes = this[Authorization.attributes]?.let { JsonUtil.jsonToMap<String, Any>(it) } ?: emptyMap()
val attributes = this[Authorization.attributes]?.let { JsonUtil.jsonToMap<String, Any>(it) }.orEmpty()
builder.id(id).principalName(principalName)
.authorizationGrantType(AuthorizationGrantType(authorizationGrantType)).authorizedScopes(authorizedScopes)
@@ -218,7 +216,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
val accessTokenIssuedAt = this[Authorization.accessTokenIssuedAt]
val accessTokenExpiresAt = this[Authorization.accessTokenExpiresAt]
val accessTokenMetadata =
this[Authorization.accessTokenMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) } ?: emptyMap()
this[Authorization.accessTokenMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) }.orEmpty()
val accessTokenType =
if (this[Authorization.accessTokenType].equals(OAuth2AccessToken.TokenType.BEARER.value, true)) {
OAuth2AccessToken.TokenType.BEARER
@@ -229,7 +227,11 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
val accessTokenScope = this[Authorization.accessTokenScopes]?.split(",").orEmpty().toSet()
val oAuth2AccessToken = OAuth2AccessToken(
accessTokenType, accessTokenValue, accessTokenIssuedAt, accessTokenExpiresAt, accessTokenScope
accessTokenType,
accessTokenValue,
accessTokenIssuedAt,
accessTokenExpiresAt,
accessTokenScope
)
builder.token(oAuth2AccessToken) { it.putAll(accessTokenMetadata) }
@@ -240,7 +242,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
val oidcTokenIssuedAt = this[Authorization.oidcIdTokenIssuedAt]
val oidcTokenExpiresAt = this[Authorization.oidcIdTokenExpiresAt]
val oidcTokenMetadata =
this[Authorization.oidcIdTokenMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) } ?: emptyMap()
this[Authorization.oidcIdTokenMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) }.or
val oidcIdToken = OidcIdToken(
oidcIdTokenValue,
@@ -19,7 +19,9 @@ class UserDetailsServiceImpl(private val userQueryService: UserQueryService, pri
transaction.transaction {
val findById = userQueryService.findByNameAndDomain(username, "")
User(
findById.name, findById.password, listOf()
findById.name,
findById.password,
listOf()
)
}
}
@@ -4,14 +4,12 @@ import org.springframework.security.authentication.AuthenticationManager
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
import org.springframework.security.web.util.matcher.AntPathRequestMatcher
class UsernamePasswordAuthFilter(jwtService: JwtService, authenticationManager: AuthenticationManager?) :
UsernamePasswordAuthenticationFilter(authenticationManager) {
init {
setRequiresAuthenticationRequestMatcher(AntPathRequestMatcher("/api/internal/v1/login", "POST"))
this.setAuthenticationSuccessHandler { request, response, authentication ->
}
}
}
@@ -12,5 +12,4 @@ object JsonUtil {
fun <K, V> jsonToMap(json: String, objectMapper: ObjectMapper = this.objectMapper): Map<K, V> =
objectMapper.readValue(json)
}