A Django project to manage the Open Bank Project API via API Calls
Go to file
2016-11-09 15:52:09 +01:00
apimanager Initial commit 2016-11-09 14:54:47 +01:00
.gitignore Initial commit 2016-11-09 14:54:47 +01:00
gunicorn.conf.py Initial commit 2016-11-09 14:54:47 +01:00
LICENSE Initial commit 2016-11-09 14:54:47 +01:00
nginx.apimanager.conf Added a few configuration updates after first production deployment 2016-11-09 15:48:14 +01:00
NOTICE Initial commit 2016-11-09 14:54:47 +01:00
README.md Added missing angle brackets in README 2016-11-09 15:52:09 +01:00
requirements.txt Added a few configuration updates after first production deployment 2016-11-09 15:48:14 +01:00
supervisor.apimanager.conf Initial commit 2016-11-09 14:54:47 +01:00

API Manager

A Django project to manage the Open Bank Project API via API Calls

Installation (development)

It is assumed that the git checkout resides inside a project directory, e.g. /var/www/apimanager and /var/www/apimanager/API-Manager. Paths below are relative to this README. Files produced during installation or at runtime should be outside the git checkout in the project directory, except for Django's local settings.

Install dependencies

$ virtualenv --python=python3 ../venv
$ source ../venv/bin/activate
(venv)$ pip install -r requirements.txt

Configure settings

Edit apimanager/apimanager/local_settings.py:

SECRET_KEY = '<random string>'
OAUTH_API = '<your API root>' # e.g. https://api.openbankproject.com
OAUTH_CLIENT_KEY = '<key you got from the API>'
OAUTH_CLIENT_SECRET = '<secret you got from the API>'
DATABASES['default']['NAME'] = '<filename to use for database>' # default is 'db.sqlite3' in parent directory of git checkout

The application's authentication is API-driven. However, to make use of Django's authentication framework and sessions, there is a minimal requirement of a database. Per default, sqlite is used, but you can configure any Django-supported backend you want. Please lookup the appropriate documentation.

Initialise database

(venv)$ ./apimanager/manage.py migrate

Run the app

(venv)$ ./apimanager/manage.py runserver

The application should be available at http://localhost:8000

Installation (production)

Execute the same steps as for development, but do not run the app.

Settings

Edit apimanager/apimanager/local_settings.py for additional changes:

DEBUG = False
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '<your hostname here>']
STATIC_ROOT = '<directory to place static files in>'

Static files

The app's static files, e.g. Javasript, CSS and images need to be collected and made available to a webserver. Run

(venv)$ ./apimanager/manage.py collectstatic

Web application server

Instead of Django's built-in runserver, you need a proper web application server to run the app, e.g. gunicorn. It should have been installed already as a dependency and you use the provided gunicorn.conf.py. Run it like

(venv)$ cd apimanager/ && gunicorn --config ../gunicorn.conf.py apimanager.wsgi 
  • gunicorn does not start successfully when omitting the directory change and using apimanager.apimanager.wsgi as program.
  • The user running gunicorn needs to have write access to the directory containing the database, as well as the database file itself.

Process control

If you do not want to start the web application server manually, but automatically at boot and also want to restart automatically if it dies, a process control system like supervisor comes in handy. Stick the provided file supervisor.apimanager.conf into /etc/supervisor/conf.d/, edit it and reload supervisor (probably as root):

# /bin/systemctl restart supervisor

Webserver

Finally, use a webserver like nginx or apache as a frontend. It serves static files from the directory where collectstatic puts them and acts as a reverse proxy for gunicorn. Stick the provided nginx.apimanager.conf into /etc/nginx/sites-enabled/, edit it and reload the webserver (probably as root):

# /bin/systemctl reload nginx

Management

The app should tell you if your logged in user does not have the proper role to execute the management functionality you need. Please use a super_admin_user at API Explorer's /#2_0_0-addEntitlement to rectify that. If your user even cannot do that, set the property super_admin_user_ids in the API configuration accordingly.

Final words

Be aware of file permission issues!

Have fun, TESOBE