Skip to content

taipy.auth.AnyOf

Bases: RoleTraitsFilter

Select traits depending on whether any of the user roles belongs to the filter or not.

Available in Taipy Enterprise only

This class exists only in the Enterprise edition of Taipy.

AnyOf is a role traits filter that recursively selects role traits depending on the user roles: get_traits() returns the success value if the credentials hold any of the filter roles and failure if they do not.

Example

You can create an AnyOf role traits filter with the following code:

my_filter = AnyOf(["role1", "role2"], "Some role is present")

Let's pretend that a user is identified by the credentials instance of Credentials.

  • If the credentials hold the role "role3" only, but do not hold and of "role1" or "role2", then my_filter.get_traits(credentials) returns None, which is the default value for the failure case.
  • If the credentials hold the roles "role1" or "role2" and potentially any other roles, then my_filter.get_traits(credentials) returns the string "Some role is present", which is the value that was set for the success case.

__init__(filters, success, failure=None)

Initialize an Any Role Traits filter.

Parameters:

Name Type Description Default
filters Union[str, Set[str]]

The role or set of roles to filter.

required
success Union[RoleTraits, Any, None]

The role traits that are returned if any of the user roles appear in filters or if filters is empty.

required
failure Union[RoleTraits, Any, None]

The role traits that are returned if none of the user roles appear in filters or if the user has no roles.

None