AuthorizationPolicy
mbauer83.zio_http_authorization.AuthorizationPolicy$.AuthorizationPolicy
Defines a policy for authorizing a specific type U
of User.User to access a specific type R
of Resource.Resource.
Reflection using scala.reflect.ClassTag is used so that the policy can be registered with an EndpointPolicyProvider.EndpointPolicyProvider.
Attributes
- Example
-
Example usage
package mbauer83.zio_http_authorization import zio.{ZIO, Console, ZIOAppDefault} object PolicyAuthorizationExample extends ZIOAppDefault: type ResourceType <: Resource[_] type UserType <: User[_, _] def getUser: ZIO[Any, Nothing, UserType] = ??? def getResource: ZIO[Any, Nothing, ResourceType] = ??? def getPolicy: ZIO[Any, Nothing, AuthorizationPolicy[UserType, ResourceType]] = ??? override val run = for { user <- getUser resource <- getResource policy <- getPolicy authorizedResource <- policy.authorized(user)(resource) _ <- Console.printLine(authorizedResource) } yield ()
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
Members list
In this article