All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.touk.nussknacker.ui.security.api.AuthenticatedUser.scala Maven / Gradle / Ivy

package pl.touk.nussknacker.ui.security.api

final case class AuthenticatedUser(
    id: String,
    username: String,
    roles: Set[String],
    impersonatedAuthenticationUser: Option[AuthenticatedUser] = None
)

object AuthenticatedUser {
  def createAnonymousUser(roles: Set[String]): AuthenticatedUser =
    AuthenticatedUser("anonymous", "anonymous", roles)

  def createImpersonatedUser(
      impersonatingUser: AuthenticatedUser,
      impersonatedUserData: ImpersonatedUserData
  ): AuthenticatedUser =
    AuthenticatedUser(
      impersonatingUser.id,
      impersonatingUser.username,
      impersonatingUser.roles,
      Some(AuthenticatedUser(impersonatedUserData))
    )

  def apply(userData: ImpersonatedUserData): AuthenticatedUser =
    AuthenticatedUser(userData.id, userData.username, userData.roles)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy