User

mbauer83.zio_http_authorization.User$.User
See theUser companion object
trait User[I <: UserId, T <: TenantId] extends Product, Serializable

A user in the bounded context of role-based authorization.

tenantId is optional since superusers will not belong to any tenant. User-models for single-tenant systems can use Nothing as the type for the tenantId.

Attributes

Example

Example usage without tenantId

 case class ExampleUser(id: String, roles: Set[Role], permissions: Set[(Permission, ResourceSelector[_, _])], otherData: String) extends User[String, Nothing]:
   val tenantId: Option[Nothing] = None

Example usage with UUID for id and tenantId

 case class ExampleUser(
   id: UUID,
   tenantId: Option[UUID],
   roles: Set[Role],
   permissions: Set[(Permission, ResourceSelector[_, _])],
   otherData: String
 ) extends User[UUID, UUID]
Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class GenericUser[I, T]

Members list

Value members

Concrete methods

def hasPermissionForResource(permission: String | Symbol)(resource: Resource[_]): Boolean

Returns true if and only if the user has the permission with an associated ResourceSelector that matches the given resource.

Returns true if and only if the user has the permission with an associated ResourceSelector that matches the given resource.

Attributes

def hasRole(role: Role): Boolean

Returns true if and only if the role is associated with the user.

Returns true if and only if the role is associated with the user.

Attributes

Inherited methods

def canEqual(that: Any): Boolean

Attributes

Inherited from:
Equals

Attributes

Inherited from:
Product
def productElement(n: Int): Any

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Abstract fields

val id: I
val roles: Set[Role]
val tenantId: Option[T]