mirror of https://github.com/usbharu/Hideout.git
Apply suggestions from code review
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
888b650e23
commit
7b65458b2f
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,5 +23,4 @@ class HttpSignatureUser(
|
|||
@Serial
|
||||
private const val serialVersionUID: Long = -3330552099960982997L
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue