Decorators

Note

An useful check is missing here? Pull requests or issues welcome.

These decorators can be used similarily to login_required:

from django_compref_keycloak.decorators import fstumde_required

@fstumde_required
def my_view(request):
   ...
django_compref_keycloak.decorators.federation_no_shibboleth_required(login_url=None)

Decorator for views that checks whether a user is a federated account, but not shibboleth.

django_compref_keycloak.decorators.fsmbtumde_required(login_url=None)

Decorator for views that checks whether a user is a fsmb-tum.de account.

django_compref_keycloak.decorators.fstumde_required(login_url=None)

Decorator for views that checks whether a user is a fs.tum.de account.

django_compref_keycloak.decorators.idp_required(idp, login_url=None)

Decorator for views that checks whether a user is federated from a particular IDP.

Currently valid IDP values: - fs.tum.de - shibboleth.tum.de - fsmb-tum.de

django_compref_keycloak.decorators.tum_shibboleth_affiliation_required(affiliations, login_url=None)

Decorator for views that checks whether a user is a TUM shibboleth account and whether it has the particular affiliation.

Common values for the affiliation: - student - employee - alum

affiliations can be a string or list of strings.

django_compref_keycloak.decorators.tum_shibboleth_employee_required(login_url=None)

Decorator for views that checks whether a user is a TUM shibboleth account and whether it is an employee.

django_compref_keycloak.decorators.tum_shibboleth_org_required(args, login_url=None)

Decorator for views that checks whether a user is a TUM shibboleth account and whether it blongs to a particular org (“Zugehoerigkeit”). We only have the org for students and employees (not for guests - everyone else does not have an org).

This methods checks if the user belongs to an org as student or employee. If an user belongs to “TU1234” as student and to “TU5678” as employee, a check for both will return True.

orgs can be a string or list of strings.

django_compref_keycloak.decorators.tum_shibboleth_required(login_url=None)

Decorator for views that checks whether a user is a TUM shibboleth account.

django_compref_keycloak.decorators.tum_shibboleth_student_required(login_url=None)

Decorator for views that checks whether a user is a TUM shibboleth account and whether it is a student.