|
2 | 2 | [id="using-the-api-to-create-first-user"] |
3 | 3 | = Using the API to create the first user |
4 | 4 |
|
5 | | -Use the following procedure to create the first user in your {productname} organization. |
| 5 | +You can use the API to create the first user with administrative privileges for your registry. |
6 | 6 |
|
7 | 7 | .Prerequisites |
8 | 8 |
|
9 | | -* The config option `FEATURE_USER_INITIALIZE` must be set to `True`. |
10 | | -* No users can already exist in the database. |
11 | | -
|
12 | | -.Procedure |
13 | | - |
14 | | -[NOTE] |
15 | | -==== |
16 | | -This procedure requests an OAuth token by specifying `"access_token": true`. |
17 | | -==== |
18 | | - |
19 | | -. Open your {productname} configuration file and update the following configuration fields: |
| 9 | +* You have set `FEATURE_USER_INITIALIZE: true` and established a superuser in your `config.yaml` file. For example: |
20 | 10 | + |
21 | 11 | [source,yaml] |
22 | 12 | ---- |
| 13 | +# ... |
23 | 14 | FEATURE_USER_INITIALIZE: true |
24 | 15 | SUPER_USERS: |
25 | | - - quayadmin |
| 16 | + - <username> |
| 17 | +# .. |
26 | 18 | ---- |
27 | | - |
28 | | -. Stop the {productname} service by entering the following command: |
29 | 19 | + |
30 | | -[source,terminal] |
31 | | ----- |
32 | | -$ sudo podman stop quay |
33 | | ----- |
| 20 | +If you did not configure these settings upon registry creation, and need to re-configure your registry to enable these settings, see. . . |
34 | 21 |
|
35 | | -. Start the {productname} service by entering the following command: |
36 | | -+ |
37 | | -[source,terminal] |
38 | | ----- |
39 | | -$ sudo podman run -d -p 80:8080 -p 443:8443 --name=quay -v $QUAY/config:/conf/stack:Z -v $QUAY/storage:/datastorage:Z {productrepo}/{quayimage}:{productminv} |
40 | | ----- |
| 22 | +* You have not created a user by using the {productname} UI. |
41 | 23 |
|
42 | | -. Run the following `CURL` command to generate a new user with a username, password, email, and access token: |
| 24 | +.Procedure |
| 25 | + |
| 26 | +. On the command-line interface, generate a new user with a username, password, email, and access token by entering the following `CURL` command: |
43 | 27 | + |
44 | 28 | [source,terminal] |
45 | 29 | ---- |
46 | | -$ curl -X POST -k http://quay-server.example.com/api/v1/user/initialize --header 'Content-Type: application/json' --data '{ "username": "quayadmin", "password":"quaypass12345", "email": "quayadmin@example.com", "access_token": true}' |
| 30 | +$ curl -X POST -k http:/</quay-server.example.com>/api/v1/user/initialize --header 'Content-Type: application/json' --data '{ "username": "<username>", "password":"<password>", "email": "<email>@example.com", "access_token": true}' |
47 | 31 | ---- |
48 | 32 | + |
49 | 33 | If successful, the command returns an object with the username, email, and encrypted password. For example: |
50 | 34 | + |
51 | 35 | [source,yaml] |
52 | 36 | ---- |
53 | | -{"access_token":"6B4QTRSTSD1HMIG915VPX7BMEZBVB9GPNY2FC2ED", "email":" [email protected]","encrypted_password":" 1nZMLH57RIE5UGdL/yYpDOHLqiNCgimb6W9kfF8MjZ1xrfDpRyRs9NUnUuNuAitW","username":"quayadmin"} # gitleaks:allow |
| 37 | +{"access_token":"6B4QTRSTSD1HMIG915VPX7BMEZBVB9GPNY2FC2ED", "email":" [email protected]","encrypted_password":" <password>","username":"quayadmin"} # gitleaks:allow |
54 | 38 | ---- |
55 | 39 | + |
56 | | -If a user already exists in the database, an error is returned: |
| 40 | +If a user already exists in the database, an error is returned. For example:: |
57 | 41 | + |
58 | 42 | [source,terminal] |
59 | 43 | ---- |
60 | 44 | {"message":"Cannot initialize user in a non-empty database"} |
61 | 45 | ---- |
62 | 46 | + |
63 | | -If your password is not at least eight characters or contains whitespace, an error is returned: |
| 47 | +If your password is not at least eight characters or contains whitespace, an error is returned. For example: |
64 | 48 | + |
65 | 49 | [source,terminal] |
66 | 50 | ---- |
67 | 51 | {"message":"Failed to initialize user: Invalid password, password must be at least 8 characters and contain no whitespace."} |
68 | 52 | ---- |
69 | 53 |
|
70 | | -. Log in to your {productname} deployment by entering the following command: |
| 54 | +. You can log in to your registry by navigating to the UI or by leveraging Podman on the CLI. |
| 55 | + |
| 56 | +.. Log in to the registry by running the following `podman` command: |
71 | 57 | + |
72 | 58 | [source,terminal] |
73 | 59 | ---- |
74 | | -$ sudo podman login -u quayadmin -p quaypass12345 http://quay-server.example.com --tls-verify=false |
| 60 | +$ podman login -u <username> -p <password> http://<quay-server.example.com> |
75 | 61 | ---- |
76 | 62 | + |
77 | 63 | .Example output |
|
0 commit comments