Skip to content

Commit a0d1d12

Browse files
gctuckerJenySadadia
authored andcommitted
doc: update getting started page with create_admin_user
Update the "Getting Started" page with a sample command using the new create_admin_user script to create an initial admin user account instead of raw HTTP queries. Signed-off-by: Guillaume Tucker <[email protected]>
1 parent d6fe432 commit a0d1d12

File tree

1 file changed

+11
-29
lines changed

1 file changed

+11
-29
lines changed

doc/getting-started.md

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,38 +78,20 @@ which enables them to create new user accounts using the
7878
[kci_data](/docs/core/kci_data#creating-new-api-user-experimental) command line
7979
tool.
8080

81-
So let's start by creating the initial admin user account. First, get an
82-
encrypted hash for your password with the `/hash` API endpoint. This uses a
83-
`POST` method for security reasons. It doesn't require any authentication and
84-
it doesn't make any changes to the database. For example, if the password is
85-
`hello`:
81+
So let's start by creating the initial admin user account. This can be done
82+
with the
83+
[`create_admin_user`](https://github.com/kernelci/kernelci-api/blob/main/create_admin_user)
84+
tool provided in the `kernelci-api` repository. Call it with the name of the
85+
admin user you want to create such as `admin`, then enter the admin password
86+
when prompted:
8687

8788
```
88-
curl \
89-
-X POST \
90-
-H 'Content-Type: application/json' \
91-
-d '{"password": "hello"}' \
92-
http://localhost:8001/hash
93-
"$2b$12$CpJZx5ooxM11bCFXT76/z.o6HWs2sPJy4iP8.xCZGmM8jWXUXJZ4K"
94-
```
95-
96-
Then create the admin user entry in the database manually via `docker-compose
97-
exec` to access the database container. You will need to provide the password
98-
hash from the previous command with special characters escaped. In particular,
99-
`$` characters need to be escaped with `\$`. For example:
100-
101-
```
102-
$ docker-compose exec db /bin/mongo kernelci --eval \
103-
"db.user.insert({\
104-
username: 'admin', \
105-
hashed_password: '\$2b\$12\$VtfVij6zz20F/Qr0Ri18O.11.0LJMMXyJxAJAHQbKU0jC96eo2fr.', \
106-
active: true, \
107-
is_admin: 1\
108-
})"
109-
MongoDB shell version v5.0.3
89+
$ ./create_admin_user admin
90+
Please enter the password: hello
91+
MongoDB shell version v5.0.9
11092
connecting to: mongodb://127.0.0.1:27017/kernelci?compressors=disabled&gssapiServiceName=mongodb
111-
Implicit session: session { "id" : UUID("84a62d1b-4b06-4631-8227-413964826100") }
112-
MongoDB server version: 5.0.3
93+
Implicit session: session { "id" : UUID("7de03dfa-4e3c-4103-8c44-4728fbc5f8c0") }
94+
MongoDB server version: 5.0.9
11395
WriteResult({ "nInserted" : 1 })
11496
```
11597

0 commit comments

Comments
 (0)