Overview
Backend Authenticator
- PAMBackend.authenticate Authentication method [1]
This method has two keyword arguments one for the username and the other for the password, both are mandatory. There is a third argument used to pass in a dict of additional arguments that you may want stored in the database on the first login of the user.
In order to use the additional arguments both the
django.contrib.auth.authenticatefunction and either thedjango.contrib.auth.forms.AuthenticationFormor the Django PAMdjango_pam.accounts.forms.AuthenticationFormwould need to be overridden, depending on which one you use.- PAMBackend.get_user Returns the authenticated user [2]
There is one positional argument that can be the
pk,username, oremail. Theemailwould be used only if theemailis used instead of theusernameto identify the user.
Login and Logout Views
LoginView [3]
Usage
re_path(r'^login/$',
LoginView.as_view(form_class=MyAuthenticationForm,
success_url='/my/success/url/',
redirect_field_name='my-redirect-field-name',
template_name='your_template.html'),
name='login'),
This view is written to work with either a template POST or a XMLHttpRequest POST request.
LogoutView [4]
Usage
re_path(r'^logout/$',
LogoutView.as_view(template_name='my_template.html',
success_url='/my/success/url/),
redirect_field_name='my-redirect-field-name'),
name='logout')
This view is written to work with either a template POST or a XMLHttpRequest POST request.