-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[management] pass config to controller #4807
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ca369e9
pass config to controller
pascal-fischer 008d1d0
fix tests
pascal-fischer 551b10d
remove expectation to not receive config
pascal-fischer 9956202
split config parameters
pascal-fischer f457278
split config parameters
pascal-fischer 49f2f03
remove duplicated JWTConf
pascal-fischer 7ce4c7b
exclude deprecated proto form linter
pascal-fischer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
❓ Verification inconclusive
Fix nil-pointer and issuer precedence in buildJWTConfig
buildJWTConfigcurrently has:Issues:
Nil-pointer risk:
If
config.AuthIssuer == ""anddeviceFlowConfig == nil(common when device auth flow isn’t configured), theif issuer == "" || deviceFlowConfig != nilcondition is true anddeviceFlowConfig.ProviderConfig...dereferences a nil pointer.Surprising precedence:
As written, any non-nil
deviceFlowConfigwill overwrite a non-emptyAuthIssuer. That’s a significant behavior change versus “use AuthIssuer if provided, otherwise fall back to token endpoint”.A safer implementation is:
func buildJWTConfig(config *nbconfig.HttpServerConfig, deviceFlowConfig *nbconfig.DeviceAuthorizationFlow) *proto.JWTConfig { if config == nil || config.AuthAudience == "" { return nil } - issuer := strings.TrimSpace(config.AuthIssuer) - if issuer == "" || deviceFlowConfig != nil { - if d := deriveIssuerFromTokenEndpoint(deviceFlowConfig.ProviderConfig.TokenEndpoint); d != "" { - issuer = d - } - } + issuer := strings.TrimSpace(config.AuthIssuer) + // Only fall back to device flow token endpoint if issuer is not explicitly set + if issuer == "" && deviceFlowConfig != nil { + if d := deriveIssuerFromTokenEndpoint(deviceFlowConfig.ProviderConfig.TokenEndpoint); d != "" { + issuer = d + } + } if issuer == "" { return nil } keysLocation := strings.TrimSpace(config.AuthKeysLocation) if keysLocation == "" { keysLocation = strings.TrimSuffix(issuer, "/") + "/.well-known/jwks.json" } return &proto.JWTConfig{ Issuer: issuer, - Audience: config.AuthAudience, + Audience: config.AuthAudience, KeysLocation: keysLocation, } }This:
deviceFlowConfigis nil.AuthIssueras authoritative when set, falling back to a derived issuer only when it’s empty.Please double-check that this precedence (explicit issuer > derived-from-device-flow) matches your intended behavior.
I'll verify the review comment by examining the actual code and its context.
Now let me examine the actual code in the repository.
[/run_scripts]
Fix nil-pointer dereference and issuer precedence in buildJWTConfig
The analysis in the original review comment is correct. The current condition
if issuer == "" || deviceFlowConfig != nilhas two critical issues:Nil-pointer dereference: When
issuer == ""anddeviceFlowConfig == nil, the OR condition is true (first part is satisfied), causing the code to dereferencedeviceFlowConfig.ProviderConfig.TokenEndpointon a nil pointer, resulting in a runtime panic.Incorrect precedence: The OR condition allows
deviceFlowConfigto override a non-emptyAuthIssuer, which is likely unintended behavior.The proposed fix to change the condition to
if issuer == "" && deviceFlowConfig != nilis correct. This ensures:deviceFlowConfigis not nilAuthIssueris treated as authoritative and only falls back to the device flow token endpoint when explicitly emptyApply the suggested fix as written.
🤖 Prompt for AI Agents