Skip to content

Commit 5fed01c

Browse files
committed
Merge branch 'main' into branding
2 parents 3839ee9 + ebe1b56 commit 5fed01c

File tree

26 files changed

+1468
-3647
lines changed

26 files changed

+1468
-3647
lines changed

.github/workflows/stale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
# v5.1.0 has a weird bug that makes stalebot add then remove its own label
1515
# https://github.com/actions/stale/pull/775
16-
- uses: actions/stale@v6.0.0
16+
- uses: actions/stale@v7.0.0
1717
with:
1818
stale-issue-label: "stale"
1919
stale-pr-label: "stale"

coderd/audit/request.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func InitRequest[T Auditable](w http.ResponseWriter, p *RequestParams) (*Request
157157
}
158158

159159
ip := parseIP(p.Request.RemoteAddr)
160-
err := p.Audit.Export(ctx, database.AuditLog{
160+
auditLog := database.AuditLog{
161161
ID: uuid.New(),
162162
Time: database.Now(),
163163
UserID: httpmw.APIKey(p.Request).UserID,
@@ -171,9 +171,13 @@ func InitRequest[T Auditable](w http.ResponseWriter, p *RequestParams) (*Request
171171
StatusCode: int32(sw.Status),
172172
RequestID: httpmw.RequestID(p.Request),
173173
AdditionalFields: p.AdditionalFields,
174-
})
174+
}
175+
err := p.Audit.Export(ctx, auditLog)
175176
if err != nil {
176-
p.Log.Error(logCtx, "export audit log", slog.Error(err))
177+
p.Log.Error(logCtx, "export audit log",
178+
slog.F("audit_log", auditLog),
179+
slog.Error(err),
180+
)
177181
return
178182
}
179183
}
@@ -192,7 +196,7 @@ func BuildAudit[T Auditable](ctx context.Context, p *BuildAuditParams[T]) {
192196
p.AdditionalFields = json.RawMessage("{}")
193197
}
194198

195-
err := p.Audit.Export(ctx, database.AuditLog{
199+
auditLog := database.AuditLog{
196200
ID: uuid.New(),
197201
Time: database.Now(),
198202
UserID: p.UserID,
@@ -206,9 +210,13 @@ func BuildAudit[T Auditable](ctx context.Context, p *BuildAuditParams[T]) {
206210
StatusCode: int32(p.Status),
207211
RequestID: p.JobID,
208212
AdditionalFields: p.AdditionalFields,
209-
})
213+
}
214+
err := p.Audit.Export(ctx, auditLog)
210215
if err != nil {
211-
p.Log.Error(ctx, "export audit log", slog.Error(err))
216+
p.Log.Error(ctx, "export audit log",
217+
slog.F("audit_log", auditLog),
218+
slog.Error(err),
219+
)
212220
return
213221
}
214222
}

docs/admin/automation.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
We recommend automating Coder deployments through the CLI. Examples include [updating templates via CI/CD pipelines](../templates/change-management.md).
44

5-
## Tokens
5+
## Authentication
66

7-
Long-lived tokens can be generated to perform actions on behalf of your user account:
8-
9-
```console
10-
coder tokens create
11-
```
7+
Coder uses authentication tokens to grant machine users access to the REST API. Follow the [Authentication](../api/authentication.md) page to learn how to generate long-lived tokens.
128

139
## CLI
1410

@@ -23,14 +19,13 @@ coder workspaces ls
2319

2420
## REST API
2521

26-
You can use tokens with the Coder's REST API using the `Coder-Session-Token` HTTP header.
22+
You can review the [API reference](../api/index.md) to find the necessary routes and payload. Alternatively, you can enable the [Swagger](https://swagger.io/) endpoint to read the documentation and do requests against the API:
2723

2824
```console
29-
curl 'https://dev.coder.com/api/v2/workspaces' \
30-
-H 'Coder-Session-Token: *****'
25+
coder server --swagger-enable
3126
```
3227

33-
> At this time, we do not publish an API reference. However, [codersdk](https://github.com/coder/coder/tree/main/codersdk) can be grepped to find the necessary routes and payloads.
28+
By default, the local Swagger endpoint is http://localhost:3000/swagger.
3429

3530
## Golang SDK
3631

docs/admin/users.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ This article walks you through the user roles available in Coder and creating an
66

77
Coder offers these user roles in the community edition:
88

9-
| | User Admin | Template Admin | Owner |
10-
| ------------------------------------------ | ---------- | -------------- | ----- |
11-
| Add and remove Users || ||
12-
| Manage groups (enterprise) || ||
13-
| Change User roles | | ||
14-
| Manage **ALL** Templates | |||
15-
| View, update and delete **ALL** Workspaces | |||
16-
| Execute and use **ALL** Workspaces | | ||
9+
| | Auditor | User Admin | Template Admin | Owner |
10+
| ----------------------------------------------------- | ------- | ---------- | -------------- | ----- |
11+
| Add and remove Users | || ||
12+
| Manage groups (enterprise) | || ||
13+
| Change User roles | | | ||
14+
| Manage **ALL** Templates | | |||
15+
| View, update and delete **ALL** Workspaces | | |||
16+
| Execute and use **ALL** Workspaces | | | ||
17+
| View all user operation [Audit Logs](./audit-logs.md) || | ||
1718

1819
A user may have one or more roles. All users have an implicit Member role
1920
that may use personal workspaces.

docs/api/authentication.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
# Authentication
22

3-
- API Key (CoderSessionToken)
4-
- Parameter Name: **Coder-Session-Token**, in: header.
3+
Long-lived tokens can be generated to perform actions on behalf of your user account:
4+
5+
```console
6+
coder tokens create
7+
```
8+
9+
You can use tokens with the Coder's REST API using the `Coder-Session-Token` HTTP header.
10+
11+
```console
12+
curl 'http://coder-server:8080/api/v2/workspaces' \
13+
-H 'Coder-Session-Token: *****'
14+
```

scripts/apidocgen/generate.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ go run github.com/swaggo/swag/cmd/swag@v1.8.6 init \
2727
popd
2828

2929
pushd "${APIDOCGEN_DIR}"
30-
npm ci
30+
yarn
3131

3232
# Make sure that widdershins is installed correctly.
33-
npm exec -- widdershins --version
33+
yarn exec -- widdershins --version
3434
# Render the Markdown file.
35-
npm exec -- widdershins \
35+
yarn exec -- widdershins \
3636
--user_templates "./markdown-template" \
3737
--search false \
3838
--omitHeader true \
Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
<!-- APIDOCGEN: BEGIN SECTION -->
2-
{{= data.tags.section }}# Authentication
3-
{{ for (var s in data.api.components.securitySchemes) { }}
4-
{{ var sd = data.api.components.securitySchemes[s]; }}
5-
{{? sd.type == 'apiKey' }}
6-
- API Key ({{=s}})
7-
- Parameter Name: **{{=sd.name}}**, in: {{=sd.in}}. {{=sd.description || ''}}
8-
{{?}}
9-
{{? sd.type == 'http'}}
10-
- HTTP Authentication, scheme: {{=sd.scheme}}{{? sd.description }}<br/>{{=sd.description}}{{?}}
11-
{{?}}
12-
{{? sd.type == 'oauth2'}}
13-
- oAuth2 authentication. {{=sd.description || ''}}
14-
{{ for (var f in sd.flows) { }}
15-
{{ var flow = sd.flows[f]; }}
16-
- Flow: {{=f}}
17-
{{? flow.authorizationUrl}} - Authorization URL = [{{=flow.authorizationUrl}}]({{=flow.authorizationUrl}}){{?}}
18-
{{? flow.tokenUrl}} - Token URL = [{{=flow.tokenUrl}}]({{=flow.tokenUrl}}){{?}}
19-
{{? flow.scopes && Object.keys(flow.scopes).length}}
20-
|Scope|Scope Description|
21-
|---|---|
22-
{{ for (var sc in flow.scopes) { }}|{{=sc}}|{{=data.utils.join(flow.scopes[sc])}}|
23-
{{ } /* of scopes */ }}
24-
{{?}}
25-
{{ } /* of flows */ }}
26-
{{?}}
27-
{{ } /* of securitySchemes */ }}
2+
# Authentication
3+
4+
Long-lived tokens can be generated to perform actions on behalf of your user account:
5+
6+
```console
7+
coder tokens create
8+
```
9+
10+
You can use tokens with the Coder's REST API using the `Coder-Session-Token` HTTP header.
11+
12+
```console
13+
curl 'http://coder-server:8080/api/v2/workspaces' \
14+
-H 'Coder-Session-Token: *****'
15+
```

0 commit comments

Comments
 (0)