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

Seed admin user on deploy #96

Open
BestLSJ opened this issue Jul 20, 2022 · 10 comments
Open

Seed admin user on deploy #96

BestLSJ opened this issue Jul 20, 2022 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@BestLSJ
Copy link

BestLSJ commented Jul 20, 2022

Add a REST POST endpoint that achieves the same functionality as /api/v1/users/config/init/ after deployment. This will make it easier to automate deployments.

@dabeeeenster
Copy link
Contributor

Hi @BestLSJ - I'm not sure how else you would achieve this? The call to init is there to seed the user?

@BestLSJ
Copy link
Author

BestLSJ commented Jul 20, 2022

Hi @dabeeeenster

Thanks for your quick reply.

I'm working on a way to deploy flagsmith fully automatically, and I can't seem find a way to seed the admin user without visiting init manually a browser.

I'd like a way to do this more programmatically, and having it as part of the flagsmith helm chart just seemed intuitive.

@dabeeeenster
Copy link
Contributor

Ah interesting point. Would a REST interface to do this achieve what you are looking for?

@BestLSJ
Copy link
Author

BestLSJ commented Jul 20, 2022

I guess it would.

EDIT: I did figure out how to make a POST request to Init, but it would be greatly appreciated if there was a simpler way.

@dabeeeenster
Copy link
Contributor

it would be greatly appreciated if there was a simpler way.

How could we make it simpler?

@BestLSJ
Copy link
Author

BestLSJ commented Jul 20, 2022

How could we make it simpler?

First you have to make a get request to get the csrfmiddlewaretoken and you have to extract this token from an html response. In principle you could make an endpoint to just get the token, or remove the need for the token all together.

Furthermore documenting the POST request would also greatly help. I had to use fiddler and decrypt the http requests to figure out the formatting schema. And only by being lucky with an error message did I learn needed the Referer header as well.

@dabeeeenster
Copy link
Contributor

Ah ok understood. Will update description and add to backlog!

@dabeeeenster dabeeeenster added the enhancement New feature or request label Jul 20, 2022
@francoisauclair911
Copy link

Also this helm chart apparently implements such feature, so maybe that can be used as inspiration
https://github.com/one-acre-fund/oaf-public-charts/blob/main/charts/flagsmith/templates/api-deploy.yaml

Alternatively we could have a section in the template to run commands and use this to seed a new admin user

@matthewelwell
Copy link
Contributor

Related PR: Flagsmith/flagsmith#2205

@matthewelwell
Copy link
Contributor

Development on this feature is complete but we need to add documentation, particularly for k8s installs.

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

6 participants