Skip to content

Commit 40d7fd1

Browse files
committed
feat(oauth2): add frontend UI for client credentials applications
- Add ClientCredentialsAppForm and ClientCredentialsAppRow components - Update API schemas to include created_at, grant_types, and user_id fields - Add dedicated pages for creating and managing client credentials apps - Update sidebar navigation and routing for OAuth2 client credentials - Enhance OAuth2AppPageView with user ownership information display Change-Id: I3271c7fb995d7225dd6cc830066fa2c8cb29720a Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 3f1495c commit 40d7fd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2163
-300
lines changed

.claude/docs/TESTING.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,23 @@ coderd/
6262

6363
### Running Tests
6464

65-
| Command | Purpose |
66-
|---------|---------|
67-
| `make test` | Run all Go tests |
68-
| `make test RUN=TestFunctionName` | Run specific test |
69-
| `go test -v ./path/to/package -run TestFunctionName` | Run test with verbose output |
70-
| `make test-postgres` | Run tests with Postgres database |
71-
| `make test-race` | Run tests with Go race detector |
72-
| `make test-e2e` | Run end-to-end tests |
65+
| Command | Purpose |
66+
|------------------------------------------------------|----------------------------------|
67+
| `make test` | Run all Go tests |
68+
| `make test PACKAGE=./pkg/...` | Run tests for specific package |
69+
| `make test RUN=TestFunctionName` | Run specific test |
70+
| `make test PACKAGE=./pkg/... RUN=TestFunctionName` | Run specific test in package |
71+
| `go test -v ./path/to/package -run TestFunctionName` | Run test with verbose output |
72+
| `make test-postgres` | Run tests with Postgres database |
73+
| `make test-race` | Run tests with Go race detector |
74+
| `make test-e2e` | Run end-to-end tests |
7375

7476
### Frontend Testing
7577

76-
| Command | Purpose |
77-
|---------|---------|
78-
| `pnpm test` | Run frontend tests |
79-
| `pnpm check` | Run code checks |
78+
| Command | Purpose |
79+
|--------------|--------------------|
80+
| `pnpm test` | Run frontend tests |
81+
| `pnpm check` | Run code checks |
8082

8183
## Common Testing Issues
8284

@@ -207,6 +209,7 @@ func BenchmarkFunction(b *testing.B) {
207209
```
208210

209211
Run benchmarks with:
212+
210213
```bash
211214
go test -bench=. -benchmem ./package/path
212215
```

.claude/docs/WORKFLOWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@
104104
### Test Execution
105105

106106
- Run full test suite: `make test`
107+
- Run specific package: `make test PACKAGE=./coderd/oauth2/...`
107108
- Run specific test: `make test RUN=TestFunctionName`
109+
- Run specific test in package: `make test PACKAGE=./coderd/oauth2/... RUN=TestFunctionName`
108110
- Run with Postgres: `make test-postgres`
109111
- Run with race detector: `make test-race`
110112
- Run end-to-end tests: `make test-e2e`

CLAUDE.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@
77

88
## 🚀 Essential Commands
99

10-
| Task | Command | Notes |
11-
|-------------------|--------------------------|----------------------------------|
12-
| **Development** | `./scripts/develop.sh` | ⚠️ Don't use manual build |
13-
| **Build** | `make build` | Fat binaries (includes server) |
14-
| **Build Slim** | `make build-slim` | Slim binaries |
15-
| **Test** | `make test` | Full test suite |
16-
| **Test Single** | `make test RUN=TestName` | Faster than full suite |
17-
| **Test Postgres** | `make test-postgres` | Run tests with Postgres database |
18-
| **Test Race** | `make test-race` | Run tests with Go race detector |
19-
| **Lint** | `make lint` | Always run after changes |
20-
| **Generate** | `make gen` | After database changes |
21-
| **Format** | `make fmt` | Auto-format code |
22-
| **Clean** | `make clean` | Clean build artifacts |
10+
| Task | Command | Notes |
11+
|-------------------|--------------------------------------------|----------------------------------|
12+
| **Development** | `./scripts/develop.sh` | ⚠️ Don't use manual build |
13+
| **Build** | `make build` | Fat binaries (includes server) |
14+
| **Build Slim** | `make build-slim` | Slim binaries |
15+
| **Test** | `make test` | Full test suite |
16+
| **Test Package** | `make test PACKAGE=./pkg/...` | Test specific package |
17+
| **Test Single** | `make test RUN=TestName` | Faster than full suite |
18+
| **Test Combined** | `make test PACKAGE=./pkg/... RUN=TestName` | Test specific test in package |
19+
| **Test Postgres** | `make test-postgres` | Run tests with Postgres database |
20+
| **Test Race** | `make test-race` | Run tests with Go race detector |
21+
| **Lint** | `make lint` | Always run after changes |
22+
| **Generate** | `make gen` | After database changes |
23+
| **Format** | `make fmt` | Auto-format code |
24+
| **Clean** | `make clean` | Clean build artifacts |
2325

2426
### Frontend Commands (site directory)
2527

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ GOTESTSUM_RETRY_FLAGS :=
936936
endif
937937

938938
test:
939-
$(GIT_FLAGS) gotestsum --format standard-quiet $(GOTESTSUM_RETRY_FLAGS) --packages="./..." -- -v -short -count=1 $(if $(RUN),-run $(RUN))
939+
$(GIT_FLAGS) gotestsum --format standard-quiet $(GOTESTSUM_RETRY_FLAGS) --packages="$(if $(PACKAGE),$(PACKAGE),./...)" -- -v -short -count=1 $(if $(RUN),-run $(RUN))
940940
.PHONY: test
941941

942942
test-cli:

coderd/apidoc/docs.go

Lines changed: 32 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 32 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/db2sdk/db2sdk.go

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -353,23 +353,34 @@ func TemplateVersionParameterOptionFromPreview(option *previewtypes.ParameterOpt
353353
}
354354
}
355355

356+
// oauth2AppEndpoints generates the OAuth2 endpoints for an app
357+
func oauth2AppEndpoints(accessURL *url.URL) codersdk.OAuth2AppEndpoints {
358+
return codersdk.OAuth2AppEndpoints{
359+
Authorization: accessURL.ResolveReference(&url.URL{
360+
Path: "/oauth2/authorize",
361+
}).String(),
362+
Token: accessURL.ResolveReference(&url.URL{
363+
Path: "/oauth2/token",
364+
}).String(),
365+
DeviceAuth: accessURL.ResolveReference(&url.URL{
366+
Path: "/oauth2/device",
367+
}).String(),
368+
Revocation: accessURL.ResolveReference(&url.URL{
369+
Path: "/oauth2/revoke",
370+
}).String(),
371+
}
372+
}
373+
356374
func OAuth2ProviderApp(accessURL *url.URL, dbApp database.OAuth2ProviderApp) codersdk.OAuth2ProviderApp {
357375
return codersdk.OAuth2ProviderApp{
358376
ID: dbApp.ID,
359377
Name: dbApp.Name,
360378
RedirectURIs: dbApp.RedirectUris,
361379
Icon: dbApp.Icon,
362-
Endpoints: codersdk.OAuth2AppEndpoints{
363-
Authorization: accessURL.ResolveReference(&url.URL{
364-
Path: "/oauth2/authorize",
365-
}).String(),
366-
Token: accessURL.ResolveReference(&url.URL{
367-
Path: "/oauth2/token",
368-
}).String(),
369-
DeviceAuth: accessURL.ResolveReference(&url.URL{
370-
Path: "/oauth2/device/authorize",
371-
}).String(),
372-
},
380+
CreatedAt: dbApp.CreatedAt,
381+
GrantTypes: dbApp.GrantTypes,
382+
UserID: dbApp.UserID.UUID,
383+
Endpoints: oauth2AppEndpoints(accessURL),
373384
}
374385
}
375386

@@ -379,6 +390,55 @@ func OAuth2ProviderApps(accessURL *url.URL, dbApps []database.OAuth2ProviderApp)
379390
})
380391
}
381392

393+
func OAuth2ProviderAppRow(accessURL *url.URL, dbApp database.GetOAuth2ProviderAppByIDRow) codersdk.OAuth2ProviderApp {
394+
return codersdk.OAuth2ProviderApp{
395+
ID: dbApp.ID,
396+
Name: dbApp.Name,
397+
RedirectURIs: dbApp.RedirectUris,
398+
Icon: dbApp.Icon,
399+
CreatedAt: dbApp.CreatedAt,
400+
GrantTypes: dbApp.GrantTypes,
401+
UserID: dbApp.UserID.UUID,
402+
Username: dbApp.Username.String,
403+
Email: dbApp.Email.String,
404+
Endpoints: oauth2AppEndpoints(accessURL),
405+
}
406+
}
407+
408+
func OAuth2ProviderAppsRows(accessURL *url.URL, dbApps []database.GetOAuth2ProviderAppsRow) []codersdk.OAuth2ProviderApp {
409+
return List(dbApps, func(dbApp database.GetOAuth2ProviderAppsRow) codersdk.OAuth2ProviderApp {
410+
return codersdk.OAuth2ProviderApp{
411+
ID: dbApp.ID,
412+
Name: dbApp.Name,
413+
RedirectURIs: dbApp.RedirectUris,
414+
Icon: dbApp.Icon,
415+
CreatedAt: dbApp.CreatedAt,
416+
GrantTypes: dbApp.GrantTypes,
417+
UserID: dbApp.UserID.UUID,
418+
Username: dbApp.Username.String,
419+
Email: dbApp.Email.String,
420+
Endpoints: oauth2AppEndpoints(accessURL),
421+
}
422+
})
423+
}
424+
425+
func OAuth2ProviderAppsByOwnerIDRows(accessURL *url.URL, dbApps []database.GetOAuth2ProviderAppsByOwnerIDRow) []codersdk.OAuth2ProviderApp {
426+
return List(dbApps, func(dbApp database.GetOAuth2ProviderAppsByOwnerIDRow) codersdk.OAuth2ProviderApp {
427+
return codersdk.OAuth2ProviderApp{
428+
ID: dbApp.ID,
429+
Name: dbApp.Name,
430+
RedirectURIs: dbApp.RedirectUris,
431+
Icon: dbApp.Icon,
432+
CreatedAt: dbApp.CreatedAt,
433+
GrantTypes: dbApp.GrantTypes,
434+
UserID: dbApp.UserID.UUID,
435+
Username: dbApp.Username.String,
436+
Email: dbApp.Email.String,
437+
Endpoints: oauth2AppEndpoints(accessURL),
438+
}
439+
})
440+
}
441+
382442
func convertDisplayApps(apps []database.DisplayApp) []codersdk.DisplayApp {
383443
dapps := make([]codersdk.DisplayApp, 0, len(apps))
384444
for _, app := range apps {

0 commit comments

Comments
 (0)