datopian / deploy

Deployment automation for the DataHub

Home Page:https://datahub.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create function to create users with token

Mikanebu opened this issue · comments

We want to have a script in python3 to create users.

Acceptance criteria

  • Can create a user from command line (and outputs token)
  • Can generate a token for user (assume the user exists)

Tasks

  • Connect to DB, create user
  • Generate token [and do what ...]

What is DP ~rufuspollock

And i've tidied your sample script below

# get connection string from environment
...

# create the user in the database
insert into users values (‘core’, ‘core’, ‘core’, ‘Core Datasets’, ‘datasets@okfn.org’, ‘’, ‘’)
# check it worked (optional)
# select * from users;

token = jwt.encode(token, private_key, algorithm='RS256').decode('ascii')