Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita272843

Browse files
authored
docs: add API key scopes documentation (#20742)
## DescriptionAdds a brief section to the API & Session Tokens documentationexplaining API key scopes.## Changes- Added "API Key Scopes" section to`docs/admin/users/sessions-tokens.md`- Includes overview of scope functionality and security benefits- Documents scope format (`resource:action`) and wildcard usage- Provides CLI examples for creating scoped tokens- Lists common scope examples with descriptions## MotivationUsers need documentation on how to create and use scoped API tokens forimproved security by limiting token permissions to only necessaryoperations.## Testing- Reviewed documentation formatting- Verified markdown structure- Confirmed examples are accurate
1 parent16b8e60 commita272843

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

‎docs/admin/users/sessions-tokens.md‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,54 @@ You can use the
8080
[`CODER_MAX_TOKEN_LIFETIME`](https://coder.com/docs/reference/cli/server#--max-token-lifetime)
8181
server flag to set the maximum duration for long-lived tokens in your
8282
deployment.
83+
84+
##API Key Scopes
85+
86+
API key scopes allow you to limit the permissions of a token to specific operations. By default, tokens are created with the`all` scope, granting full access to all actions the user can perform. For improved security, you can create tokens with limited scopes that restrict access to only the operations needed.
87+
88+
Scopes follow the format`resource:action`, where`resource` is the type of object (like`workspace`,`template`, or`user`) and`action` is the operation (like`read`,`create`,`update`, or`delete`). You can also use wildcards like`workspace:*` to grant all permissions for a specific resource type.
89+
90+
###Creating tokens with scopes
91+
92+
You can specify scopes when creating a token using the`--scope` flag:
93+
94+
```sh
95+
# Create a token that can only read workspaces
96+
coder tokens create --name"readonly-token" --scope"workspace:read"
97+
98+
# Create a token with multiple scopes
99+
coder tokens create --name"limited-token" --scope"workspace:read" --scope"template:read"
100+
```
101+
102+
Common scope examples include:
103+
104+
-`workspace:read` - View workspace information
105+
-`workspace:*` - Full workspace access (create, read, update, delete)
106+
-`template:read` - View template information
107+
-`api_key:read` - View API keys (useful for automation)
108+
-`application_connect` - Connect to workspace applications
109+
110+
For a complete list of available scopes, see the API reference documentation.
111+
112+
###Allow lists (advanced)
113+
114+
For additional security, you can combine scopes with allow lists to restrict tokens to specific resources. Allow lists let you limit a token to only interact with particular workspaces, templates, or other resources by their UUID:
115+
116+
```sh
117+
# Create a token limited to a specific workspace
118+
coder tokens create --name"workspace-token" \
119+
--scope"workspace:read" \
120+
--allow"workspace:a1b2c3d4-5678-90ab-cdef-1234567890ab"
121+
```
122+
123+
**Important:** Allow lists are exclusive - the token can**only** perform actions on resources explicitly listed. In the example above, the token can only read the specified workspace and cannot access any other resources (templates, organizations, other workspaces, etc.). To maintain access to other resources, you must explicitly add them to the allow list:
124+
125+
```sh
126+
# Token that can read one workspace AND access templates and user info
127+
coder tokens create --name"limited-token" \
128+
--scope"workspace:read" --scope"template:*" --scope"user:read" \
129+
--allow"workspace:a1b2c3d4-5678-90ab-cdef-1234567890ab" \
130+
--allow"template:*" \
131+
--allow"user:*" \
132+
... etc
133+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp