Skip to content

Instantly share code, notes, and snippets.

@brunapereira
Last active January 11, 2020 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunapereira/bd798786e83cd70c93dc85b0ab83d591 to your computer and use it in GitHub Desktop.
Save brunapereira/bd798786e83cd70c93dc85b0ab83d591 to your computer and use it in GitHub Desktop.
@Component
class AuthenticationGateway(private val properties: AuthenticationProperties [1]) : MicroserviceGateway() [2] {
override var webClient: WebClient = ClientBuilder() [3]
.withBaseUrl(properties.baseUrl)
.withFailOnUnknownProperty(false)
.withNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
.build()
fun authenticate(): AuthenticationToken [4] {
val request =
AuthenticationRequestBody(
properties.username,
properties.password,
"password"
)
val headers = mapOf("Accept-Version" to "v1")
return post("/tokens", request, headers, AuthenticationToken::class) [5]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment