Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
d2d4b6c7
Commit
d2d4b6c7
authored
Sep 14, 2020
by
Manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed add_users.py s.t. it consumes a json file instead of hardcoded values
parent
9c1ccb14
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
.gitignore
.gitignore
+2
-0
add_users.py
src/rest-gateway/app/add_users.py
+16
-2
No files found.
.gitignore
View file @
d2d4b6c7
...
...
@@ -13,3 +13,5 @@ src/modules/certificate/articonf1.crt
src/modules/certificate/articonf1-chain.crt
src/modules/security/regular_user_credentials.json
src/modules/security/default_users.json
src/rest-gateway/app/add_users.py
View file @
d2d4b6c7
# add modules folder to interpreter path
import
sys
import
os
import
json
import
prance
from
pathlib
import
Path
from
typing
import
Dict
,
Any
...
...
@@ -10,7 +11,20 @@ if os.path.exists(modules_path):
sys
.
path
.
insert
(
1
,
modules_path
)
from
services.user_service
import
UserService
from
env_info
import
is_running_locally
if
__name__
==
"__main__"
:
UserService
.
add
(
"regular@articonf1.itec.aau.at"
,
"GBILLjaZE0Wyea9Y9ByS"
,
role
=
"u"
)
UserService
.
add
(
"root@articonf1.itec.aau.at"
,
"CJG6zD0mAjvo5zdVBftY"
,
role
=
"a"
)
\ No newline at end of file
if
is_running_locally
():
path
=
f
'{modules_path}/security/default_users.json'
else
:
path
=
'/srv/articonf/default_users.json'
with
open
(
path
,
"r"
)
as
file_handler
:
content
=
file_handler
.
read
()
users
=
json
.
loads
(
content
)
for
user
in
users
:
if
"username"
in
user
and
"password"
in
user
and
"role"
in
user
:
UserService
.
add
(
user
[
"username"
],
user
[
"password"
],
role
=
user
[
"role"
])
else
:
print
(
f
"Missing field in user object, required=(username, password, role), given=({user.keys()})"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment