-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.saveourtool.save.authservice.security | ||
|
||
import com.saveourtool.save.authservice.utils.AuthenticationDetails | ||
import com.saveourtool.save.utils.AUTHORIZATION_SOURCE | ||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken | ||
import org.springframework.security.core.Authentication | ||
import org.springframework.security.web.server.authentication.ServerAuthenticationConverter | ||
import org.springframework.security.web.server.authentication.ServerHttpBasicAuthenticationConverter | ||
import org.springframework.stereotype.Component | ||
import org.springframework.web.server.ServerWebExchange | ||
import reactor.core.publisher.Mono | ||
|
||
/** | ||
* Implementation of [ServerAuthenticationConverter] that embeds user identity source into [UsernamePasswordAuthenticationToken] | ||
*/ | ||
@Component | ||
class CustomAuthenticationBasicConverter : ServerHttpBasicAuthenticationConverter(), | ||
ServerAuthenticationConverter { | ||
Check failure Code scanning / ktlint [WRONG_INDENTATION] only spaces are allowed for indentation and each indentation should equal to 4 spaces (tabs are not allowed): expected 0 but was 4 Error
[WRONG_INDENTATION] only spaces are allowed for indentation and each indentation should equal to 4 spaces (tabs are not allowed): expected 0 but was 4
|
||
/** | ||
* Convert exchange, received from gateway into UsernamePasswordAuthenticationToken, specify source identity, laid | ||
* by gateway into X-Authorization-Source header | ||
*/ | ||
@Suppress("TOO_MANY_LINES_IN_LAMBDA") | ||
override fun convert(exchange: ServerWebExchange): Mono<Authentication> = super.convert(exchange).map { authentication -> | ||
val name = (authentication as UsernamePasswordAuthenticationToken).principal as String | ||
UsernamePasswordAuthenticationToken( | ||
name, | ||
authentication.credentials as String | ||
).apply { | ||
details = AuthenticationDetails( | ||
id = -1L, | ||
) | ||
} | ||
} | ||
} | ||
Check failure Code scanning / ktlint [WRONG_INDENTATION] only spaces are allowed for indentation and each indentation should equal to 4 spaces (tabs are not allowed): no newline at the end of file CustomAuthenticationBasicConverter.kt Error
[WRONG_INDENTATION] only spaces are allowed for indentation and each indentation should equal to 4 spaces (tabs are not allowed): no newline at the end of file CustomAuthenticationBasicConverter.kt
Check warning Code scanning / detekt Checks whether files end with a line separator. Warning
The file /home/runner/work/save-cloud/save-cloud/authentication-service/src/main/kotlin/com/saveourtool/save/authservice/security/CustomAuthenticationBasicConverter.kt is not ending with a new line.
Check warning Code scanning / detekt Checks whether files end with a line separator. Warning
The file /home/runner/work/save-cloud/save-cloud/authentication-service/src/main/kotlin/com/saveourtool/save/authservice/security/CustomAuthenticationBasicConverter.kt is not ending with a new line.
|