authentication_service.views module

class authentication_service.views.CookieRedirectView(**kwargs)[source]

Bases: django.views.generic.base.View

Simple view that redirects in the event the client passes a cookie containing the correct key. In the event a cookie is not present, redirect to the django default login url.

User is explicitly logged out to clear the user session. In anticipation that the referrer will prompt them to login again so as to obtain the oidc tokens.

dispatch(request, *args, **kwargs)[source]
class authentication_service.views.DeleteAccountView(**kwargs)[source]

Bases: django.views.generic.edit.FormView

dispatch(*args, **kwargs)[source]
form_class

alias of authentication_service.forms.DeleteAccountForm

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

get_context_data(*args, **kwargs)[source]

Insert the form into the context dict.

success_url = '/profile/edit/'
template_name = 'authentication_service/profile/delete_account.html'
class authentication_service.views.EditProfileView(**kwargs)[source]

Bases: authentication_service.views.LanguageRedirectMixin, django.views.generic.edit.UpdateView

form_class

alias of authentication_service.forms.EditProfileForm

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_object(queryset=None)[source]

Returns the object the view is displaying.

By default this requires self.queryset and a pk or slug argument in the URLconf, but subclasses can override this to return any object.

template_name = 'authentication_service/profile/edit_profile.html'
class authentication_service.views.LanguageMixin[source]

Bases: object

This mixin sets an instance variable called self.language, value is passed in via url or determined by django language middleware

dispatch(*args, **kwargs)[source]
class authentication_service.views.LanguageRedirectMixin[source]

Bases: authentication_service.views.LanguageMixin, authentication_service.views.RedirectMixin

Combined class for the frequently used Language and Redirect mixins. Language can safely be set on views that make no use of it.

class authentication_service.views.LockoutView(**kwargs)[source]

Bases: django.views.generic.base.TemplateView

A view used by Defender to inform the user that they have exceeded the threshold for allowed login failures or password reset attempts.

get_context_data(*args, **kwargs)[source]
template_name = 'authentication_service/lockout.html'
class authentication_service.views.LoginView(**kwargs)[source]

Bases: two_factor.views.core.LoginView

This view simply extends the LoginView from two_factor.views.core. We only override the template and the done step, which we use to login superusers.

dispatch(request, *args, **kwargs)

This method gets called by the routing engine. The first argument is request which contains a HttpRequest instance. The request is stored in self.request for later use. The storage instance is stored in self.storage.

After processing the request using the dispatch method, the response gets updated by the storage engine (for example add cookies).

form_list = (('auth', <class 'django.contrib.auth.forms.AuthenticationForm'>), ('token', <class 'two_factor.forms.AuthenticationTokenForm'>), ('backup', <class 'two_factor.forms.BackupTokenForm'>))
template_name = 'authentication_service/login/login.html'
class authentication_service.views.PasswordResetConfirmView(**kwargs)[source]

Bases: django.contrib.auth.views.PasswordResetConfirmView

form_class

alias of authentication_service.forms.SetPasswordForm

class authentication_service.views.RedirectMixin[source]

Bases: object

This mixin gets the redirect URL parameter from the request URL. This URL is used as the success_url attribute. If no redirect_url is set, it will default to the Login URL.

For registration, this mixin also checks the security level of the request. If the security level is high, the success URL will redirect to 2FA setup.

TODO: Security should be moved out.

dispatch(*args, **kwargs)[source]
get_success_url()[source]
success_url = None
class authentication_service.views.RegistrationView(**kwargs)[source]

Bases: authentication_service.views.LanguageRedirectMixin, django.views.generic.edit.CreateView

dispatch(*args, **kwargs)[source]
form_class

alias of authentication_service.forms.RegistrationForm

form_invalid(form)[source]

If the form is invalid, re-render the context data with the data-filled form and errors.

form_valid(form)[source]

If the form is valid, save the associated model.

get_context_data(*args, **kwargs)[source]

Insert the form into the context dict.

get_form_kwargs()[source]

Returns the keyword arguments for instantiating the form.

get_formset
security = None
template_name = 'authentication_service/registration/registration.html'
class authentication_service.views.ResetPasswordSecurityQuestionsView(**kwargs)[source]

Bases: django.views.generic.edit.FormView

dispatch(request, *args, **kwargs)
form_class

alias of authentication_service.forms.ResetPasswordSecurityQuestionsForm

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form_kwargs()[source]

Returns the keyword arguments for instantiating the form.

get_success_url()[source]

Returns the supplied success URL.

template_name = 'authentication_service/reset_password/security_questions.html'
class authentication_service.views.ResetPasswordView(**kwargs)[source]

Bases: django.contrib.auth.views.PasswordResetView

This view allows the user to enter either their username or their email address in order for us to identify them. After we have identified the user we check what method to user to help them reset their password. If the user has an email address, we send them a reset link. If they have security questions, we take them to the ResetPasswordSecurityQuestionsView to enter their answers.

form_class

alias of authentication_service.forms.ResetPasswordForm

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

looks_like_email(identifier)[source]
success_url = '/reset-password/done/'
template_name = 'authentication_service/reset_password/reset_password.html'
class authentication_service.views.UpdatePasswordView(**kwargs)[source]

Bases: authentication_service.views.LanguageRedirectMixin, django.contrib.auth.views.PasswordChangeView

form_class

alias of authentication_service.forms.PasswordChangeForm

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

success_url = '/profile/edit/'
template_name = 'authentication_service/profile/update_password.html'
class authentication_service.views.UpdateSecurityQuestionsView(**kwargs)[source]

Bases: authentication_service.views.LanguageRedirectMixin, django.views.generic.base.TemplateView

get(request, *args, **kwargs)[source]
get_context_data(*args, **kwargs)[source]
get_formset
post(request, *args, **kwargs)[source]
render(request, formset)[source]
success_url = '/profile/edit/'
template_name = 'authentication_service/profile/update_security_questions.html'