CMservice

August 30, 2016 ยท View on GitHub

A webservice for collecting and storing end-user consent of attributes.

Install dependencies

To install all necessary dependencies, run python setup.py install in the root directory.

Run CMservice

Copy the settings.cfg.example and rename the copy settings.cfg. If needed modify the necessary configurations.

export CMSERVICE_CONFIG=<path to settings.cfg> gunicorn cmservice.service.run:app

Make sure to setup HTTPS cert and key, and bind to the correct host/port using gunicorn settings.

Configuration

Parameter nameData typeExample valueDescription
SSLbooleanTrueShould the server use https or not
SERVER_CERTString"./keys/server.crt"The path to the certificate file used by SSL comunication
SERVER_KEYString"./keys/server.key"The path to the key file used by SSL comunication
TRUSTED_KEYSList of strings["./keys/mykey.pub"]A list of signature verification keys
SECRET_KEYString"t3ijtgglok432jtgerfd"A random value used by cryptographic components to for example to sign the session cookie
PORTInteger8166Port on which the CMservice should start if running the dev server in run.py
HOSTString"127.0.0.1"The IP-address on which the CMservice should run if running the dev server in run.py
DEBUGbooleanFalseTurn on or off the Flask servers internal debuggin, should be turned off to ensure that all log information get stored in the log file
TICKET_TTLInteger600For how many seconds the ticket should be valid
CONSENT_DATABASE_URLString"mysql://localhost:3306/consent"URL to SQLite/MySQL/Postgres database, if not supplied an in-memory SQLite database will be used
CONSENT_REQUEST_DATABASE_URLString"mysql://localhost:3306/consent_req"URL to SQLite/MySQL/Postgres database, if not supplied an in-memory SQLite database will be used
AUTO_SELECT_ATTRIBUTESbooleanTrueSpecifies if all the attributes in the GUI should be selected or not
MAX_CONSENT_EXPIRATION_MONTHInteger12The maximum numbers of months a consent could be valid
USER_CONSENT_EXPIRATION_MONTHList of integers[3, 6]A list of alternatives for how many months a user wants to give consent
LOGGING_FILEString"cmservice.log"A path to the log file, if none exists it will be created
LOGGING_LEVELString"WARNING"Which logging level the application should use. Possible values: INFO, DEBUG, WARNING, ERROR and CRITICAL
CONSENT_SALTString"VFT0yZ"A SALT used to hash the consent ID before stroed in the database

Storage

Some information has to be stored in order for the CMservice to work

Database alternatives

Currently the consent could be stored in either in memory database or in a SQLite database. Please read the "Configuration" section for more information on how to switch between the different database instances.

Stored infomation

Database columnDescription
consent_idAn unique id for a consent, generated by the client. Before the consent ID is strored in the database a SALT is concatinated with the consent id recived from the client and it is then hashed
timestampTime for when the consent where given.
monthFor how many months the consent where given. After that particular date the user needs to give consent again.
attributesAll the attributes for which consent where given. Note that it's only for which attributes consent where given and not the values.
question_hashThe consent question sent by the client. It's a hash over who sent the original request, the consent_id, the selected attributes and values

Ticket database

Database columnDescription
TicketA identifier for the ticket
TimestampThe time then the ticket where created
TicketDataThe unpacked original consent request which where sent as a singed JWT. The request contains user attributes and values in plain text, a user ID a redirect URL, information about the service provider making the request

Development

i18n

To extract all i18n string:

python setup.py extract_messages --input-paths src/cmservice/ --output-file src/cmservice/service/data/i18n/messages.pot

To compile .po->.mo:

python setup.py compile_catalog --directory src/cmservice/service/data/i18n/locales/

See Babel docs for more info.