Authentication

This package contains views related to login, logout and password reset functionality as well as 2FA authentication:

Account Activation View

class integreat_cms.cms.views.authentication.account_activation_view.AccountActivationView(**kwargs)[source]

Bases: PasswordResetConfirmView

View to set a new password and activate and account.

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
dispatch(*args: Any, **kwargs: Any) HttpResponse[source]

The view part of the view. Handles all HTTP methods equally.

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The rendered template response or a redirection to the login page

Return type:

HttpResponse

extra_context = None[source]
form_class[source]

alias of SetPasswordForm

form_invalid(form)[source]

If the form is invalid, render the invalid form.

form_valid(form: SetPasswordForm) HttpResponse[source]

If the form is valid, show a success message.

Parameters:

form (SetPasswordForm) – The supplied form

Returns:

A redirection to the success_url

Return type:

HttpResponse

get(request, *args, **kwargs)[source]

Handle GET requests: instantiate a blank version of the form.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_form_class()[source]

Return the form class to use.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_initial()[source]

Return the initial data to use for forms on this view.

get_prefix()[source]

Return the prefix to use for forms.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

get_user(uidb64)[source]
http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
initial = {}[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

post(request, *args, **kwargs)[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

post_reset_login = False[source]
post_reset_login_backend = None[source]
prefix = None[source]
put(*args, **kwargs)[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

reset_url_token = 'set-password'[source]
response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

success_url = '/login/'[source]

If the password was successfully reset, redirect to the login

template_engine = None[source]
template_name = 'authentication/account_activation_form.html'[source]

The template which should be rendered

title = 'Enter new password'[source]
token_generator = <integreat_cms.cms.utils.account_activation_token_generator.AccountActivationTokenGenerator object>[source]

The generator for activation tokens (use AccountActivationTokenGenerator instead of the default one to make sure password reset tokens are not accepted for account activation and vice versa)

view_is_async = False[source]

Login View

class integreat_cms.cms.views.authentication.login_view.LoginView(**kwargs)[source]

Bases: LoginView

View to extend the default login behavior from LoginView with multi-factor-authentication.

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

authentication_form = None[source]
content_type = None[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
form_class[source]

alias of AuthenticationForm

form_invalid(form)[source]

If the form is invalid, render the invalid form.

form_valid(form: AuthenticationForm) HttpResponseRedirect[source]

This function overwrites form_valid() which is called if the login form is valid. In case the user has mfa-keys configured, the login is delegated to WebAuthnLoginView. Else, the default method login() is used to log the user in. After that, the user is redirected to LOGIN_REDIRECT_URL.

Parameters:

form (AuthenticationForm) – User login form

Returns:

Redirect user to mfa login view or to LOGIN_REDIRECT_URL

Return type:

HttpResponseRedirect

get(request, *args, **kwargs)[source]

Handle GET requests: instantiate a blank version of the form.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_default_redirect_url()[source]

Return the default redirect URL.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_form_class()[source]

Return the form class to use.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_initial()[source]

Return the initial data to use for forms on this view.

get_prefix()[source]

Return the prefix to use for forms.

get_redirect_url()[source]

Return the user-originating redirect URL if it’s safe.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

get_success_url_allowed_hosts()[source]
get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
initial = {}[source]
next_page = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

post(request, *args, **kwargs)[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

prefix = None[source]
put(*args, **kwargs)[source]
redirect_authenticated_user = True[source]

A boolean that controls whether or not authenticated users accessing the login page will be redirected as if they had just successfully logged in.

redirect_field_name = 'next'[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

success_url = None[source]
success_url_allowed_hosts = {}[source]
template_engine = None[source]
template_name = 'authentication/login.html'[source]

The template to render (see TemplateResponseMixin)

view_is_async = False[source]

Logout View

class integreat_cms.cms.views.authentication.logout_view.LogoutView(**kwargs)[source]

Bases: LogoutView

View to log off a user

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
dispatch(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]

This function sends message, if logout was successful

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

passes form to dispatch function

Return type:

HttpResponse

extra_context = None[source]
get(request, *args, **kwargs)[source]

Logout may be done via POST.

get_context_data(**kwargs)[source]
get_default_redirect_url()[source]

Return the default redirect URL.

get_redirect_url()[source]

Return the user-originating redirect URL if it’s safe.

get_success_url()[source]
get_success_url_allowed_hosts()[source]
get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

http_method_names = ['get', 'head', 'post', 'options'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
next_page = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

post(request, *args, **kwargs)[source]

Logout may be done via POST.

redirect_field_name = 'next'[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

success_url_allowed_hosts = {}[source]
template_engine = None[source]
template_name = 'registration/logged_out.html'[source]
view_is_async = False[source]

Password Reset Confirm View

class integreat_cms.cms.views.authentication.password_reset_confirm_view.PasswordResetConfirmView(**kwargs)[source]

Bases: PasswordResetConfirmView

View to confirm that the password should be reset

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
dispatch(*args: Any, **kwargs: Any) HttpResponse[source]

The view part of the view. Handles all HTTP methods equally.

Parameters:
  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The rendered template response or a redirection to the password reset page

Return type:

HttpResponse

extra_context = None[source]
form_class[source]

alias of SetPasswordForm

form_invalid(form)[source]

If the form is invalid, render the invalid form.

form_valid(form: SetPasswordForm) HttpResponse[source]

If the form is valid, show a success message.

Parameters:

form (SetPasswordForm) – The supplied form

Returns:

form validation

Return type:

HttpResponse

get(request, *args, **kwargs)[source]

Handle GET requests: instantiate a blank version of the form.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_form_class()[source]

Return the form class to use.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_initial()[source]

Return the initial data to use for forms on this view.

get_prefix()[source]

Return the prefix to use for forms.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

get_user(uidb64)[source]
http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
initial = {}[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

post(request, *args, **kwargs)[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

post_reset_login = False[source]
post_reset_login_backend = None[source]
prefix = None[source]
put(*args, **kwargs)[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

reset_url_token = 'set-password'[source]
response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

success_url = '/login/'[source]

If the password was successfully reset, redirect to the login

template_engine = None[source]
template_name = 'authentication/password_reset_confirm.html'[source]

The template which should be rendered

title = 'Enter new password'[source]
token_generator = <django.contrib.auth.tokens.PasswordResetTokenGenerator object>[source]
view_is_async = False[source]

Password Reset View

class integreat_cms.cms.views.authentication.password_reset_view.PasswordResetView(**kwargs)[source]

Bases: PasswordResetView

View to extend the default login behaviour from LoginView with multi-factor-authentication.

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
dispatch(*args: HttpRequest, **kwargs: Any) HttpResponseRedirect | TemplateResponse[source]

The view part of the view. Handles all HTTP methods equally.

Parameters:
  • *args (HttpRequest) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

The rendered template response or a redirection

Return type:

HttpResponseRedirect | TemplateResponse

email_template_name = 'emails/password_reset_email.txt'[source]

The full name of a template to use for generating the email with the reset password link.

extra_context = None[source]
extra_email_context = None[source]
form_class[source]

The form for the password reset

Form fields:

alias of CustomPasswordResetForm

form_invalid(form)[source]

If the form is invalid, render the invalid form.

form_valid(form: CustomPasswordResetForm) HttpResponseRedirect[source]

This function validates the form and sends a message depending if the function was executed successfully

Parameters:

form (CustomPasswordResetForm) – The supplied form

Returns:

passes form to form validation

Return type:

HttpResponseRedirect

from_email = None[source]
get(request, *args, **kwargs)[source]

Handle GET requests: instantiate a blank version of the form.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_form_class()[source]

Return the form class to use.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_initial()[source]

Return the initial data to use for forms on this view.

get_prefix()[source]

Return the prefix to use for forms.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

html_email_template_name = 'emails/password_reset_email.html'[source]

The full name of a template to use for generating the html email with the reset password link.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
initial = {}[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

post(request, *args, **kwargs)[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

prefix = None[source]
put(*args, **kwargs)[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

subject_template_name = 'registration/password_reset_subject.txt'[source]
success_url = '/reset-password/'[source]

If the password reset process was successfully initialized, stay on the password reset page

template_engine = None[source]
template_name = 'authentication/password_reset_form.html'[source]

The template which should be rendered

title = 'Password reset'[source]
token_generator = <django.contrib.auth.tokens.PasswordResetTokenGenerator object>[source]
view_is_async = False[source]

Passwordless Login View

class integreat_cms.cms.views.authentication.passwordless_login_view.PasswordlessLoginView(**kwargs)[source]

Bases: LoginView

View to extend the default login behavior from LoginView with multi-factor-authentication.

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

authentication_form = None[source]
content_type = None[source]
dispatch(request, *args, **kwargs)[source]
extra_context = None[source]
form_class[source]

The form class for the passwordless login

Form fields:

  • username: Username (UsernameField)

alias of PasswordlessAuthenticationForm

form_invalid(form)[source]

If the form is invalid, render the invalid form.

form_valid(form: PasswordlessAuthenticationForm) HttpResponseRedirect[source]

This function overwrites form_valid() which is called if the login form is valid. In case the user has mfa-keys configured, the login is delegated to WebAuthnLoginView or TOTPLoginView. Else, the default method login() is used to log the user in. After that, the user is redirected to LOGIN_REDIRECT_URL.

Parameters:

form (PasswordlessAuthenticationForm) – User login form

Returns:

Redirect user to mfa login view or to LOGIN_REDIRECT_URL

Return type:

HttpResponseRedirect

get(request, *args, **kwargs)[source]

Handle GET requests: instantiate a blank version of the form.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_default_redirect_url()[source]

Return the default redirect URL.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_form_class()[source]

Return the form class to use.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_initial()[source]

Return the initial data to use for forms on this view.

get_prefix()[source]

Return the prefix to use for forms.

get_redirect_url()[source]

Return the user-originating redirect URL if it’s safe.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

get_success_url_allowed_hosts()[source]
get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
initial = {}[source]
next_page = None[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

post(request, *args, **kwargs)[source]

Handle POST requests: instantiate a form instance with the passed POST variables and then check if it’s valid.

prefix = None[source]
put(*args, **kwargs)[source]
redirect_authenticated_user = True[source]

A boolean that controls whether or not authenticated users accessing the login page will be redirected as if they had just successfully logged in.

redirect_field_name = 'next'[source]
render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

success_url = None[source]
success_url_allowed_hosts = {}[source]
template_engine = None[source]
template_name = 'authentication/passwordless_login.html'[source]

The template to render (see TemplateResponseMixin)

view_is_async = False[source]

Totp Login View

class integreat_cms.cms.views.authentication.totp_login_view.TOTPLoginView(**kwargs)[source]

Bases: TemplateView

View to extend the default login behavior from LoginView with multi-factor-authentication using TOTP.

__init__(**kwargs)[source]

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

classmethod as_view(**initkwargs)[source]

Main entry point for a request-response process.

content_type = None[source]
dispatch(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]

Check whether TOTP login can be used right now

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

Redirection to login form or region selection

Return type:

HttpResponse

extra_context = None[source]
get(request, *args, **kwargs)[source]
get_context_data(**kwargs: Any) dict[str, Any][source]

Get revision context data

Returns:

The context dictionary

Parameters:

kwargs (Any) –

Return type:

dict[str, Any]

get_template_names()[source]

Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace'][source]
http_method_not_allowed(request, *args, **kwargs)[source]
options(request, *args, **kwargs)[source]

Handle responding to requests for the OPTIONS HTTP verb.

post(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse[source]

Retrieves the entered TOTP code of the user and validates it.

Parameters:
  • request (HttpRequest) – The current request

  • *args (Any) – The supplied arguments

  • **kwargs (Any) – The supplied keyword arguments

Returns:

Redirection to region selection or rendered login form

Return type:

HttpResponse

render_to_response(context, **response_kwargs)[source]

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

response_class[source]

alias of TemplateResponse

setup(request, *args, **kwargs)[source]

Initialize attributes shared by all view methods.

template_engine = None[source]
template_name: str = 'authentication/login_totp.html'[source]

The template to render (see TemplateResponseMixin)

user: User | None = None[source]

The user who tries to authenticate

view_is_async = False[source]