Install guide
Requirements
- PostgresQL database
- OpenID Connect provider (optional), e. g. a Keycloak instance, for single sign on
Running
The application can be run using the provided container at Docker Hub.
Supported environment variables:
SECRET_KEY
random value. Keep it secret. DetailsUSE_X_FORWARDED_HOST
can beTrue
to use a X-Forwarded-Host header to construct linksWAMYTM_DEBUG
should beFalse
in production to hide error details.WAMYTM_DATABASE_HOST
Database server nameWAMYTM_DATABASE_NAME
Database nameWAMYTM_DATABASE_USERNAME
Username for database connectionWAMYTM_DATABASE_PASSWORD
Password for database connectionWAMYTM_KEYCLOAK_CLIENT_ID
OpenID client id (value is taken from OpenID provider)WAMYTM_KEYCLOAK_CLIENT_SECRET
OpenID client secret (value is taken from OpenID provider)WAMYTM_KEYCLOAK_PUBLIC_KEY
JWT public key (value is taken from OpenID provider)WAMYTM_KEYCLOAK_AUTH_URL
redirect uri for user loginsWAMYTM_KEYCLOAK_TOKEN_URL
uri to exchange tokens from backend to OpenID connect providerWAMYTM_KEYCLOAK_VERIFY_SSL
should beTrue
in production to verify provider connectionWAMYTM_TRUST_X_FORWARDED_PROTO
can beTrue
to trust a X-Forwarded_Proto header
Running from repository using docker-compose
The following steps start a demonstration instance.
- Start required containers:
docker-compose up -d
- Database
- Connect to database server:
docker-compose exec db psql -U postgres
- Setup database (see commands)
- Keycloak identity server
- Open Keycloak by visiting https://localhost:8443/auth/
- Temporary accept certificate
- Korporator setup
- Connect to the app:
docker-compose exec korporator /bin/bash
- Run
python manage.py migrate
to initialize database - Run
python manage.py createsuperuser
to create backend admin - Access the backend at http://localhost:8000/admin/
- Access the frondend at http://localhost:8000/
- Example users: user1:3itsvxks, user2:Fq5vnMfj
Database setup commands:
create user wamytm with encrypted password 'Stw9nUvm';
alter role wamytm set client_encoding to 'utf8';
alter role wamytm set default_transaction_isolation to 'read committed';
alter role wamytm set timezone to 'UTC';
create database wamytmdb;
revoke CONNECT on DATABASE wamytmdb from public;
grant all on DATABASE wamytmdb to wamytm;
alter database wamytmdb owner to wamytm;
\c wamytmdb
alter schema public owner to wamytm;
\q
Configure login with Keycloak
- Create a new client
wamytm
in the realm's Clients section - Configure client settings:
- Settings > Access Type > confidential
- Settings > Fine Grain OpenID Connect Configuration > User Info Signed Response Algorithm > RS256
- Settings > Fine Grain OpenID Connect Configuration > Request Object Signature Algorithm > RS256
- Use the Client ID (Settings tab) as value for
WAMYTM_KEYCLOAK_CLIENT_ID
- Use the Secret (Credentials tab) as value for
WAMYTM_KEYCLOAK_CLIENT_SECRET
- Get the public key from Realm Settings > Keys > Public key and put it into settings as
WAMYTM_KEYCLOAK_PUBLIC_KEY
- Update urls in
WAMYTM_KEYCLOAK_AUTH_URL
andWAMYTM_KEYCLOAK_TOKEN_URL
with the correct hostname, port and realm name - Configure username mapper: Clients > Client ID > Mappers: Create User Property mapper, set Token Claim Name to
username
, Property tousername
(or something equal, e. g. email) - Open Client Scopes and add new scope
wamytm
- Open Mappers tab and add a new mapper: Name
wamytm-audience
, Mapper TypeAudience
, Included Client Audience:wamytm
, Add to access tokenon
- Open Clients > wamytm > Client Scopes and add
wamytm
from Available client scopes to Assigned default client scopes