diff --git a/src/main/kotlin/ltd/hlaeja/controller/HomeController.kt b/src/main/kotlin/ltd/hlaeja/controller/HomeController.kt index b565861..3e8a64e 100644 --- a/src/main/kotlin/ltd/hlaeja/controller/HomeController.kt +++ b/src/main/kotlin/ltd/hlaeja/controller/HomeController.kt @@ -1,6 +1,6 @@ package ltd.hlaeja.controller -import ltd.hlaeja.security.RemoteUserDetail +import ltd.hlaeja.security.user.RemoteUserDetail import org.springframework.security.core.context.ReactiveSecurityContextHolder import org.springframework.stereotype.Controller import org.springframework.ui.Model diff --git a/src/main/kotlin/ltd/hlaeja/controller/advice/ErrorAttributes.kt b/src/main/kotlin/ltd/hlaeja/controller/advice/ErrorAttributes.kt index 769f3aa..a6ad3f1 100644 --- a/src/main/kotlin/ltd/hlaeja/controller/advice/ErrorAttributes.kt +++ b/src/main/kotlin/ltd/hlaeja/controller/advice/ErrorAttributes.kt @@ -1,7 +1,7 @@ package ltd.hlaeja.controller.advice import kotlinx.coroutines.runBlocking -import ltd.hlaeja.security.RemoteAuthentication +import ltd.hlaeja.security.user.RemoteAuthentication import ltd.hlaeja.security.user.GuestUser import org.springframework.boot.web.error.ErrorAttributeOptions import org.springframework.boot.web.reactive.error.DefaultErrorAttributes diff --git a/src/main/kotlin/ltd/hlaeja/controller/advice/UserAttribute.kt b/src/main/kotlin/ltd/hlaeja/controller/advice/UserAttribute.kt index 7ef6401..1df717d 100644 --- a/src/main/kotlin/ltd/hlaeja/controller/advice/UserAttribute.kt +++ b/src/main/kotlin/ltd/hlaeja/controller/advice/UserAttribute.kt @@ -1,7 +1,7 @@ package ltd.hlaeja.controller.advice import kotlinx.coroutines.reactive.awaitFirstOrNull -import ltd.hlaeja.security.RemoteAuthentication +import ltd.hlaeja.security.user.RemoteAuthentication import ltd.hlaeja.security.user.GuestUser import org.springframework.security.core.context.ReactiveSecurityContextHolder import org.springframework.ui.Model diff --git a/src/main/kotlin/ltd/hlaeja/security/RemoteReactiveAuthenticationManager.kt b/src/main/kotlin/ltd/hlaeja/security/manager/RemoteAuthenticationManager.kt similarity index 89% rename from src/main/kotlin/ltd/hlaeja/security/RemoteReactiveAuthenticationManager.kt rename to src/main/kotlin/ltd/hlaeja/security/manager/RemoteAuthenticationManager.kt index d4d08b3..67512d9 100644 --- a/src/main/kotlin/ltd/hlaeja/security/RemoteReactiveAuthenticationManager.kt +++ b/src/main/kotlin/ltd/hlaeja/security/manager/RemoteAuthenticationManager.kt @@ -1,4 +1,4 @@ -package ltd.hlaeja.security +package ltd.hlaeja.security.manager import io.github.oshai.kotlinlogging.KotlinLogging import io.jsonwebtoken.Claims @@ -6,7 +6,8 @@ import io.jsonwebtoken.Jws import io.jsonwebtoken.JwtException import java.util.UUID import ltd.hlaeja.jwt.service.PublicJwtService -import ltd.hlaeja.library.accountRegistry.Authentication.Response +import ltd.hlaeja.security.user.RemoteAuthentication +import ltd.hlaeja.security.user.RemoteUserDetail import ltd.hlaeja.service.AccountRegistryService import ltd.hlaeja.util.toAuthenticationRequest import org.springframework.security.authentication.AuthenticationServiceException @@ -19,7 +20,7 @@ import reactor.core.publisher.Mono private val log = KotlinLogging.logger {} @Component -class RemoteReactiveAuthenticationManager( +class RemoteAuthenticationManager( private val accountRegistryService: AccountRegistryService, private val publicJwtService: PublicJwtService, ) : ReactiveAuthenticationManager { @@ -30,7 +31,7 @@ class RemoteReactiveAuthenticationManager( .map(::processToken) private fun processToken( - response: Response, + response: ltd.hlaeja.library.accountRegistry.Authentication.Response, ): Authentication = try { publicJwtService.verify(response.token) { claims -> makeRemoteAuthentication(claims) } } catch (e: JwtException) { diff --git a/src/main/kotlin/ltd/hlaeja/security/user/GuestUser.kt b/src/main/kotlin/ltd/hlaeja/security/user/GuestUser.kt index c84e103..921a6ab 100644 --- a/src/main/kotlin/ltd/hlaeja/security/user/GuestUser.kt +++ b/src/main/kotlin/ltd/hlaeja/security/user/GuestUser.kt @@ -1,8 +1,6 @@ package ltd.hlaeja.security.user import java.util.UUID -import ltd.hlaeja.security.RemoteAuthentication -import ltd.hlaeja.security.RemoteUserDetail interface GuestUser { diff --git a/src/main/kotlin/ltd/hlaeja/security/RemoteAuthentication.kt b/src/main/kotlin/ltd/hlaeja/security/user/RemoteAuthentication.kt similarity index 94% rename from src/main/kotlin/ltd/hlaeja/security/RemoteAuthentication.kt rename to src/main/kotlin/ltd/hlaeja/security/user/RemoteAuthentication.kt index a4af478..72cc2eb 100644 --- a/src/main/kotlin/ltd/hlaeja/security/RemoteAuthentication.kt +++ b/src/main/kotlin/ltd/hlaeja/security/user/RemoteAuthentication.kt @@ -1,4 +1,4 @@ -package ltd.hlaeja.security +package ltd.hlaeja.security.user import org.springframework.security.core.Authentication import org.springframework.security.core.GrantedAuthority @@ -25,6 +25,7 @@ data class RemoteAuthentication( authenticated = isAuthenticated } + @Suppress("unused") fun hasRole(role: String): Boolean { authorities.forEach { if (it.authority.equals("role_$role", true)) { diff --git a/src/main/kotlin/ltd/hlaeja/security/RemoteUserDetail.kt b/src/main/kotlin/ltd/hlaeja/security/user/RemoteUserDetail.kt similarity index 88% rename from src/main/kotlin/ltd/hlaeja/security/RemoteUserDetail.kt rename to src/main/kotlin/ltd/hlaeja/security/user/RemoteUserDetail.kt index bc6d35c..70750d2 100644 --- a/src/main/kotlin/ltd/hlaeja/security/RemoteUserDetail.kt +++ b/src/main/kotlin/ltd/hlaeja/security/user/RemoteUserDetail.kt @@ -1,4 +1,4 @@ -package ltd.hlaeja.security +package ltd.hlaeja.security.user import java.io.Serializable import java.util.UUID