diff options
3 files changed, 7 insertions, 7 deletions
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt index b485e17d..e96744a9 100644 --- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt +++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt @@ -37,18 +37,18 @@ class SecurityException(message: String) : Exception(message) data class Credentials(val username: String? = null, val password: String? = null) /** - * Pac4j form login dispatcher. + * Form login dispatcher. */ -class LoginService { +class LoginService(val loginEndpoint: String) { val loginAgent = CallAgent() /** - * Login with Pac4j FormClient. + * Login with a form. * @param credentials username and password credentials */ suspend fun login(credentials: Credentials?): Boolean = if (credentials?.username != null) { - loginAgent.remoteCall("callback?client_name=FormClient", obj { + loginAgent.remoteCall(loginEndpoint, obj { this.username = credentials.username this.password = credentials.password }, HttpMethod.POST, "application/x-www-form-urlencoded").then { _: dynamic -> true }.asDeferred().await() @@ -58,7 +58,7 @@ class LoginService { } /** - * Pac4j form login dispatcher. + * Form login dispatcher. */ abstract class SecurityMgr { diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt index 98f8bdb3..ee5c59fc 100644 --- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt +++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt @@ -32,7 +32,7 @@ actual typealias Profile = CommonProfile /** * A helper extension function for processing with authenticated user profile. */ -fun <RESP> Request.withProfile(block: (Profile) -> RESP): RESP { +suspend fun <RESP> Request.withProfile(block: suspend (Profile) -> RESP): RESP { val profile = this.require(CommonProfile::class.java) as CommonProfile? return profile?.let { block(profile) diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt index 02c0fe27..18164800 100644 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt +++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/Profile.kt @@ -37,7 +37,7 @@ actual typealias Profile = CommonProfile * A helper extension function for processing with authenticated user profile. */ @Suppress("TooGenericExceptionCaught") -fun <RESP> withProfile(block: (Profile) -> RESP): RESP { +suspend fun <RESP> withProfile(block: suspend (Profile) -> RESP): RESP { val profile = try { val requestAttributes = (RequestContextHolder.getRequestAttributes() as ServletRequestAttributes) val req = requestAttributes.request |