utils package

Subpackages

Submodules

utils.apps module

class utils.apps.UtilsConfig(app_name, app_module)

Bases: django.apps.config.AppConfig

Configuration class for utils application.

default_auto_field

Default primary key for models in app.

Type

str

name

Name of application.

Type

str

default_auto_field = 'django.db.models.BigAutoField'
name = 'utils'

utils.auth module

class utils.auth.MasterKeyNaiveAuthentication

Bases: rest_framework.authentication.BaseAuthentication

Authentication model for master key.

Note

It was done the way I understood the assignment.In the task it was written that the authorization will be performed by the key in the email exchange. This solution allows you to set the master key as requested in the email. You could also set the authorization using the ready-made implementation included in the Django Rest Framework, which is TokenAuthentication. This authorization would allow tokens to be assigned to specific users. DRF requires any user to be returned upon authorization. For this authorization it will always be the first SuperUser, therefore at least one super user account is required. It may not be the best authorization for use in production, but it meets the assumption of a token sent by e-mail. In my opinion, a good authentication mechanism would be JWT(Json Web Token).

authenticate(request)

Authenticate the request and return a two-tuple of (user, token).

authenticate_header(request)

Return a string to be used as the value of the WWW-Authenticate header in a 401 Unauthenticated response, or None if the authentication scheme should return 403 Permission Denied responses.

Module contents