keycloak.uma_permissions
========================

.. py:module:: keycloak.uma_permissions

.. autoapi-nested-parse::

   User-managed access permissions module.



Classes
-------

.. autoapisummary::

   keycloak.uma_permissions.UMAPermission
   keycloak.uma_permissions.Resource
   keycloak.uma_permissions.Scope
   keycloak.uma_permissions.AuthStatus


Functions
---------

.. autoapisummary::

   keycloak.uma_permissions.build_permission_param


Module Contents
---------------

.. py:class:: UMAPermission(permission: UMAPermission | None = None, resource: str = '', scope: str = '')

   A class to conveniently assemble permissions.

   The class itself is callable, and will return the assembled permission.

   Usage example:

   >>> r = Resource("Users")
   >>> s = Scope("delete")
   >>> permission = r(s)
   >>> print(permission)
       'Users#delete'

   :param permission: Permission
   :type permission: UMAPermission
   :param resource: Resource
   :type resource: str
   :param scope: Scope
   :type scope: str


   .. py:attribute:: resource
      :value: ''



   .. py:attribute:: scope
      :value: ''



   .. py:method:: __str__() -> str

      Str method.

      :returns: String representation
      :rtype: str



   .. py:method:: __eq__(other: object) -> bool

      Eq method.

      :param __o: The other object
      :type __o: object
      :returns: Equality boolean
      :rtype: bool



   .. py:method:: __repr__() -> str

      Repr method.

      :returns: The object representation
      :rtype: str



   .. py:method:: __hash__() -> int

      Hash method.

      :returns: Hash of the object
      :rtype: int



   .. py:method:: __call__(permission: UMAPermission | None = None, resource: str = '', scope: str = '') -> UMAPermission

      Call method.

      :param permission: Permission
      :type permission: UMAPermission
      :param resource: Resource
      :type resource: str
      :param scope: Scope
      :type scope: str
      :returns: The combined UMA permission
      :rtype: UMAPermission
      :raises PermissionDefinitionError: In case bad permission definition



.. py:class:: Resource(resource: Resource)

   Bases: :py:obj:`UMAPermission`


   A UMAPermission Resource class to conveniently assemble permissions.

   The class itself is callable, and will return the assembled permission.

   :param resource: Resource
   :type resource: str


.. py:class:: Scope(scope: Scope)

   Bases: :py:obj:`UMAPermission`


   A UMAPermission Scope class to conveniently assemble permissions.

   The class itself is callable, and will return the assembled permission.

   :param scope: Scope
   :type scope: str


.. py:class:: AuthStatus(is_logged_in: bool, is_authorized: bool, missing_permissions: set)

   A class that represents the authorization/login status of a user associated with a token.

   This has to evaluate to True if and only if the user is properly authorized
   for the requested resource.

   :param is_logged_in: Is logged in indicator
   :type is_logged_in: bool
   :param is_authorized: Is authorized indicator
   :type is_authorized: bool
   :param missing_permissions: Missing permissions
   :type missing_permissions: set


   .. py:attribute:: is_logged_in


   .. py:attribute:: is_authorized


   .. py:attribute:: missing_permissions


   .. py:method:: __bool__() -> bool

      Bool method.

      :returns: Boolean representation
      :rtype: bool



   .. py:method:: __repr__() -> str

      Repr method.

      :returns: The object representation
      :rtype: str



.. py:function:: build_permission_param(permissions: str | list | dict) -> set

   Transform permissions to a set, so they are usable for requests.

   :param permissions: Permissions
   :type permissions: str | Iterable[str] | dict[str, str] | dict[str, Iterabble[str]]
   :returns: Permission parameters
   :rtype: set
   :raises KeycloakPermissionFormatError: In case of bad permission format


