simple_openid_connect.integrations.django.apps

Django AppConfig for this app

Functions

check_middleware(*args, **kwargs)

Classes

OpenidAppConfig(app_name, app_module)

The Django AppConfig for simple_openid_connect

SettingsModel(*, OPENID_ISSUER, OPENID_CLIENT_ID)

A pydantic model used to validate django settings

class simple_openid_connect.integrations.django.apps.OpenidAppConfig(app_name, app_module)[source]

The Django AppConfig for simple_openid_connect

get_client(own_base_uri: HttpRequest | str | None = None) OpenidClient[source]

Get an OpenidClient instance that is appropriate for usage in django.

It is automatically configured via django settings.

Parameters:

own_base_uri – The base url of this application which will be used to construct a redirect_uri back to it. Can also be the current request in which case {scheme}://{host} of it will be used as the base url. If this parameter is not given, only the OPENID_BASE_URI setting is used. In any case, if the OPENID_BASE_URI setting is set, it will be used instead.

Raises:

ImproperlyConfigured – when no own_base_uri is given and the OPENID_BASE_URI is also None

classmethod get_instance() OpenidAppConfig[source]

Retrieve the currently used instance from django’s app registry

ready() None[source]

Called when django starts.

Performs settings validation and raises ImproperlyConfigured if necessary.

property safe_settings: SettingsModel

type-validated version of django settings

property user_mapper: UserMapper

A UserMapper instance of which the actual implementation is configured via django settings.

class simple_openid_connect.integrations.django.apps.SettingsModel(*, OPENID_ISSUER: str, OPENID_CLIENT_ID: str, OPENID_CLIENT_SECRET: str | None = None, OPENID_SCOPE: str = 'openid', OPENID_REDIRECT_URI: str | None = 'simple_openid_connect:login-callback', OPENID_BASE_URI: str | None = None, OPENID_USER_MAPPER: str = 'simple_openid_connect.integrations.django.user_mapping.UserMapper', OPENID_LOGIN_TIMEOUT: int = 300)[source]

A pydantic model used to validate django settings

OPENID_BASE_URI: str | None

The absolute base uri of this application. This is used to construct valid redirect urls to the current application.

OPENID_CLIENT_ID: str

The client id that was issued to you from your OpenId provider.

OPENID_CLIENT_SECRET: str | None

The client secret that was issued to you from your OpenId provider if this is a confidential client.

OPENID_ISSUER: str

The Openid issuer to use. This is required to be an https url and an Openid discovery document should be served under {issuer}/.well-known/openid-configuration.

OPENID_LOGIN_TIMEOUT: int

Time in seconds which a login procedure is allowed to take at maximum. If a user takes more than this time between initiating a login and completing it, the login process fails and they have to redo it.

OPENID_REDIRECT_URI: str | None

The URL or ``named URL pattern <https://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns>``_ where users are redirected to from the OpenId provider and at which the authentication result is processed. This is sometimes also called a callback uri.

OPENID_SCOPE: str

The Openid scopes which are requested from the provider when a user logs in. It should be a list of scopes as space separated string and should contain the openid scope.

OPENID_USER_MAPPER: str

A string specifying a class that inherits from simple_openid_connect.integrations.django.user_mapping.UserMapper.

model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].