Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
usbharu 2023-10-20 12:01:47 +09:00 committed by GitHub
parent 888b650e23
commit 7b65458b2f
4 changed files with 6 additions and 10 deletions

View File

@ -84,7 +84,6 @@ class SecurityConfig {
return http.build()
}
@Bean
fun getHttpSignatureFilter(authenticationManager: AuthenticationManager): HttpSignatureFilter {
val httpSignatureFilter = HttpSignatureFilter(DefaultSignatureHeaderParser())
@ -97,14 +96,17 @@ class SecurityConfig {
val provider = PreAuthenticatedAuthenticationProvider()
provider.setPreAuthenticatedUserDetailsService(
HttpSignatureUserDetailsService(
userQueryService, HttpSignatureVerifierComposite(
userQueryService,
HttpSignatureVerifierComposite(
mapOf(
"rsa-sha256" to RsaSha256HttpSignatureVerifier(
DefaultSignatureHeaderParser(),
RsaSha256HttpSignatureSigner()
)
), DefaultSignatureHeaderParser()
), transaction
),
DefaultSignatureHeaderParser()
),
transaction
)
)
provider.setUserDetailsChecker(AccountStatusUserDetailsChecker())

View File

@ -11,13 +11,11 @@ import java.net.URL
class HttpSignatureFilter(private val httpSignatureHeaderParser: SignatureHeaderParser) :
AbstractPreAuthenticatedProcessingFilter() {
override fun getPreAuthenticatedPrincipal(request: HttpServletRequest?): Any {
val headersList = request?.headerNames?.toList().orEmpty()
val headers =
headersList.associateWith { header -> request?.getHeaders(header)?.toList().orEmpty() }
val signature = httpSignatureHeaderParser.parse(HttpHeaders(headers))
return signature.keyId
}
@ -45,5 +43,4 @@ class HttpSignatureFilter(private val httpSignatureHeaderParser: SignatureHeader
method
)
}
}

View File

@ -23,5 +23,4 @@ class HttpSignatureUser(
@Serial
private const val serialVersionUID: Long = -3330552099960982997L
}
}

View File

@ -23,8 +23,6 @@ class HttpSignatureUserDetailsService(
AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> {
override fun loadUserDetails(token: PreAuthenticatedAuthenticationToken): UserDetails = runBlocking {
transaction.transaction {
if (token.principal !is String) {
throw IllegalStateException("Token is not String")
}