add readonly guard to new routes - #665
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enforces a read-only mode guard across new write routes and cleans up related authentication code, while also introducing a demo login prompt in the client and updating environment hints.
- Add ReadonlyGuard to all write endpoints in users, tokens, roles, and groups controllers
- Deprecate and update ReadonlyGuard behavior; remove legacy RBAC bypass logic in JWT and permissions guards
- Update
.env.templatecomments and enhance login prompt with demo credentials
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| server/src/users/users.controller.ts | Imported and applied ReadonlyGuard to write routes |
| server/src/token/token.controller.ts | Imported and applied ReadonlyGuard to write routes |
| server/src/roles/roles.controller.ts | Imported and applied ReadonlyGuard to write routes |
| server/src/groups/groups.controller.ts | Imported and applied ReadonlyGuard to write routes |
| server/src/common/guards/readonly.guard.ts | Marked ReadonlyGuard as deprecated and added additional warning message |
| server/src/auth/strategies/jwt.guard.ts | Commented out legacy RBAC skip logic |
| server/src/auth/permissions.guard.ts | Commented out legacy RBAC skip logic |
| server/.env.template | Clarified KUBERO_PROMETHEUS_ENDPOINT settings for local development |
| client/src/components/loginprompt.vue | Added demo domain alert and auto-filled demo credentials |
| server/src/deployments/deployments.service.spec.ts.old | Added legacy test file still suffixed .old |
Comments suppressed due to low confidence (4)
server/src/common/guards/readonly.guard.ts:21
- HTTP 202 (Accepted) is not typically used for blocking requests; consider returning 403 Forbidden to indicate the operation is disallowed.
throw new HttpException('Kubero is in read-only mode', 202);
server/src/deployments/deployments.service.spec.ts.old:1
- This test file ends with
.spec.ts.oldwhich may prevent it from running; consider renaming or removing the legacy.oldsuffix.
import { Test, TestingModule } from '@nestjs/testing';
server/.env.template:33
- The URL is missing a slash after "http:"; it should be "http://127.0.0.1:8080".
KUBERO_PROMETHEUS_ENDPOINT=http:/127.0.0.1:8080 # for local development
client/src/components/loginprompt.vue:129
- [nitpick] Computed properties should be pure and without side effects; moving assignment logic into a watcher or lifecycle hook would be more maintainable.
this.username = 'demo';
| /* Disabling for RBAC | ||
| if ( | ||
| !process.env.KUBERO_USERS && | ||
| !process.env.GITHUB_CLIENT_SECRET && | ||
| !process.env.OAUTH2_CLIENT_SECRET | ||
| ) { | ||
| return true; | ||
| } | ||
| */ |
There was a problem hiding this comment.
[nitpick] Rather than leaving large commented-out blocks, consider removing this legacy code to keep the guard implementation clean.
| /* Disabling for RBAC | |
| if ( | |
| !process.env.KUBERO_USERS && | |
| !process.env.GITHUB_CLIENT_SECRET && | |
| !process.env.OAUTH2_CLIENT_SECRET | |
| ) { | |
| return true; | |
| } | |
| */ | |
| // Removed legacy code for RBAC disabling. |
| /* Disabling for RBAC | ||
| if ( | ||
| !process.env.KUBERO_USERS && | ||
| !process.env.GITHUB_CLIENT_SECRET && | ||
| !process.env.OAUTH2_CLIENT_SECRET | ||
| ) { | ||
| return true; | ||
| } | ||
| */ | ||
|
|
There was a problem hiding this comment.
[nitpick] This commented-out RBAC fallback adds noise; removing deprecated logic would improve readability.
| /* Disabling for RBAC | |
| if ( | |
| !process.env.KUBERO_USERS && | |
| !process.env.GITHUB_CLIENT_SECRET && | |
| !process.env.OAUTH2_CLIENT_SECRET | |
| ) { | |
| return true; | |
| } | |
| */ |
…reader' as the username and '123456' as the password for demo domain access.
Description
Fixes # (issue)
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: