Skip to content

feat: add Device Auth Tokens tab to User Preferences - #1633

Open
olexii4 wants to merge 8 commits into
mainfrom
CRW-11582
Open

feat: add Device Auth Tokens tab to User Preferences#1633
olexii4 wants to merge 8 commits into
mainfrom
CRW-11582

Conversation

@olexii4

@olexii4 olexii4 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a Device Auth Tokens tab to the User Preferences page with two capabilities:

  1. Connect to GitHub — A Connect to GitHub button opens a modal displaying a one-time code with a copy button and a "Copy & Continue to Browser" primary button. The backend polls GitHub for authorization (RFC 8628) and on success writes a che.eclipse.org/device-authentication=true Kubernetes Secret to the user's namespace. The button appears automatically when the device-auth-config ConfigMap is present in the Che namespace — fully independent of Git Services OAuth configuration.

  2. View & delete (single and bulk) — A compact card list (matching SSH Keys UI) shows stored tokens. A per-row Actions ⋮ menu provides Delete and Reconnect actions. Deleting removes the K8s Secret and revokes the GitHub token via POST /credentials/revoke (no app credentials required). Reconnecting replaces the existing token (single-active-token model matching che-code). Replacing an existing secret preserves its resourceVersion and any extra labels applied by che-code or a mutating webhook.

Device Authentication tokens are GitHub OAuth tokens generated by the device authorization flow (RFC 8628). They are stored as Kubernetes Secrets labeled che.eclipse.org/device-authentication=true. Previously the only way to generate or remove a token was through the VS Code command palette inside a running workspace.

Screenshot/screencast of this PR

Device Auth Tokens tab Connect to GitHub modal

What issues does this PR fix or reference?

fixes https://redhat.atlassian.net/browse/CRW-11582

Is it tested? How?

Unit / integration tests

  • getDeviceAuthClientId.spec.ts — 6 tests: ConfigMap read, TTL cache hit, env-var override, missing namespace, K8s 404
  • deviceAuthToken.spec.ts — 4 route tests: 503 when ConfigMap absent, correct delegation when present
  • deviceAuthTokenApi.spec.ts — 27 tests updated: clientId passed as parameter, revocation success path, createNamespacedSecret argument shape

Deploy and verify

  1. Deploy Che with the PR image:
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p='[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {"containers": [{"image": "quay.io/eclipse/che-dashboard:pr-1633", "name": "che-dashboard"}]}}]'
  1. Apply the device-auth-config ConfigMap. Use VS Code's public OAuth App (01ab8ac9400c4e429b23) — it has Device Flow enabled by default and supports GitHub Copilot:
kubectl -n eclipse-che create configmap device-auth-config \
  --from-literal=github_client_id=01ab8ac9400c4e429b23
  1. Navigate to User Preferences → Device Auth Tokens.
  2. Click Copy & Continue to Browser → paste the code on github.com/login/device → authorize.
  3. Verify: the token card appears with a validity icon.
  4. Click ⋮ → Reconnect to replace the token; ⋮ → Delete to revoke and remove it.
  5. Delete the ConfigMap and reload — verify the Connect to GitHub button is hidden.
  6. Without the ConfigMap, call POST .../device-auth-token/initiate directly — verify HTTP 503 is returned.

Release Notes

Added a Device Auth Tokens tab to User Preferences. Users can connect their GitHub account using device authorization directly from the Dashboard, view tokens with on-demand validity checks, and delete/revoke tokens without requiring app credentials. The feature is enabled by creating a device-auth-config ConfigMap in the Che namespace — fully independent of Git Services OAuth.

Docs PR

eclipse-che/che-docs#3168

@che-bot

che-bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Click here to review and test in web IDE: Contribute

@olexii4 olexii4 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary

Verdict: 💬 Comment - No blocking issues. Design is sound, follows established project patterns consistently.

Criticality: 🟡 Important (DELETE endpoint on K8s Secrets)

Integration contracts verified against che-code extension source:

  • ✅ Label che.eclipse.org/device-authentication=true matches
  • ✅ Secret name pattern compatible
  • ✅ No secret data exposed (only metadata returned)

Positive feedback:

  • Clean layered architecture matching SSH keys / PATs / AI provider keys patterns
  • 23 new frontend tests with good assertion rigor
  • Minimal DTO - no secret data leakage
  • Consistent error handling across all layers

5 inline comments posted below covering schema constraints, backend tests, reducer tests, label verification, and card distinguishability.


Review generated by ok-pr-review (standard + deep)

Comment thread packages/dashboard-backend/src/constants/schemas.ts
Comment thread packages/dashboard-backend/src/devworkspaceClient/services/deviceAuthTokenApi.ts Outdated
Comment thread packages/dashboard-backend/src/devworkspaceClient/services/deviceAuthTokenApi.ts Outdated
@tolusha

tolusha commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Hi! I'm che-ai-assistant — I help with your pull requests.

Available commands:

  • /che-ai-assistant generate-che-doc — Generate a documentation PR based on this PR's changes
  • /che-ai-assistant ok-pr-review — Run a comprehensive PR review (summary, code review, deep review, impact analysis)
  • /che-ai-assistant check-pr-test-failures — Analyze failing CI checks, identify root causes, and suggest fixes
  • /che-ai-assistant update-che-e2e-tests — Update Eclipse Che e2e tests
  • /che-ai-assistant help — Show this help message

Comment thread packages/dashboard-frontend/src/store/DeviceAuthToken/reducer.ts
@olexii4
olexii4 requested a review from RomanNikitenko July 13, 2026 14:16
@github-actions

Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1633 (linux/amd64, linux/arm64, linux/s390x)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1633", name: che-dashboard}]}}]"

1 similar comment
@github-actions

Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1633 (linux/amd64, linux/arm64, linux/s390x)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1633", name: che-dashboard}]}}]"

@olexii4

olexii4 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

/che-ai-assistant ok-pr-review

Task completed.

@tolusha tolusha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-structured PR with solid test coverage across all layers. The security model is sound with proper label validation on delete and correct use of user bearer tokens throughout. A few findings worth discussing before merging:

  • Date type mismatch (I1): The DeviceAuthToken DTO declares creationTimestamp?: Date but Fastify serializes it to an ISO 8601 string. The frontend receives a string at runtime. See inline comment on the DTO.
  • Error conflation in deleteToken (D2): The catch block in deleteToken wraps the intentional label-mismatch throw alongside network errors, making all failure modes indistinguishable to the caller.
  • Bootstrap fetch for all users (W1/P1): fetchDeviceAuthTokens adds a K8s API call to every dashboard load. Since the component already lazy-loads on tab visit, removing the bootstrap call would improve initial load time for users who never use this tab.

All other findings are minor (ordering, modal UX, extensibility). See inline comments for details.

Comment thread packages/dashboard-frontend/src/store/rootReducer.ts
Comment thread packages/dashboard-backend/src/devworkspaceClient/services/deviceAuthTokenApi.ts Outdated
Comment thread packages/dashboard-backend/src/devworkspaceClient/services/deviceAuthTokenApi.ts Outdated
Comment thread packages/common/src/dto/api/index.ts
Comment thread packages/dashboard-frontend/src/services/bootstrap/index.ts Outdated
@github-actions

Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1633 (linux/amd64, linux/arm64, linux/s390x)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1633", name: che-dashboard}]}}]"

@olexii4

olexii4 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

/che-ai-assistant ok-pr-review

Task completed.

@olexii4

olexii4 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@olexii4

olexii4 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

/retest

Comment thread packages/dashboard-backend/src/routes/api/deviceAuthToken.ts Fixed
Comment thread packages/dashboard-backend/src/routes/api/deviceAuthToken.ts Dismissed
@github-actions

Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1633 (linux/amd64, linux/arm64, linux/s390x)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1633", name: che-dashboard}]}}]"

@olexii4 olexii4 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary

Verdict: 🔄 Request Changes — 2 critical issues, 4 suggestions

Criticality: 🟡 Important (K8s Secrets + GitHub OAuth tokens)

Integration contracts verified:

  • ✅ Label che.eclipse.org/device-authentication=true matches che-code
  • ✅ GitHub Device Flow API endpoints and grant type match docs
  • ✅ GitHub revocation API matches docs
  • ✅ No secret data exposed (only metadata returned)

Critical:

  1. Math.random() for K8s secret names — collision risk in multi-user deployments (inline #1)
  2. response.ok not checked on GitHub API calls — silent failures on non-2xx (inline #2)

Warnings:
3. slow_down response not propagated — violates GitHub Device Flow spec (inline #3)
4. PF v5 CSS variable in PF 6 codebase (inline #4)
5. onSuccess callback drops token argument — stale UI on re-fetch failure (inline #5)
6. Missing maxLength on deviceCode schema field (inline #6)

Positive feedback:

  • Clean layered architecture matching SSH keys / PATs patterns
  • Comprehensive backend test suite (321 lines) with strong assertion rigor
  • resourceVersion precondition on delete is a genuine hardening improvement
  • Delete modal includes helpful GitHub settings link
  • Provider field + label is nice forward-looking extensibility

All prior review feedback (tolusha + self-review: 12 comments) has been addressed.


Review generated by ok-pr-review (standard + deep)

Comment thread packages/dashboard-backend/src/devworkspaceClient/services/deviceAuthTokenApi.ts Outdated
Comment thread packages/dashboard-backend/src/devworkspaceClient/services/deviceAuthTokenApi.ts Outdated
Comment thread packages/dashboard-backend/src/devworkspaceClient/services/deviceAuthTokenApi.ts Outdated
Comment thread packages/dashboard-frontend/src/pages/UserPreferences/DeviceAuthTokens/index.tsx Outdated
Comment thread packages/dashboard-backend/src/constants/schemas.ts Outdated
@github-actions

Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1633 (linux/amd64, linux/arm64, linux/s390x)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1633", name: che-dashboard}]}}]"

1 similar comment
@github-actions

Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1633 (linux/amd64, linux/arm64, linux/s390x)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1633", name: che-dashboard}]}}]"

@olexii4

olexii4 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@olexii4
olexii4 marked this pull request as draft August 7, 2026 16:41
@olexii4
olexii4 marked this pull request as ready for review August 7, 2026 16:41
@olexii4

olexii4 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

/che-ai-assistant ok-pr-review

@olexii4

olexii4 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@olexii4
olexii4 marked this pull request as draft August 10, 2026 14:25
@olexii4
olexii4 marked this pull request as ready for review August 10, 2026 14:25
@olexii4
olexii4 removed the request for review from vinokurig August 10, 2026 14:34
Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>
…ferences tab

Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>
…error handling

Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>
…rovements

Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>
…ap fallback

Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>
@github-actions

Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1633 (linux/amd64, linux/arm64, linux/s390x)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1633", name: che-dashboard}]}}]"

@olexii4

olexii4 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

/retest

olexii4 added a commit to eclipse-che/che-docs that referenced this pull request Aug 13, 2026
Documents the Device Auth Tokens tab in User Preferences introduced
in eclipse-che/che-dashboard#1633.

New article (connecting-to-github-using-device-authorization.adoc):
- Connect to GitHub using the device authorization flow (RFC 8628)
- Reconnect to replace a revoked or expired token in-place
- Delete a single token or multiple tokens in bulk
- Troubleshooting for expired one-time codes

Updated admin procedure (proc_setting-up-the-github-oauth-app.adoc):
- Optional steps to enable Device Flow on the GitHub OAuth App
- Step to create the device-auth-config ConfigMap that enables the
  Connect to GitHub button in the Dashboard

Updated assembly (configuring-oauth-2-for-github.adoc):
- NOTE for admins who already configured the OAuth App and want
  to enable Device Auth Tokens without repeating the full setup

Navigation: added the new article under Using credentials and
configurations in workspaces > Mounting secrets.

Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>

@svor svor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olexii4 Great job!
Works for me

Image

I'd like to ask @RomanNikitenko and @vinokurig for the review as well

@openshift-ci

openshift-ci Bot commented Aug 13, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: olexii4, svor

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

olexii4 added a commit to eclipse-che/che-docs that referenced this pull request Aug 14, 2026
Documents the Device Auth Tokens tab in User Preferences introduced
in eclipse-che/che-dashboard#1633.

New article (connecting-to-github-using-device-authorization.adoc):
- Connect to GitHub using the device authorization flow (RFC 8628)
- Reconnect to replace a revoked or expired token in-place
- Delete a single token or multiple tokens in bulk
- Troubleshooting for expired one-time codes

Updated admin procedure (proc_setting-up-the-github-oauth-app.adoc):
- Optional steps to enable Device Flow on the GitHub OAuth App
- Step to create the device-auth-config ConfigMap that enables the
  Connect to GitHub button in the Dashboard

Updated assembly (configuring-oauth-2-for-github.adoc):
- NOTE for admins who already configured the OAuth App and want
  to enable Device Auth Tokens without repeating the full setup

Navigation: added the new article under Using credentials and
configurations in workspaces > Mounting secrets.

Assisted-by: Claude Sonnet 4.6
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants