style: スタイルを修正

This commit is contained in:
usbharu 2023-09-19 16:27:45 +09:00
parent 8ab55cb248
commit ec1285e6fb
4 changed files with 17 additions and 25 deletions

View File

@ -14,7 +14,11 @@ class ExposedOAuth2AuthorizationConsentService(private val registeredClientRepos
override fun save(authorizationConsent: AuthorizationConsent?) {
requireNotNull(authorizationConsent)
val singleOrNull =
OAuth2AuthorizationConsent.select { OAuth2AuthorizationConsent.registeredClientId eq authorizationConsent.registeredClientId and (OAuth2AuthorizationConsent.principalName eq authorizationConsent.principalName) }
OAuth2AuthorizationConsent.select {
OAuth2AuthorizationConsent.registeredClientId
.eq(authorizationConsent.registeredClientId)
.and(OAuth2AuthorizationConsent.principalName.eq(authorizationConsent.principalName))
}
.singleOrNull()
if (singleOrNull == null) {
OAuth2AuthorizationConsent.insert {
@ -38,13 +42,16 @@ class ExposedOAuth2AuthorizationConsentService(private val registeredClientRepos
requireNotNull(registeredClientId)
requireNotNull(principalName)
return OAuth2AuthorizationConsent.select { OAuth2AuthorizationConsent.registeredClientId eq registeredClientId and (OAuth2AuthorizationConsent.principalName eq principalName) }
return OAuth2AuthorizationConsent.select {
(OAuth2AuthorizationConsent.registeredClientId eq registeredClientId)
.and(OAuth2AuthorizationConsent.principalName eq principalName)
}
.singleOrNull()?.toAuthorizationConsent()
}
fun ResultRow.toAuthorizationConsent(): AuthorizationConsent {
val registeredClientId = this[OAuth2AuthorizationConsent.registeredClientId]
val registeredClient = registeredClientRepository.findById(registeredClientId)
registeredClientRepository.findById(registeredClientId)
val principalName = this[OAuth2AuthorizationConsent.principalName]
val builder = AuthorizationConsent.withId(registeredClientId, principalName)

View File

@ -45,7 +45,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
it[accessTokenExpiresAt] = accessToken?.token?.expiresAt
it[accessTokenMetadata] = accessToken?.metadata?.let { it1 -> JsonUtil.mapToJson(it1) }
it[accessTokenType] = accessToken?.token?.tokenType?.value
it[accessTokenScopes] = accessToken?.token?.scopes?.joinToString(",")?.takeIf { it.isEmpty() }
it[accessTokenScopes] = accessToken?.run { token.scopes.joinToString(",").takeIf { it.isEmpty() } }
it[refreshTokenValue] = refreshToken?.token?.tokenValue
it[refreshTokenIssuedAt] = refreshToken?.token?.issuedAt
it[refreshTokenExpiresAt] = refreshToken?.token?.expiresAt
@ -203,7 +203,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
JsonUtil.jsonToMap<String, Any>(
it
)
} ?: emptyMap()
}.orEmpty()
val oAuth2AuthorizationCode =
OAuth2AuthorizationCode(authorizationCodeValue, authorizationCodeIssuedAt, authorizationCodeExpiresAt)
builder.token(oAuth2AuthorizationCode) {
@ -242,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) }.or
this[Authorization.oidcIdTokenMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) }.orEmpty()
val oidcIdToken = OidcIdToken(
oidcIdTokenValue,
@ -259,7 +259,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
val refreshTokenIssuedAt = this[Authorization.refreshTokenIssuedAt]
val refreshTokenExpiresAt = this[Authorization.refreshTokenExpiresAt]
val refreshTokenMetadata =
this[Authorization.refreshTokenMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) } ?: emptyMap()
this[Authorization.refreshTokenMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) }.orEmpty()
val oAuth2RefreshToken = OAuth2RefreshToken(refreshTokenValue, refreshTokenIssuedAt, refreshTokenExpiresAt)
@ -271,7 +271,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
val userCodeIssuedAt = this[Authorization.userCodeIssuedAt]
val userCodeExpiresAt = this[Authorization.userCodeExpiresAt]
val userCodeMetadata =
this[Authorization.userCodeMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) } ?: emptyMap()
this[Authorization.userCodeMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) }.orEmpty()
val oAuth2UserCode = OAuth2UserCode(userCodeValue, userCodeIssuedAt, userCodeExpiresAt)
builder.token(oAuth2UserCode) { it.putAll(userCodeMetadata) }
}
@ -281,7 +281,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
val deviceCodeIssuedAt = this[Authorization.deviceCodeIssuedAt]
val deviceCodeExpiresAt = this[Authorization.deviceCodeExpiresAt]
val deviceCodeMetadata =
this[Authorization.deviceCodeMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) } ?: emptyMap()
this[Authorization.deviceCodeMetadata]?.let { JsonUtil.jsonToMap<String, Any>(it) }.orEmpty()
val oAuth2DeviceCode = OAuth2DeviceCode(deviceCodeValue, deviceCodeIssuedAt, deviceCodeExpiresAt)
builder.token(oAuth2DeviceCode) { it.putAll(deviceCodeMetadata) }

View File

@ -21,7 +21,7 @@ class UserDetailsServiceImpl(private val userQueryService: UserQueryService, pri
User(
findById.name,
findById.password,
listOf()
emptyList()
)
}
}

View File

@ -1,15 +0,0 @@
package dev.usbharu.hideout.service.auth
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 ->
}
}
}