Automatilib is common django code used by the i.AI team.
Project description
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 AWSAWS_REGION_NAME
- The AWS region that the user pool and cognito client live inCOLA_COGNITO_USER_POOL_ID
- The cognito user pool ID in AWS
This is where some of the above can be found:
COLA_COOKIE_NAME
: In your json settings file for COLACOLA_COOKIE_DOMAIN
:cabinetoffice.gov.uk
COLA_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-2
COLA_COGNITO_USER_POOL_ID
: In AWS, go to your cognito user pool, in the top table calledUser pool overview
, yourUser pool ID
is 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(?<=:).*(?=\.)
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
automatilib-1.0.2.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for automatilib-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57366281ac6bc07e6e2a6e1f13712e22148d09250fab652d21e5edbdd5075cb8 |
|
MD5 | 8520694707c4d0839e4527229be87622 |
|
BLAKE2b-256 | 5816eb42be9fdf1d1a7dcbdf990501f653c3a82d3f71221f41c55b6dcddd5035 |