Skip to content

Commit 72fb716

Browse files
committed
docs: switch admin setup to startup bootstrap
Update documentation to describe automatic initial admin creation via KCI_INITIAL_PASSWORD and optional identity env vars. Remove references to manual setup_admin_user flow and delete scripts/setup_admin_user. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent c008b55 commit 72fb716

3 files changed

Lines changed: 15 additions & 40 deletions

File tree

doc/api-details.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ user management.
4444

4545
### Create an admin user
4646

47-
The very first admin user needs to be created with
48-
[`api.admin`](https://github.com/kernelci/kernelci-api/blob/main/api/admin.py)
49-
tool provided in the `kernelci-api` repository.
50-
[Here](../local-instance/#create-an-admin-user-account) is a guide to
51-
setup an admin user. We can use this admin user to create other user accounts.
47+
On startup, if no admin exists yet, the API automatically creates the first
48+
admin user from environment variables:
49+
50+
- `KCI_INITIAL_PASSWORD` (required for first bootstrap)
51+
- `KCI_INITIAL_ADMIN_USERNAME` (optional, default: `admin`)
52+
- `KCI_INITIAL_ADMIN_EMAIL` (optional, default: `<username>@kernelci.org`)
53+
54+
[Here](../local-instance/#bootstrap-the-initial-admin-user) is a guide to
55+
bootstrap an admin user. You can use this admin account to create other user
56+
accounts.
5257

5358

5459
### Invite user (Admin only, required)

doc/local-instance.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ show:
7676
kernelci-api | INFO: 172.20.0.1:49228 - "GET / HTTP/1.1" 200 OK
7777
```
7878

79-
### Create an admin user account
79+
### Bootstrap the initial admin user
8080

8181
Some parts of the API don't require any authentication, like in the example
8282
above with the root `/` endpoint and most `GET` requests to retrieve data.
@@ -85,7 +85,7 @@ by authenticated users. This will be required to run a full pipeline or to
8585
subscribe to the pub/sub interface. Then some users have administrator rights,
8686
which enables them to create new user accounts.
8787

88-
On startup, the API now bootstraps the first admin account automatically if no
88+
On startup, the API bootstraps the first admin account automatically if no
8989
admin exists yet:
9090

9191
* `KCI_INITIAL_PASSWORD` must be set, otherwise startup fails with an error
@@ -97,29 +97,14 @@ admin exists yet:
9797
After the first admin exists, `KCI_INITIAL_PASSWORD` is no longer required for
9898
startup.
9999

100-
You can still create an admin manually with the
101-
[`api.admin`](https://github.com/kernelci/kernelci-api/blob/main/api/admin.py)
102-
tool (wrapper: `setup_admin_user`), for example:
103-
104-
```
105-
$ ./scripts/setup_admin_user --email EMAIL
106-
Creating kernelci-api_api_run ... done
107-
Password for user 'admin':
108-
Creating admin user...
109-
```
110-
111-
> **Note** Strictly speaking, only the `db` service needs to be running in
112-
> order to use this tool. In fact it can also be used with any other MongoDB
113-
> instance such as an Atlas account using the `--mongo` command line argument.
114-
115100
> **Note** For more details about how to create users via the raw API, see the
116101
> [API documentation](../api-details/#users)
117102
118103
### Create an admin API token
119104

120-
Then to get an API token, the `/user/login` API endpoint can be used. For example,
121-
to create an admin token with the same user name and password as used
122-
previously:
105+
Then to get an API token, the `/user/login` API endpoint can be used. For
106+
example, to create an admin token with the same username and password set in
107+
`KCI_INITIAL_PASSWORD`:
123108

124109
```
125110
$ curl -X 'POST' \

scripts/setup_admin_user

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)