Views

async nginx_ldap_auth.app.main.login(request: Request, service: str = '/')[source]

If the user is already logged in, redirect to the URI named by the service, query paremeter, defaulting to / if that is not present. Otherwise, render the login page.

If the header X-Auth-Realm is set, use that as the title for the login page. Otherwise use nginx_ldap_auth.settings.Settings.auth_realm.

Parameters:

request – The request object

Keyword Arguments:

service – redirect the user to this URL after successful login

async nginx_ldap_auth.app.main.login_handler(request: Request)[source]

Process our user’s login request. If authentication is successful, redirect to the value of the service hidden input field on our form.

If authentication fails, display the login form again.

If the header X-Auth-Realm is set, use that as the title for the login page. Otherwise use nginx_ldap_auth.settings.Settings.auth_realm.

Parameters:

request – The request object

async nginx_ldap_auth.app.main.logout(request: Request)[source]

Log the user out and redirect to the login page.

Parameters:

request – The request object

async nginx_ldap_auth.app.main.check_auth(request: Request, response: Response)[source]

Ensure the user is still authorized. If the user is authorized, return 200 OK, otherwise return 401 Unauthorized.

The user is authorized if the cookie exists, the session the cookie refers to exists, and the username key in the settings is set.

Additionally, the user must still exist in LDAP, and if nginx_ldap_auth.settings.Settings.ldap_authorization_filter is not None, the user must also match the filter.

Parameters:
  • request – The request object

  • response – The response object