mbauer83.zio_http_authorization

A simple library for role-based and permission-based access-control with ZIO-http. Provides the means to declare and manage Resources, Permissions, Roles, Users and AuthorizationPolicies.

These policies can then be registered with an EndpointPolicyProvider as partial functions from Request to AuthorizationPolicy.

The EndpointPolicyProvider (e.g. DefaultEndpointPolicyProvider) can then be used to get a matching policy for a given Request.

Attributes

Members list

Type members

Classlikes

AuthorizationPolicies hold information about the type of User and Resource they authorize, and define an effect to authorize a user of the specified type to access a resource of the specified type.

AuthorizationPolicies hold information about the type of User and Resource they authorize, and define an effect to authorize a user of the specified type to access a resource of the specified type.

Out of the box, this library provides a policy which always denies access, a policy which always grants access, and a policy which grants access if the user has the SUPER Role, or if the resource's tenant-id matches the user's tenant-id, or if the resource has no tenant-id.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

An EndpointPolicyProvider is used to retrieve a matching * AuthorizationPolicy for a given Request from a set of policies, each registered with a partial function from Request to the policy.

An EndpointPolicyProvider is used to retrieve a matching * AuthorizationPolicy for a given Request from a set of policies, each registered with a partial function from Request to the policy.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Permission

Permissions define specific (kinds of) actions that may be performed on a Resource by a User to which the permission is assigned together with a ResourceSelector.

Permissions define specific (kinds of) actions that may be performed on a Resource by a User to which the permission is assigned together with a ResourceSelector.

Permissions contain a name which may be of type String or Symbol.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Permission.type
object Resource

Resources are the objects to which access is restricted via AuthorizationPolicies. They are identified by a ResourceDescriptor which is generic in its type of ResourceId and TenantId.

Resources are the objects to which access is restricted via AuthorizationPolicies. They are identified by a ResourceDescriptor which is generic in its type of ResourceId and TenantId.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Resource.type
object Role

Roles are the basic units of role-based authorization. They are tags which can be associated in a many-to-many fashion with Users. AuthorizationPolicies can then check if a given User is authorized to to access or perform a specific kind of action on a given Resource based on data from the resource and from the user, including Roles and Permissions.

Roles are the basic units of role-based authorization. They are tags which can be associated in a many-to-many fashion with Users. AuthorizationPolicies can then check if a given User is authorized to to access or perform a specific kind of action on a given Resource based on data from the resource and from the user, including Roles and Permissions.

This library defined three common default roles: SUPER, ADMIN, and USER.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Role.type
object User

Users are the basic subject of role-based authorization. They are generic in their type of UserId and tenant id.

Users are the basic subject of role-based authorization. They are generic in their type of UserId and tenant id.

Aside from their identity, users contain their assigned Roles and Permissions which can be checked by AuthorizationPolicies.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
User.type