Flagsmith/flagsmith-charts

Seed admin user on deploy

BestLSJ opened this issue · 10 comments

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.

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

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.

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

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.

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

How could we make it simpler?

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.

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

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

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