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.

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

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

success_url = '/login/'[source]

If the password was successfully reset, redirect to the login

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

The template which should be rendered

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)

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.

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

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.

template_name = 'authentication/login.html'[source]

The template to render (see TemplateResponseMixin)

Logout View

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

Bases: LogoutView

View to log off a user

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

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

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

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

success_url = '/login/'[source]

If the password was successfully reset, redirect to the login

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

The template which should be rendered

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.

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.

form_class[source]

The form for the password reset

Form fields:

alias of CustomPasswordResetForm

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

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.

success_url = '/reset-password/'[source]

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

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

The template which should be rendered

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.

form_class[source]

The form class for the passwordless login

Form fields:

  • username: Username (UsernameField)

alias of PasswordlessAuthenticationForm

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

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.

template_name = 'authentication/passwordless_login.html'[source]

The template to render (see TemplateResponseMixin)

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.

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

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]

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

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