RemoteUserBackend
This backend is to be used in conjunction with the RemoteUserMiddleware found in the middleware module of this package, and is used when the server is handling authentication outside of Django.
Attributes
| Attribute | Type | Description |
|---|---|---|
| create_unknown_user | boolean = True | Determines whether the authenticate method creates User objects for usernames that don't already exist in the database. |
Methods
authenticate()
@classmethod
def authenticate(
request: [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest),
remote_user: str
) - > User | None
The username passed as remote_user is considered trusted. Return the User object with the given username. Create a new User object if create_unknown_user is True.
Parameters
| Name | Type | Description |
|---|---|---|
| request | [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest) | The current HTTP request object associated with the authentication attempt. |
| remote_user | str | The trusted username string provided by the external authentication source. |
Returns
| Type | Description |
|---|---|
| `User | None` |
aauthenticate()
@classmethod
def aauthenticate(
request: [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest),
remote_user: str
) - > User | None
Asynchronous version of authenticate(). The username passed as remote_user is considered trusted.
Parameters
| Name | Type | Description |
|---|---|---|
| request | [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest) | The current HTTP request object associated with the authentication attempt. |
| remote_user | str | The trusted username string provided by the external authentication source. |
Returns
| Type | Description |
|---|---|
| `User | None` |
clean_username()
@classmethod
def clean_username(
username: str
) - > str
Perform any cleaning on the "username" prior to using it to get or create the user object. Return the cleaned username.
Parameters
| Name | Type | Description |
|---|---|---|
| username | str | The raw username string received from the remote authentication system. |
Returns
| Type | Description |
|---|---|
str | The processed username string ready for database lookup or creation. |
configure_user()
@classmethod
def configure_user(
request: [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest),
user: [User](../models/user.md?sid=django_contrib_auth_models_user),
created: bool = True
) - > [User](../models/user.md?sid=django_contrib_auth_models_user)
Configure a user and return the updated user. By default, return the user unmodified.
Parameters
| Name | Type | Description |
|---|---|---|
| request | [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest) | The current HTTP request object, useful for accessing session or metadata during configuration. |
| user | [User](../models/user.md?sid=django_contrib_auth_models_user) | The User instance that was just retrieved or created by the backend. |
| created | bool = True | A flag indicating whether this User instance was newly created in the database. |
Returns
| Type | Description |
|---|---|
[User](../models/user.md?sid=django_contrib_auth_models_user) | The User object after any custom configuration or attribute assignments have been applied. |
aconfigure_user()
@classmethod
def aconfigure_user(
request: [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest),
user: [User](../models/user.md?sid=django_contrib_auth_models_user),
created: bool = True
) - > [User](../models/user.md?sid=django_contrib_auth_models_user)
Asynchronous version of configure_user(). Configures a user and returns the updated user.
Parameters
| Name | Type | Description |
|---|---|---|
| request | [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest) | The current HTTP request object, useful for accessing session or metadata during configuration. |
| user | [User](../models/user.md?sid=django_contrib_auth_models_user) | The User instance that was just retrieved or created by the backend. |
| created | bool = True | A flag indicating whether this User instance was newly created in the database. |
Returns
| Type | Description |
|---|---|
[User](../models/user.md?sid=django_contrib_auth_models_user) | The User object after any custom configuration or attribute assignments have been applied. |