Is your feature request related to a problem? Please describe.
It is easy and user-friendly to add a user via List Users page. I suppose the command superset fab createuser will achieve the same goal with a prompt. But I'm frustrated when I try to create a batch of users. For example, I want to add four different users as public role with default password. Repeatedly filling forms is not a good idea.
I guess the user management is related to .superset\superset.db. Connect to the database and insert values should do the job.
Describe the solution you'd like
An admin user could download a sample csv/xlsx(with header). The admin will fill the table or write some code snippets to generate the correct csv/xlsx(with header).
The admin upload the csv through a superset page. After the process of the csv, the page is refreshed and lists all the users(or part of it with N users in total are created message printed).
e.g.
| First Name | Last Name | User Name | Active | Email | Role | Password|
| :------------- | :----------: | -----------: |:------------- | :----------: | -----------: | -----------: |
| Frank | Scarlet | Scarlet | 1 | [email protected] | Public | P@ssword |
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Issue-Label Bot is automatically applying the label #enhancement to this issue, with a confidence of 0.79. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
@FrankScarlet why don't you just write a script that calls flask fab create-user? You can pass flags instead of following the prompts, eg
flask fab create-user --role Public --username user1 --firstname name1 --lastname name2 --email [email protected] --password cool-password
@FrankScarlet why don't you just write a script that calls
flask fab create-user? You can pass flags instead of following the prompts, egflask fab create-user --role Public --username user1 --firstname name1 --lastname name2 --email [email protected] --password cool-password
Thanks a lot. I tried superset fab create-user. But I thought it only works in an interactive style.
With your answer I can come up with a script to achieve my goal.
I am still thinking about possible problems in users management. So I won't close this issue immediately
You can also do it through the ORM
@nytai --role Public seems Great.
But I find that the combination of sql_lab, Gamma, Public suits my need. I tried to pass multiple flags but failed.
```shell
Error: Got unexpected extra arguments
````
It seems like that I should create a new role with adding the permissions all together. Is there any way to quickly duplicate a role? I would like to duplicate a Gamma role and add permission of sql_lab and public manually.
Gamma role owns so many permissions. It is a little bit annoying to add permission again and again.
@FrankScarlet,
Like @mistercrunch suggested you can use SQLAlchemy (ORM) to create user's with multiple roles, here's what the cli is calling behind the scenes: https://github.com/dpgaspar/Flask-AppBuilder/blob/master/flask_appbuilder/security/sqla/manager.py#L185
Closing this issue as it it appears all questions have been addressed
Add a related issue.
https://github.com/apache/incubator-superset/issues/3083
I think the bs4 post method mentioned in this issue is also very helpful.
users = [{
'first_name': 'fname',
'last_name':'lname',
'username': 'cplc',
'email': '[email protected]',
'password': 'cplcapp',
'conf_password': 'cplcapp',
'roles': ['2', '4', '6']
}] # It's related to the roles db(ID i guess). the `roles` list correponds to [ 'Public','Gamma','sql_lab']
for user in users:
payload = {'first_name': user['first_name'],
'last_name': user['last_name'],
'username': user['username'],
'email': user['email'],
'active': True,
'conf_password': user['password'],
'password': user['password'],
'roles': user['roles']
}
print(superset.post(url_path='users/add', json=payload))
On the other hand, did the SQLAlchemy (ORM) means sth like the method given at the beginning of the above issue
create_engine('superset.db') # connect to the role database
insert into some values according to a csv
Add a related issue.
3083
I think the bs4 post method mentioned in this issue is also very helpful.
users = [{ 'first_name': 'fname', 'last_name':'lname', 'username': 'cplc', 'email': '[email protected]', 'password': 'cplcapp', 'conf_password': 'cplcapp', 'roles': ['2', '4', '6'] }] # It's related to the roles db(ID i guess). the `roles` list correponds to [ 'Public','Gamma','sql_lab'] for user in users: payload = {'first_name': user['first_name'], 'last_name': user['last_name'], 'username': user['username'], 'email': user['email'], 'active': True, 'conf_password': user['password'], 'password': user['password'], 'roles': user['roles'] } print(superset.post(url_path='users/add', json=payload))
Ooops, is this method limited? I test a json which includes three users but only the first user was added.
users=[{}, {} ...]