Tokens App
The tokens site app enables users to issue and manage access tokens for REST
API views used on your SODAR Core based Django site.
Basics
Users can use this app to create and delete access tokens. These can be set to expire or work until deleted.
Installation
Warning
To install this app you must have the django-sodar-core package
installed and the projectroles app integrated into your Django site.
See the projectroles integration document
for instructions.
Django Settings
The siteinfo app is available for your Django site after installing
django-sodar-core. Add the app into THIRD_PARTY_APPS as follows:
THIRD_PARTY_APPS = [
# ...
'tokens.apps.TokensConfig',
]
You also need to set KNOX_TOKEN_MODEL to tokens.SODARAuthToken.
Alternatively, you can use your own model which must extend `SODARAuthToken:
KNOX_TOKEN_MODEL = 'tokens.SODARAuthToken'
Optional Settings
To alter default tokens app settings, insert the following optional variables with values of your choosing:
# Tokens app settings
# Restrict access to token creation for users with project roles
TOKENS_CREATE_PROJECT_USER_RESTRICT = True
URL Configuration
In the Django URL configuration file, add the following line under
urlpatterns to include siteinfo URLs in your site.
urlpatterns = [
# ...
url(r'^tokens/', include('tokens.urls')),
]
Register Plugin
To register the siteinfo site app plugin, run the following management command:
$ ./manage.py syncplugins
You should see the following output:
Registering Plugin for tokens.plugins.SiteAppPlugin
Usage
When logged in to SODAR, you can find the “API Tokens” link in your user dropdown menu in the top right corner of the site.
Select “Create Token” from the “Token Operations” dropdown to create a new token. You will only see the token once, so make sure to copy it to clipboard at this point.
Deleting existing tokens can be done from the token list.