forked from certat/intelmq-webinput-csv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webinput-adduser
executable file
·34 lines (27 loc) · 1.16 KB
/
webinput-adduser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
#
# SPDX-FileCopyrightText: 2021 Birger Schacht
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# IntelMQ-API adduser command
import argparse
import getpass
import os
import sys
import webinput_session.session
import webinput_session.config
session_config: webinput_session.config.Config = webinput_session.config.Config(os.environ.get("WEBINPUT_CSV_SESSION_CONFIG"))
parser = argparse.ArgumentParser(description='Add a user account to the Webinput CSV session store.')
parser.add_argument('--user', required=True, help='The username of the account.', type=str)
parser.add_argument('--password', required=False, help='The password of the account.', type=str)
args = parser.parse_args()
if session_config.session_store is None:
print("Could not add user- no session store configured in configuration!", file=sys.stderr)
exit(1)
session_store = webinput_session.session.SessionStore(str(session_config.session_store), session_config.session_duration)
if args.password is None:
password = getpass.getpass()
else:
password = args.password
session_store.add_user(args.user, password)
print(f"Added user {args.user} to Webinput CSV session file.")