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_KEYrandom value. Keep it secret. DetailsUSE_X_FORWARDED_HOSTcan beTrueto use a X-Forwarded-Host header to construct linksWAMYTM_DEBUGshould beFalsein production to hide error details.WAMYTM_DATABASE_HOSTDatabase server nameWAMYTM_DATABASE_NAMEDatabase nameWAMYTM_DATABASE_USERNAMEUsername for database connectionWAMYTM_DATABASE_PASSWORDPassword for database connectionWAMYTM_KEYCLOAK_CLIENT_IDOpenID client id (value is taken from OpenID provider)WAMYTM_KEYCLOAK_CLIENT_SECRETOpenID client secret (value is taken from OpenID provider)WAMYTM_KEYCLOAK_PUBLIC_KEYJWT public key (value is taken from OpenID provider)WAMYTM_KEYCLOAK_AUTH_URLredirect uri for user loginsWAMYTM_KEYCLOAK_TOKEN_URLuri to exchange tokens from backend to OpenID connect providerWAMYTM_KEYCLOAK_VERIFY_SSLshould beTruein production to verify provider connectionWAMYTM_TRUST_X_FORWARDED_PROTOcan beTrueto 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 migrateto initialize database - Run
python manage.py createsuperuserto 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
wamytmin 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_URLandWAMYTM_KEYCLOAK_TOKEN_URLwith 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
wamytmfrom Available client scopes to Assigned default client scopes