i.AI Shared Code
automatilib is a django package used and developed by the i.AI team within the Cabinet Office.
It provides common features used in many of our applications.
Features
- Timestamped, UUID and base user models
- Initial migration for above models
- Logic for authenticating with COLA
Settings
LOGIN_REDIRECT_URL- The URL to redirect users to post-loginLOGIN_URL- The URL to redirect users to if they are not logged inCOLA_COOKIE_NAME- The name of the cookie to check for COLA JWTCOLA_COGNITO_CLIENT_ID- The cognito client ID found in AWSCOLA_LOGIN_FAILURE- Where the user should be redirected to in the event of authentication failure.AWS_REGION_NAME- The AWS region that the user pool and cognito client live inCOLA_COGNITO_USER_POOL_ID- The cognito user pool ID in AWSLOGIN_FAILURE_TEMPLATE_PATH- The path to an error template for authenticating with COLA errorsCONTACT_EMAIL- The contact email to be used in the login error template
This is where some of the above can be found:
COLA_COOKIE_NAME: In your json settings file for COLACOLA_COOKIE_DOMAIN: is.cabinetoffice.gov.ukby defaultCOLA_COGNITO_CLIENT_ID: In AWS, go to your cognito user pool, then to app integration, then at the bottom you can find your client ID in the tableAWS_REGION_NAME: Whichever region in AWS your Cognito pool lives, likely to beeu-west-2COLA_COGNITO_USER_POOL_ID: In AWS, go to your cognito user pool, in the top table calledUser pool overview, yourUser pool IDis thereCOLA_LOGIN_URL: Ask the COLA team for this URLCOLA_JWT_REGEX_PATTERN: This is one you can adjust how you want to, the baseline is(?<=:).*(?=\.)COLA_LOGIN_FAILURE- This should be a route in your app, if not specified the user will get a raw 401 plain text message.
To make use of COLA
see the example settings in this repo
Add these into your INSTALLED_APPS settings:
INSTALLED_APPS = [
"automatilib.core.apps.IdotAIConfig",
"automatilib.cola.apps.ColaAuthConfig",
...
]
Add this into your AUTHENTICATION_BACKEND setting:
AUTHENTICATION_BACKENDS = [
"automatilib.cola.backend.COLAAuthenticationBackend",
"django.contrib.auth.backends.ModelBackend", # This includes the default backend
]
Import and add the following to your url_patterns:
from automatilib.cola.urls import url_patterns as cola_urls
urlpatterns = other_urlpatterns + cola_urls
How to run Tests
DJANGO_SETTINGS_MODULE=example_project.settings pytest --cov cola --cov core --cov-report term-missing --cov-fail-under 80
Licence
MIT
Metadata
Release files for automatilib 1.2.1
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 |
|---|---|---|---|---|
| automatilib-1.2.1.tar.gz | 7.3 kB | Without provenance | Details for automatilib-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| automatilib-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for automatilib-1.2.1-py3-none-any.whl |
Total release size: 15.2 kB
Release files / automatilib-1.2.1.tar.gz
| Download URL | automatilib-1.2.1.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78523dc7184040f7738f9e775b7e453914e3d3aefe12e3a7a680410e94fbfa58
|
|
BLAKE2b-256 checksum How to use checksums |
fc846a25b01af8dcc963168049e23333bdd2a80b54196a9f86f14797b6320dec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / automatilib-1.2.1-py3-none-any.whl
| Download URL | automatilib-1.2.1-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dac23aa454ea9b9521c5c8a5a4357014faca50e72f685007d2c861ef72d20bcf
|
|
BLAKE2b-256 checksum How to use checksums |
44ef9f9be23d9701276ef64cb72127abc0db916e7be9cd06f49e94996b4bb48f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for automatilib 1.2.1
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.