Install
Install DjangoPlugin Package
pip install -e git@github.com:TokkoLabs/authorization.git
Import & Configure dj-plugin
your-project/settings.py
# Add app to installed apps
INSTALLED_APPS = [
'tokko-auth'
]
# Also add declare app's middleware
MIDDLEWARE = [
# Has request JWT?
"tokko-auth.middleware.HasJWTMiddleware",
# JWT has required NAMESPACE?
"tokko-auth.middleware.NamespaceAuthorizationMiddleware",
# Fill "request.user" attribute
"tokko-auth.middleware.UserRecoverMiddleware",
]
# Finally, declare your AUTH0_DOMAIN
AUTH0_DOMAIN = 'my-auth-sub-dns.auth0.com'
Usage
API required NAMESPACE
your-project/settings.py
# API required NAMESPACE
AUTH_API_NAMESPACE = 'my-service-namespace'
View & Mutation required SCOPES
Resticciones de acceso basado en scopes para la view some_ufo_secrets.
from authorization.decorators import has_permission
# Require todos los scopes
@has_permission('x-files:agent', 'alien:believer', has_all=True)
def some_ufo_secrets(request):
...
# Al menos un scope
@has_permission('scully:agent', 'mulder:agent', at_least_one=True)
def some_ufo_secrets(request):
...
Settings
Environment Vars
Esta aplicación observa un conjunto de variables de entorno configurables, las cuales pueden modificar drásticamente su funcionamiento.
Required
| Name | Description | Type | Default |
|---|---|---|---|
| AUTH0_DOMAIN | Auth0 Domain. Ej: {my-project}.auth.com. Si esta variable no esta correctamente configurada, se emitirá un exception EnvVarNotInitialized |
String | - |
Optional
| Name | Description | Type | Default |
|---|---|---|---|
| AUTH_FAIL_SAFE_ENABLE | Remueve errores de validación | Boolean | False |
| AUTH_USERINFO_ENABLE | Agrega /userinfo data al request.user |
Boolean | False |
| AUTH_API_NAMESPACE | Scopes requeridos a nivel API, estos se validaran en cada request | List | [ ] |
| AUTH_BEAUTIFY_ERROR_RESPONSE | Formatea los errors a JSONResponse, se auto-deshabilita sobre GQL | Boolean | False |
| AUTH_FULL_DISABLED | Desactiva validacion de Auth | Boolean | False |
| AUTH_ALLOW_PRODUCTIVE_SHUTDOWN | Permite desactivar la validacion de Auth en productivo | Boolean | False |
| SAMPLES_ARE_ENABLE | Agrega Views, Mutation & Queries de ejemplo |
Boolean | True |
Testing
Local environment
Unit Test
python manage.py test authorization.tests.unit
Service Test
python manage.py test authorization.tests.service
Docker environment
Unit Test
# Require: docker-compose up [-d] [--build]
docker-compose exec app bash -c "python manage.py test authorization.tests.unit"
Service Test
# Require: docker-compose up [-d] [--build]
docker-compose exec app bash -c "python manage.py test authorization.tests.service"
Glossary
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to project.
Metadata
Release files for django-tokko-auth 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-tokko-auth-0.0.3.tar.gz | 12.6 kB | Without provenance | Details for django-tokko-auth-0.0.3.tar.gz |
Release files / django-tokko-auth-0.0.3.tar.gz
| Download URL | django-tokko-auth-0.0.3.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
43d1d51a02a79d18d2b948a925224758384ebe978660a7cba98b7e38a89aea1e
|
|
BLAKE2b-256 checksum How to use checksums |
a185c3d98bbce43d6109734f549022d132951bce6d1ad8e001f841e445e93e11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.0
|
Security for django-tokko-auth 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.