django_pam.auth package

django_pam.auth.backends module

Django PAM backend.

class django_pam.auth.backends.PAMBackend[source]

Bases: ModelBackend

An implementation of a PAM backend authentication module.

authenticate(request, username=None, password=None, **extra_fields)[source]

Authenticate using PAM then get the account if it exists else create a new account.

Note

The keyword arguments ‘service’, ‘encoding’, and ‘resetcreds’ can also be passed and will be pulled off the ‘extra_fields’ kwargs.

Parameters:
  • username (str) – The users username. This is a manditory field.

  • password (str) – The users password. This is a manditory field.

  • extra_fields (dict) – Additonal keyword options of any editable field in the user model or arguments in the PAM authenticate method.

Return type:

The Django user object or None if it fails.

get_user(user_data)[source]

Get the user by either the username, email, or the pk.

Parameters:

user_data – The username, email or pk.

Return type:

A Django user object.