21910: Trust system root token even if IssueTrustedTokens == false.
[arvados.git] / doc / admin / user-management-cli.html.textile.liquid
1 ---
2 layout: default
3 navsection: admin
4 title: User management at the CLI
5 ...
6 {% comment %}
7 Copyright (C) The Arvados Authors. All rights reserved.
8
9 SPDX-License-Identifier: CC-BY-SA-3.0
10 {% endcomment %}
11
12 Initial setup
13
14 <pre>
15 ARVADOS_API_HOST={{ site.arvados_api_host }}
16 ARVADOS_API_TOKEN=1234567890qwertyuiopasdfghjklzxcvbnm1234567890zzzz
17 </pre>
18
19 In these examples, @zzzzz-tpzed-3kz0nwtjehhl0u4@ is the sample user account.  Replace with the uuid of the user you wish to manipulate.
20
21 See "user management":{{site.baseurl}}/admin/user-management.html for an overview of how to use these commands.
22
23 h3. Setup a user
24
25 This creates a default git repository and VM login.  Enables user to self-activate using Workbench.
26
27 <notextile>
28 <pre><code>$ <span class="userinput">arv user setup --uuid zzzzz-tpzed-3kz0nwtjehhl0u4</span>
29 </code></pre>
30 </notextile>
31
32
33 h3. Deactivate user
34
35 <notextile>
36 <pre><code>$ <span class="userinput">arv user unsetup --uuid zzzzz-tpzed-3kz0nwtjehhl0u4</span>
37 </code></pre>
38 </notextile>
39
40
41 When deactivating a user, you may also want to "reassign ownership of their data":{{site.baseurl}}/admin/reassign-ownership.html .
42
43 h3(#activate-user). Directly activate user
44
45 <notextile>
46 <pre><code>$ <span class="userinput">arv user update --uuid "zzzzz-tpzed-3kz0nwtjehhl0u4" --user '{"is_active":true}'</span>
47 </code></pre>
48 </notextile>
49
50 Note: this bypasses user agreements checks, and does not set up the user with a default git repository or VM login.
51
52 h3(#create-token). Create a token for a user
53
54 As an admin, you can create tokens for other users.
55
56 <notextile>
57 <pre><code>$ <span class="userinput">arv api_client_authorization create --api-client-authorization '{"owner_uuid": "zzzzz-tpzed-fr97h9t4m5jffxs"}'</span>
58 {
59  "href":"/api_client_authorizations/zzzzz-gj3su-yyyyyyyyyyyyyyy",
60  "kind":"arvados#apiClientAuthorization",
61  "etag":"9yk144t0v6cvyp0342exoh2vq",
62  "uuid":"zzzzz-gj3su-yyyyyyyyyyyyyyy",
63  "owner_uuid":"zzzzz-tpzed-fr97h9t4m5jffxs",
64  "created_at":"2020-03-12T20:36:12.517375422Z",
65  "modified_by_client_uuid":null,
66  "modified_by_user_uuid":null,
67  "modified_at":null,
68  "api_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
69  "created_by_ip_address":null,
70  "expires_at":null,
71  "last_used_at":null,
72  "last_used_by_ip_address":null,
73  "scopes":["all"]
74 }
75 </code></pre>
76 </notextile>
77
78
79 To get the token string, combine the values of @uuid@ and @api_token@ in the form "v2/$uuid/$api_token".  In this example the string that goes in @ARVADOS_API_TOKEN@ would be:
80
81 <pre>
82 ARVADOS_API_TOKEN=v2/zzzzz-gj3su-yyyyyyyyyyyyyyy/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
83 </pre>
84
85 h3(#delete-token). Delete a single token
86
87 As a user or admin, if you need to revoke a specific, known token, for example a token that may have been leaked to an unauthorized party, you can delete it at the command line.
88
89 First, determine the token UUID.  If it is a "v2" format token (starts with "v2/") then the token UUID is middle section between the two slashes.   For example:
90
91 <pre>
92 v2/zzzzz-gj3su-yyyyyyyyyyyyyyy/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
93 </pre>
94
95 the UUID is "zzzzz-gj3su-yyyyyyyyyyyyyyy" and you can skip to the next step.
96
97 If you have a "bare" token (only the secret part) then, as an admin, you need to query the token to get the uuid:
98
99 <pre>
100 $ ARVADOS_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx arv --format=uuid api_client_authorization current
101 zzzzz-gj3su-yyyyyyyyyyyyyyy
102 </pre>
103
104 Now you can delete the token:
105
106 <pre>
107 $ ARVADOS_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx arv api_client_authorization delete --uuid zzzzz-gj3su-yyyyyyyyyyyyyyy
108 </pre>
109
110 h3(#delete-all-tokens). Delete all tokens belonging to a user
111
112 First, "obtain a valid token for the user.":#create-token
113
114 Then, use that token to get all the user's tokens, and delete each one:
115
116 <pre>
117 $ ARVADOS_API_TOKEN=xxxxtoken-belonging-to-user-whose-tokens-will-be-deletedxxxxxxxx ; \
118 for uuid in $(arv --format=uuid api_client_authorization list) ; do \
119 arv api_client_authorization delete --uuid $uuid ; \
120 done
121 </pre>
122
123 h2. Adding Permissions
124
125 h3(#vm-login). VM login
126
127 Give @$user_uuid@ permission to log in to @$vm_uuid@ as @$target_username@ and make sure that @$target_username@ is a member of the @docker@ group
128
129 <pre>
130 user_uuid=xxxxxxxchangeme
131 vm_uuid=xxxxxxxchangeme
132 target_username=xxxxxxxchangeme
133
134 read -rd $'\000' newlink <<EOF; arv link create --link "$newlink"
135 {
136 "tail_uuid":"$user_uuid",
137 "head_uuid":"$vm_uuid",
138 "link_class":"permission",
139 "name":"can_login",
140 "properties":{"username":"$target_username", "groups": [ "docker" ]}
141 }
142 EOF
143 </pre>