reviewboard.accounts.backends.standard¶
Standard authentication backend.
- class StandardAuthBackend[source]¶
Bases:
BaseAuthBackend
,ModelBackend
Authenticate users against the local database.
This will authenticate a user against their entry in the database, if the user has a local password stored. This is the default form of authentication in Review Board.
This backend also handles permission checking for users on LocalSites. In Django, this is the responsibility of at least one auth backend in the list of configured backends.
Regardless of the specific type of authentication chosen for the installation, StandardAuthBackend will always be provided in the list of configured backends. Because of this, it will always be able to handle authentication against locally added users and handle LocalSite-based permissions for all configurations.
- name: Optional[StrOrPromise] = 'Standard Registration'[source]¶
The display name for the authentication backend.
This will be shown in the list of backends in the administration UI.
- Type:
- settings_form[source]¶
alias of
StandardAuthSettingsForm
- supports_registration: bool = True[source]¶
Whether this backend supports registering new users.
- Type:
- supports_change_name: bool = True[source]¶
Whether this backend supports changing the user’s full name.
- Type:
- supports_change_email: bool = True[source]¶
Whether this backend supports changing the user’s e-mail address.
- Type:
- supports_change_password: bool = True[source]¶
Whether this backend supports changing the user’s password.
- Type:
- authenticate(request: Optional[HttpRequest] = None, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs) Optional[User] [source]¶
Authenticate the user.
This will attempt to authenticate the user against the database. If the username and password are valid, a user will be returned.
Changed in version 6.0:
request
is now optional.username
andpassword
are technically optional, to aid in consistency for type hints, but will result in aNone
result.
Changed in version 4.0: The
request
argument is now mandatory as the first positional argument, as per requirements in Django.- Parameters:
request (
django.http.HttpRequest
) – The HTTP request from the caller. This may beNone
.username (
str
) – The username used for authentication.password (
str
) – The password used for authentication.**kwargs (
dict
, unused) – Additional keyword arguments supplied by the caller.
- Returns:
The authenticated user, or
None
if the user could not be authenticated for any reason.- Return type:
- get_or_create_user(username: str, request: Optional[HttpRequest] = None) Optional[User] [source]¶
Return an existing user or create one if it doesn’t exist.
This does not authenticate the user.
- Parameters:
username (
str
) – The username to fetch or create.request (
django.http.HttpRequest
, optional) – The HTTP request from the client.
- Returns:
The resulting user, or
None
if one could not be found.- Return type:
- update_password(user: User, password: str) None [source]¶
Update a user’s password on the backend.
This will update the user information, but will not save the user instance. That must be saved manually.
- Parameters:
user (
django.contrib.auth.models.User
) – The user whose password will be changed.password (
str
) – The new password.
- get_all_permissions(user: Union[AbstractBaseUser, AnonymousUser], obj: Optional[Model] = None) Set[str] [source]¶
Return a list of all permissions for a user.
If a LocalSite instance is passed as
obj
, then the permissions returned will be those that the user has on that LocalSite. Otherwise, they will be their global permissions.It is not legal to pass any other object.
- Parameters:
user (
django.contrib.auth.models.AnonymousUser
or :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:``django.contrib.auth.models.User
) – The user to retrieve permission for.obj (
django.db.models.Model
, optional) –A model used as context.
If provided, this must be a
LocalSite
.
- Returns:
A set of all permission codes.
- Return type:
- has_perm(user: Union[AbstractBaseUser, AnonymousUser], perm: str, obj: Any = None) bool [source]¶
Return whether or not a user has the given permission.
If a LocalSite instance is passed as
obj
, then the permissions checked will be those that the user has on that LocalSite. Otherwise, they will be their global permissions.It is not legal to pass any other object.
- Parameters:
user (
django.contrib.auth.models.AnonymousUser
or :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:``django.contrib.auth.models.User
) – The user to retrieve permission for.perm (
str
) – The permission code to check for.obj (
django.db.models.Model
, optional) –A model used as context.
If provided, this must be a
LocalSite
.
- Returns:
True
if the user has the permission.False
if it does not.- Return type:
- __annotations__ = {'INVALID_USERNAME_CHAR_REGEX': 're.Pattern', 'backend_id': 'Optional[str]', 'login_instructions': 'Optional[StrOrPromise]', 'name': 'Optional[StrOrPromise]', 'settings_form': 'Optional[Type[SiteSettingsForm]]', 'supports_change_email': 'bool', 'supports_change_name': 'bool', 'supports_change_password': 'bool', 'supports_registration': 'bool'}¶