-
Notifications
You must be signed in to change notification settings - Fork 0
chore: use refresh tokens in local oidc provider #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@claude can you please do a deep review of this? |
|
Claude finished @kantord's task —— View job Deep Review of PR #76Thanks for asking me to review this PR! I've analyzed the changes to add refresh token support to the local OIDC provider. Here's my comprehensive review: 🎯 SummaryThis PR properly configures the development OIDC provider to support refresh tokens, ensuring the local dev environment matches production behavior. The changes are well-implemented and align with the project's authentication architecture. ✅ What's Good1. Correct Refresh Token ImplementationThe changes properly configure the OIDC provider to issue refresh tokens:
2. Good Dev ExperienceThe very short access token TTL (15 seconds) forces frequent token refreshes during development, which is excellent for testing:
3. Client-Side Changes Are CorrectThe addition of
4. Code Quality
🔍 Areas for Consideration1. Comment Accuracy (Minor)File: The comment says: // Disable built-in dev interactions so our custom interaction logic below
// (auto-login + auto-consent that grants offline_access) takes effectIssue: The comment implies that disabling Suggestion: Clarify the comment to explain the actual reason for disabling it. For example: // Disable built-in dev interactions in favor of our custom auto-login/auto-consent logic
// that always grants offline_access for testing refresh tokens2. Scope Validation Logic (Enhancement Opportunity)File: The current scope granting logic is defensive but verbose: const requestedScopes = interaction.params.scope
?.split(" ")
.filter(Boolean) || ["openid", "email", "profile"];
const allowedScopes = ["openid", "email", "profile", "offline_access"];
const grantedScopes = requestedScopes.filter((s) =>
allowedScopes.includes(s),
);
// Ensure offline_access is granted in dev so refresh tokens are issued
if (!grantedScopes.includes("offline_access")) {
grantedScopes.push("offline_access");
}
const scopeString = grantedScopes.length
? grantedScopes.join(" ")
: "openid email profile";
grant.addOIDCScope(scopeString);Observation: The fallback
Suggestion: Simplify the logic since we always ensure const requestedScopes = interaction.params.scope
?.split(" ")
.filter(Boolean) || ["openid", "email", "profile"];
const allowedScopes = ["openid", "email", "profile", "offline_access"];
const grantedScopes = requestedScopes.filter((s) =>
allowedScopes.includes(s),
);
// Ensure offline_access is always granted in dev for testing refresh tokens
if (!grantedScopes.includes("offline_access")) {
grantedScopes.push("offline_access");
}
grant.addOIDCScope(grantedScopes.join(" "));This is purely a code clarity enhancement and doesn't affect functionality. 3. Refresh Token Configuration ValidationFile: The configuration includes Question: Have you tested that:
If not tested yet, I'd recommend manual testing or adding integration tests for this flow. 4. DocumentationFile: Consider adding a brief note in the documentation about refresh token behavior in development vs. production:
This would help future contributors understand why the dev environment behaves differently. 🔒 Security Review✅ No Security Issues Found
📋 Testing✅ Test Coverage UpdatedThe test in 💡 Suggestion: Integration TestConsider adding an integration test that verifies:
This would give confidence that the full refresh flow works end-to-end. 🎨 Code StyleAll changes follow the project's code style guidelines:
🚀 RecommendationApprove with minor suggestions. The core implementation is solid and the changes are safe to merge. The suggestions above are all optional enhancements that would improve code clarity and documentation, but they don't block the PR. Priority for follow-up:
Summary of Changes
Great work on improving the dev environment's authentication fidelity! 🎉 Job Run: [Link to run](https://github.com/stacklok/toolhive-cloud-ui/actions/runs/${{ github.run_id }}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds refresh token support to the local OIDC provider for development, enabling testing of token refresh flows. The changes add the offline_access scope to OAuth2 authentication requests, configure the dev OIDC provider to issue refresh tokens with very short-lived access tokens (15 seconds), and update the corresponding tests.
- Adds
offline_accessscope to OAuth2 signin flow in both implementation and tests - Configures dev OIDC provider to support refresh tokens with shortened access token TTL
- Updates auto-consent logic to always grant
offline_accessin development
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/app/signin/page.tsx | Adds offline_access scope to the OAuth2 signin call to request refresh tokens |
| src/app/signin/tests/signin.test.tsx | Updates test assertions to include the new offline_access scope in expected call parameters |
| dev-auth/oidc-provider.mjs | Configures OIDC provider to support refresh tokens: declares offline_access scope, shortens access token TTL to 15s, disables built-in dev interactions, and updates auto-consent logic to always grant offline_access |
No description provided.