From 408856b7af4b69f1a6d833a16f71ba86076c7577 Mon Sep 17 00:00:00 2001 From: osmala <ossi.laine@utu.fi> Date: Thu, 15 Apr 2021 10:14:26 +0300 Subject: [PATCH] How to create users manually --- README.md | 4 ++++ deploy/config/mysql/data.sql | 13 +++++++++++++ deploy/config/mysql/schema.sql | 13 +------------ generate_password.py | 10 ++++++++++ 4 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 deploy/config/mysql/data.sql create mode 100644 generate_password.py diff --git a/README.md b/README.md index 55ab406..26f9df7 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,10 @@ service gunicorn restart Install docker and docker-compose +Generate users and groups in deploy/config/mysql/data.sql + +Password can be generated with generate_password.py -script + Go to deploy folder. Build containers and run them with: ``` docker-compose -f docker-compose.yml up -d --build diff --git a/deploy/config/mysql/data.sql b/deploy/config/mysql/data.sql new file mode 100644 index 0000000..ad59348 --- /dev/null +++ b/deploy/config/mysql/data.sql @@ -0,0 +1,13 @@ + +/* password:password */ +INSERT INTO user VALUES(1,'admin',NULL,'pbkdf2:sha256:50000$6Cc6Mjmo$3fe413a88db1bacfc4d617f7c1547bd1ea4cbd6c5d675a58e78332201f6befc6'); + +/* password:password */ +INSERT INTO user VALUES(2,'editor',NULL,'pbkdf2:sha256:50000$Rq2WwVVi$12335e8d02fa3f25ffd11ba9f02fd1db7ca2964c5eaa13ca179a02ee3f19a656'); + +INSERT INTO research_group(id, name, tag, description) VALUES(1, 'Human Emotion Systems', 'emotion', 'Welcome to the Human Emotion Systems -laboratory`s Onni-net laboratory! The experiments that are currently underway are listed below - you can participate for as many experiments you want.'); +INSERT INTO research_group(id, name, tag, description) VALUES(2, 'Turku Eye-tracking', 'eyelabs', 'Welcome to the Turku Eyelabs -laboratory`s Onni-net laboratory! The experiments that are currently underway are listed below - you can participate for as many experiments you want.'); + +INSERT INTO user_in_group VALUES (1,1, 'admin'); +INSERT INTO user_in_group VALUES (2,1, 'editor'); + diff --git a/deploy/config/mysql/schema.sql b/deploy/config/mysql/schema.sql index c12823c..ef8429b 100644 --- a/deploy/config/mysql/schema.sql +++ b/deploy/config/mysql/schema.sql @@ -197,10 +197,7 @@ ALTER TABLE experiment ADD COLUMN (embody_enabled BOOLEAN DEFAULT 0); /* Set current answer type (embody/slider/etc..) so returning users are routed to correct question */ ALTER TABLE answer_set ADD COLUMN (answer_type VARCHAR(120)); -INSERT INTO user VALUES(1,'admin',NULL,'pbkdf2:sha256:50000$6Cc6Mjmo$3fe413a88db1bacfc4d617f7c1547bd1ea4cbd6c5d675a58e78332201f6befc6'); - -/* eyelabs */ -INSERT INTO user VALUES(2,'eyelabs',NULL,'pbkdf2:sha256:50000$sdBu3Rjm$7ab97c6d2686460b85a2a20517b7012c15ffb341ba3fef5b0f17ed8354fc38d9'); +ALTER TABLE experiment ADD COLUMN (group_id INTEGER), ADD FOREIGN KEY(group_id) REFERENCES research_group(id); CREATE TABLE research_group ( @@ -211,9 +208,6 @@ CREATE TABLE research_group ( PRIMARY KEY (id) ); -INSERT INTO research_group(id, name, tag, description) VALUES(1, 'Human Emotion Systems', 'emotion', 'Welcome to the Human Emotion Systems -laboratory`s Onni-net laboratory! The experiments that are currently underway are listed below - you can participate for as many experiments you want.'); -INSERT INTO research_group(id, name, tag, description) VALUES(2, 'Turku Eye-tracking', 'eyelabs', 'Welcome to the Turku Eyelabs -laboratory`s Onni-net laboratory! The experiments that are currently underway are listed below - you can participate for as many experiments you want.'); - CREATE TABLE user_in_group ( idgroup INTEGER, iduser INTEGER, @@ -222,8 +216,3 @@ CREATE TABLE user_in_group ( FOREIGN KEY(iduser) REFERENCES user (id) ); -INSERT INTO user_in_group VALUES (1,1, 'admin'); -INSERT INTO user_in_group VALUES (2,1, 'admin'); - -ALTER TABLE experiment ADD COLUMN (group_id INTEGER), ADD FOREIGN KEY(group_id) REFERENCES research_group(id); - diff --git a/generate_password.py b/generate_password.py new file mode 100644 index 0000000..cb63eea --- /dev/null +++ b/generate_password.py @@ -0,0 +1,10 @@ +from werkzeug.security import generate_password_hash, check_password_hash + +hash1 = 'pbkdf2:sha256:50000$6Cc6Mjmo$3fe413a88db1bacfc4d617f7c1547bd1ea4cbd6c5d675a58e78332201f6befc6' + +hash2 = 'pbkdf2:sha256:50000$vQutOphQ$9f80b3ef2b5bc2f971a40febf0d964326386e12d1b90e0f6f5d1a235f6e8093d' + +print(check_password_hash(hash1, 'password')) +print(check_password_hash(hash2, 'password')) + +print(generate_password_hash('password')) -- GitLab