Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] API / CLI with documentation #44

Closed
flying-sausages opened this issue May 23, 2020 · 5 comments
Closed

[Feature Request] API / CLI with documentation #44

flying-sausages opened this issue May 23, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@flying-sausages
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
I would like to integrate Mango into an installer toolset and would like to integrate mango's user management system into the toolset's, therefore being able to create users, change passwords and delete users.

Describe the solution you'd like
An API/CLI access to make these changes would be very useful. This goes for more than just user management.

Additional context
Nextcloud provides the occ command, The Lounge provides the thelounge CLI tool, etc. These tools allow admins to do user management on the command line, and use those commands within scripts for automation. Currently I would opt for doing SQL into the mango.db but nobody likes SQL...

@flying-sausages flying-sausages added the enhancement New feature or request label May 23, 2020
@flying-sausages flying-sausages changed the title [Feature Request] API / CLI documentation for external access [Feature Request] API / CLI with documentation May 23, 2020
@hkalexling
Copy link
Member

May I know the use case of this? Sorry, I don't understand the "installer toolset" you mentioned. Is it a script you wrote that installs Mango and creates a user for you automatically?

Actually the Mango frontend talks to the server using a set of APIs (see https://github.com/hkalexling/Mango/blob/master/src/routes/api.cr) but they are not documented, because Mango is still in early development and some APIs might be updated/removed in future releases. I suppose we can have a section in the Wiki to document some commonly used APIs. Let me know what you think!

@flying-sausages
Copy link
Collaborator Author

This would be part of swizzin. The tool can add users to the server and create accounts for them within the user management systems of other applications, as well as make sure their passwordsa re in sync. I mainly need to set the admin username and password on install to be the same as the master user who is installing it.

@hkalexling
Copy link
Member

hkalexling commented May 24, 2020

Thanks for the clarification.

I took a look at your PR draft, and it looks like you are able to parse the initial password from stdout. With the initial username and password, you can call the login API, retrieve the token from cookies, and then use the token to create/delete users. These can be easily done with a few curl commands.

It would definitely work, but I am not sure if we should do this. Parsing password from stdout feels hacky, and it would be much more robust if we can do something like

mango adduser --username admin --password password

in the CLI. But you will have to wait for the next release if you prefer the CLI option.

@flying-sausages
Copy link
Collaborator Author

Happy to wait for this and patch it into swizzin later if the PR gets accepted before it :)

@hkalexling
Copy link
Member

The requested CLI tool is added in v0.5.0. You can run mango admin user --help to see the detailed help message. Here are some examples:

# list the users
mango admin user list

# create a new user with admin access
mango admin user add -u new_user -p 123456 --admin

# rename the user
mango admin user update new_user -u new_name --admin

# remove admin access
mango admin user update new_name

# delete the user
mango admin user delete new_name

Thanks for the feature request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants