Welcome | Get started | Dive into Lino | Contribute | Reference

lino.core.auth.backends

This started as a copy of Django 1.11 django.contrib.auth.backends.

Changes:

  • move "from django.contrib.auth.models import Permission" from global to local context

  • added support for use_ipdict

Classes

AllowAllUsersModelBackend()

AllowAllUsersRemoteUserBackend()

ModelBackend()

Authenticates against settings.AUTH_USER_MODEL.

RemoteUserBackend()

This backend is to be used in conjunction with the RemoteUserMiddleware found in the middleware module of this package, and is used when the server is handling authentication outside of Django.

class lino.core.auth.backends.ModelBackend

Bases: object

Authenticates against settings.AUTH_USER_MODEL.

user_can_authenticate(user)

Reject users with is_active=False. Custom user models that don't have that attribute are allowed.

get_user_permissions(user_obj, obj=None)

Returns a set of permission strings the user user_obj has from their user_permissions.

get_group_permissions(user_obj, obj=None)

Returns a set of permission strings the user user_obj has from the groups they belong.

has_module_perms(user_obj, app_label)

Returns True if user_obj has any permissions in the given app_label.

class lino.core.auth.backends.RemoteUserBackend

Bases: ModelBackend

This backend is to be used in conjunction with the RemoteUserMiddleware found in the middleware module of this package, and is used when the server is handling authentication outside of Django.

By default, the authenticate method creates User objects for usernames that don't already exist in the database. Subclasses can disable this behavior by setting the create_unknown_user attribute to False.

authenticate(request, remote_user)

The username passed as remote_user is considered trusted. This method simply returns the User object with the given username, creating a new User object if create_unknown_user is True.

Returns None if create_unknown_user is False and a User object with the given username is not found in the database.

clean_username(username)

Performs any cleaning on the "username" prior to using it to get or create the user object. Returns the cleaned username.

By default, returns the username unchanged.

configure_user(user)

Configures a user after creation and returns the updated user.

By default, returns the user unmodified.