AllowAllPolicy

mbauer83.zio_http_authorization.AuthorizationPolicy$.AllowAllPolicy
See theAllowAllPolicy companion object
class AllowAllPolicy[U <: User[_, _], R <: Resource[_]] extends AuthorizationPolicy[U, R]

An AuthorizationPolicy that always authorizes access to a resource.

Attributes

Example

Create via companion object as in the following example

package mbauer83.zio_http_authorization
import zio.{ZIO, Console, ZIOAppDefault}
object AllPassAuthExample extends ZIOAppDefault:
 type ResourceType <: Resource[_]
 type UserType <: User
 def getUser: ZIO[Any, Nothing, UserType] = ???
 def getResource: ZIO[Any, Nothing, ResourceType] = ???
 override val run = for {
   user <- getUser
   resource <- getResource
   policy = AllowAllPolicy[UserType, ResourceType]
   authorizedResource <- policy.authorized(user)(resource)
   _ <-  Console.printLine(authorizedResource)
 } yield ()
Companion
object
Graph
Supertypes
trait AuthorizationPolicy[U, R]
class Object
trait Matchable
class Any

Members list

Type members

Inherited types

type ResourceType = R

Attributes

Inherited from:
AuthorizationPolicy
type UserType = U

Attributes

Inherited from:
AuthorizationPolicy

Value members

Concrete methods

def authorized[Res <: R | Iterable[R]](user: U)(resource: Res): ZIO[Any, UserNotAuthorizedForResourceException[_], Res]

An effect which either fails with a UserNotAuthorizedForResourceException or succeeds with the resource if the user is authorized to access the resource.

An effect which either fails with a UserNotAuthorizedForResourceException or succeeds with the resource if the user is authorized to access the resource.

If the resource is an scala.collection.Iterable, the effect must fail if and only if the user is not authorized to access any of the resources in the collection. Otherwise, it must succeed with a filtered version of the resource.

Attributes