@@ -78,38 +78,20 @@ which enables them to create new user accounts using the
78
78
[ kci_data] ( /docs/core/kci_data#creating-new-api-user-experimental ) command line
79
79
tool.
80
80
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:
86
87
87
88
```
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
110
92
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
113
95
WriteResult({ "nInserted" : 1 })
114
96
```
115
97
0 commit comments