Fix SSH JWT issuer derivation for IDPs with path components#4844
Fix SSH JWT issuer derivation for IDPs with path components#4844pascal-fischer merged 1 commit intonetbirdio:mainfrom
Conversation
WalkthroughModified the JWT issuer derivation condition in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
management/internals/shared/grpc/conversion.go (1)
394-405: Optional: Document the path-stripping behavior.The function intentionally strips path components from the token endpoint, returning only
scheme://host/. While this is appropriate for deriving a fallback issuer, it may be worth adding a comment explaining this behavior to prevent future confusion, especially since it's the reason path-based IDPs were broken by the old call-site logic.Consider adding a doc comment:
// deriveIssuerFromTokenEndpoint extracts the issuer URL from a token endpoint +// Note: This function intentionally strips path components, returning only scheme://host/. +// It should only be used when no explicit issuer is configured. func deriveIssuerFromTokenEndpoint(tokenEndpoint string) string {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
management/internals/shared/grpc/conversion.go(1 hunks)
🔇 Additional comments (1)
management/internals/shared/grpc/conversion.go (1)
372-376: LGTM! The condition fix correctly respects explicitly configured issuers.The change from OR (
||) to AND (&&) is correct and directly addresses the reported SSH failure with IDPs that have path components. Previously, any non-nildeviceFlowConfigwould trigger derivation from the token endpoint—overriding an explicitly setAuthIssuer—and sincederiveIssuerFromTokenEndpoint()strips path components (returns onlyscheme://host/), this broke IDPs like Authentik that require paths in the issuer URL.The new logic only derives the issuer when it's truly unset, preserving the configured value when present. Code search confirms this is the only call site for issuer derivation, and the fix doesn't affect other authentication providers (e.g., Auth0 explicitly requires
AuthIssuerto be configured independently).



Describe your changes
Fixed SSH JWT authentication for IDPs with path-based issuers (e.g., Authentik).
The
buildJWTConfig()function inconversion.gowas incorrectly using OR (||) instead of AND (&&) when checking whether to derive the issuer from the token endpoint. This caused it to always override the configuredAuthIssuerwhendeviceFlowConfigexists, even whenAuthIssuerwas properly set.The
deriveIssuerFromTokenEndpoint()function strips the path from URLs (returns onlyscheme://host/), which breaks IDPs like Authentik where the issuer includes a path component (e.g.,https://auth.example.com/application/o/netbird/).Changed: Line 372 in
management/internals/shared/grpc/conversion.goNow the issuer is only derived from the token endpoint when
AuthIssueris not already configured.Issue ticket number and link
Fixes #4813
Stack
Checklist
Documentation
Select exactly one:
Reason: This is a bug fix that corrects existing behavior. No new features or configuration options are introduced.
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
N/A
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.