mirror of https://github.com/usbharu/Hideout.git
style: スタイルを修正
This commit is contained in:
parent
8ab55cb248
commit
ec1285e6fb
|
@ -14,7 +14,11 @@ class ExposedOAuth2AuthorizationConsentService(private val registeredClientRepos
|
||||||
override fun save(authorizationConsent: AuthorizationConsent?) {
|
override fun save(authorizationConsent: AuthorizationConsent?) {
|
||||||
requireNotNull(authorizationConsent)
|
requireNotNull(authorizationConsent)
|
||||||
val singleOrNull =
|
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()
|
.singleOrNull()
|
||||||
if (singleOrNull == null) {
|
if (singleOrNull == null) {
|
||||||
OAuth2AuthorizationConsent.insert {
|
OAuth2AuthorizationConsent.insert {
|
||||||
|
@ -38,13 +42,16 @@ class ExposedOAuth2AuthorizationConsentService(private val registeredClientRepos
|
||||||
requireNotNull(registeredClientId)
|
requireNotNull(registeredClientId)
|
||||||
requireNotNull(principalName)
|
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()
|
.singleOrNull()?.toAuthorizationConsent()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ResultRow.toAuthorizationConsent(): AuthorizationConsent {
|
fun ResultRow.toAuthorizationConsent(): AuthorizationConsent {
|
||||||
val registeredClientId = this[OAuth2AuthorizationConsent.registeredClientId]
|
val registeredClientId = this[OAuth2AuthorizationConsent.registeredClientId]
|
||||||
val registeredClient = registeredClientRepository.findById(registeredClientId)
|
registeredClientRepository.findById(registeredClientId)
|
||||||
|
|
||||||
val principalName = this[OAuth2AuthorizationConsent.principalName]
|
val principalName = this[OAuth2AuthorizationConsent.principalName]
|
||||||
val builder = AuthorizationConsent.withId(registeredClientId, principalName)
|
val builder = AuthorizationConsent.withId(registeredClientId, principalName)
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
|
||||||
it[accessTokenExpiresAt] = accessToken?.token?.expiresAt
|
it[accessTokenExpiresAt] = accessToken?.token?.expiresAt
|
||||||
it[accessTokenMetadata] = accessToken?.metadata?.let { it1 -> JsonUtil.mapToJson(it1) }
|
it[accessTokenMetadata] = accessToken?.metadata?.let { it1 -> JsonUtil.mapToJson(it1) }
|
||||||
it[accessTokenType] = accessToken?.token?.tokenType?.value
|
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[refreshTokenValue] = refreshToken?.token?.tokenValue
|
||||||
it[refreshTokenIssuedAt] = refreshToken?.token?.issuedAt
|
it[refreshTokenIssuedAt] = refreshToken?.token?.issuedAt
|
||||||
it[refreshTokenExpiresAt] = refreshToken?.token?.expiresAt
|
it[refreshTokenExpiresAt] = refreshToken?.token?.expiresAt
|
||||||
|
@ -203,7 +203,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
|
||||||
JsonUtil.jsonToMap<String, Any>(
|
JsonUtil.jsonToMap<String, Any>(
|
||||||
it
|
it
|
||||||
)
|
)
|
||||||
} ?: emptyMap()
|
}.orEmpty()
|
||||||
val oAuth2AuthorizationCode =
|
val oAuth2AuthorizationCode =
|
||||||
OAuth2AuthorizationCode(authorizationCodeValue, authorizationCodeIssuedAt, authorizationCodeExpiresAt)
|
OAuth2AuthorizationCode(authorizationCodeValue, authorizationCodeIssuedAt, authorizationCodeExpiresAt)
|
||||||
builder.token(oAuth2AuthorizationCode) {
|
builder.token(oAuth2AuthorizationCode) {
|
||||||
|
@ -242,7 +242,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
|
||||||
val oidcTokenIssuedAt = this[Authorization.oidcIdTokenIssuedAt]
|
val oidcTokenIssuedAt = this[Authorization.oidcIdTokenIssuedAt]
|
||||||
val oidcTokenExpiresAt = this[Authorization.oidcIdTokenExpiresAt]
|
val oidcTokenExpiresAt = this[Authorization.oidcIdTokenExpiresAt]
|
||||||
val oidcTokenMetadata =
|
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(
|
val oidcIdToken = OidcIdToken(
|
||||||
oidcIdTokenValue,
|
oidcIdTokenValue,
|
||||||
|
@ -259,7 +259,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
|
||||||
val refreshTokenIssuedAt = this[Authorization.refreshTokenIssuedAt]
|
val refreshTokenIssuedAt = this[Authorization.refreshTokenIssuedAt]
|
||||||
val refreshTokenExpiresAt = this[Authorization.refreshTokenExpiresAt]
|
val refreshTokenExpiresAt = this[Authorization.refreshTokenExpiresAt]
|
||||||
val refreshTokenMetadata =
|
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)
|
val oAuth2RefreshToken = OAuth2RefreshToken(refreshTokenValue, refreshTokenIssuedAt, refreshTokenExpiresAt)
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
|
||||||
val userCodeIssuedAt = this[Authorization.userCodeIssuedAt]
|
val userCodeIssuedAt = this[Authorization.userCodeIssuedAt]
|
||||||
val userCodeExpiresAt = this[Authorization.userCodeExpiresAt]
|
val userCodeExpiresAt = this[Authorization.userCodeExpiresAt]
|
||||||
val userCodeMetadata =
|
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)
|
val oAuth2UserCode = OAuth2UserCode(userCodeValue, userCodeIssuedAt, userCodeExpiresAt)
|
||||||
builder.token(oAuth2UserCode) { it.putAll(userCodeMetadata) }
|
builder.token(oAuth2UserCode) { it.putAll(userCodeMetadata) }
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ class ExposedOAuth2AuthorizationService(private val registeredClientRepository:
|
||||||
val deviceCodeIssuedAt = this[Authorization.deviceCodeIssuedAt]
|
val deviceCodeIssuedAt = this[Authorization.deviceCodeIssuedAt]
|
||||||
val deviceCodeExpiresAt = this[Authorization.deviceCodeExpiresAt]
|
val deviceCodeExpiresAt = this[Authorization.deviceCodeExpiresAt]
|
||||||
val deviceCodeMetadata =
|
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)
|
val oAuth2DeviceCode = OAuth2DeviceCode(deviceCodeValue, deviceCodeIssuedAt, deviceCodeExpiresAt)
|
||||||
builder.token(oAuth2DeviceCode) { it.putAll(deviceCodeMetadata) }
|
builder.token(oAuth2DeviceCode) { it.putAll(deviceCodeMetadata) }
|
||||||
|
|
|
@ -21,7 +21,7 @@ class UserDetailsServiceImpl(private val userQueryService: UserQueryService, pri
|
||||||
User(
|
User(
|
||||||
findById.name,
|
findById.name,
|
||||||
findById.password,
|
findById.password,
|
||||||
listOf()
|
emptyList()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 ->
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue