API

Handlers

Handlers for shibboleth endpoints.

shibboleth_authenticator.handlers.authorized_signup_handler(auth, remote=None, *args, **kwargs)[source]

Handle sign-in/up functionality.

Checks if user is already registered. If not registered, the function registers a new user and authenticates the new user. If there already exists a user object in the database, the user is only authenticated and logged in.

Parameters:
  • remote – The remote application.
  • resp – The response.
Returns:

Redirect response.

Views

Blueprint for handling Shibboleth callbacks.

shibboleth_authenticator.views.authorized(remote_app=None)[source]

Authorize handler callback.

This function is called when the user is redirected from the IdP to the web application. It handles the authorization.

Parameters:remote_app (str) – The remote application key name.
Returns:Return redirect response or abort in case of failure.
Return type:flask.Response
shibboleth_authenticator.views.init_saml_auth(req, saml_path)[source]

Init SAML authentication for remote application.

Parameters:
  • req (dict) –
  • saml_path (str) – The path to the configuration files for python3-saml.

Returns:

shibboleth_authenticator.views.login(remote_app)[source]

Redirect user to remote application for authentication.

This function redirects the user to the IdP for authorization. After having authorized the IdP redirects the user back to this web application as configured in your saml_path.

Parameters:remote_app (str) – The remote application key name.
Returns:
Return redirect response to IdP or abort in case
of failure.
Return type:flask.Response
shibboleth_authenticator.views.metadata(remote_app)[source]

Create remote application specific metadata xml for ServiceProvider.

The metadata-XML response is created using the settings provided in the remote app’s specific saml_path.

Parameters:remote_app (str) – The remote application key name.
Returns:The SP’s metadata xml.
Return type:flask.Response
shibboleth_authenticator.views.prepare_flask_request(request)[source]

Prepare flask request.

Parameters:request (flask.Request) – The Flask request.
Returns:Returns dictionary used in init_saml_auth().
Return type:dict

Utils

Utility methods to help find, authenticate or register a remote user.

shibboleth_authenticator.utils.get_account_info(attributes, remote_app)[source]

Return account info for remote user.

shibboleth_authenticator.utils.get_safe_redirect_target(arg='next')[source]

Get URL to redirect to and ensure that it is local.

Parameters:arg – URL argument.
Returns:The redirect target or None.