Skip to content

Instantly share code, notes, and snippets.

@bandrzejczak
Created February 9, 2018 22:55
Show Gist options
  • Save bandrzejczak/1ffb9c3c1e5234e10e3c6bc622db7470 to your computer and use it in GitHub Desktop.
Save bandrzejczak/1ffb9c3c1e5234e10e3c6bc622db7470 to your computer and use it in GitHub Desktop.
private def impersonateUser(token: String, userId: String): Future[Seq[(String, String)]] = {
sttp
.post(uri"${config.authServerUrl}/admin/realms/${config.realm}/users/$userId/impersonation")
.auth.bearer(token)
.send()
.map { r =>
val currentTime = ZonedDateTime.now()
r.cookies
.filter(_.expires.forall(_.isAfter(currentTime)))
.map(cookie => (cookie.name, cookie.value))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment