Repository navigation
Conversation
Embedders that build the auth server through the runner could not turn on Config.NonFatalSecondaryLegs, so a user who cancelled one provider's consent at first sign-in failed the whole sign-in. Add runner.WithNonFatalSecondaryLegs, which sets the field on the server the runner builds. It stays Go-only: there is no RunConfig or CRD field, so config files and operator CRDs cannot enable it. Without the option, behaviour is unchanged. This unblocks Mecatl's embedded gateway, which builds its authorization server through the runner. Once Mecatl bumps its ToolHive pin to a release with this option and passes it, a user who cancels one provider's consent at their first sign-in still gets an account, and that provider stays unconnected until they connect it. That is the first sign-in part of Mecatl's "Connect link for a missing provider connection, through the gateway's URL elicitation" (stacklok/mecatl#2973). The rest of that work, such as user-keyed storage and the credential reader, is separate. Closes stacklok#7370 Co-authored-by: Mecatl <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7377 +/- ##
=======================================
Coverage 82.63% 82.64%
=======================================
Files 934 934
Lines 97043 97045 +2
=======================================
+ Hits 80196 80202 +6
+ Misses 16842 16838 -4
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
runner.NewEmbeddedAuthServerWithStorage. The earlier PR "Make secondary chain legs optionally non-fatal" (Make secondary chain legs optionally non-fatal #7311) addedauthserver.Config.NonFatalSecondaryLegs, but the runner builds theConfigfrom theRunConfigand its options, and neither carried the setting. An embedder could turn it on only by callingauthserver.Newand repeating the runner's resolution, so a user who cancelled one provider's consent at their first sign-in still failed the whole sign-in.runner.WithNonFatalSecondaryLegs(), which sets the field on the server the runner builds. It works with bothNewEmbeddedAuthServerandNewEmbeddedAuthServerWithStorage. Without it nothing changes.RunConfigor CRD field, so config files and operator CRDs cannot enable it.Closes #7370
Type of change
Test plan
go test -race ./pkg/authserver/runner/with the Taskfile's flags; the fulltask testis left to CI)task test-e2e)golangci-lint run ./pkg/authserver/runner/, 0 issues; the repo-widetask lint-fixis left to CI)The new table test,
TestIntegration_EmbeddedAuthServer_NonFatalSecondaryLegs, builds a three-upstream chain through the runner and has the second leg's user deny consent:error=access_denied.These are the two "done when" cases in the issue. The test fails if the
NonFatalSecondaryLegsline inresolvedCfgis removed. The skip rules themselves are covered by the existing handler tests, so this test only proves the wiring.Does this introduce a user-facing change?
Only for embedders that build the auth server through the runner and pass the new option. Config files, the CLI and operator CRDs are unchanged.
authserver.Config.NonFatalSecondaryLegs.Special notes for reviewers
RunConfigor CRD field, if one is wanted, is separate work ("vMCP: graceful degradation when one upstream IdP fails in multi-upstream auth", vMCP: graceful degradation when one upstream IdP fails in multi-upstream auth #5162).SingleLegauthorization, ignore it, so refusing it would break an embedder that sets it on every gateway.walkChainnow delegates to awalkChainWithDenialvariant, with an empty denied host meaning the old behaviour, so the existing filter tests are untouched.newFilterTestServertakes optional runner options.Implementation plan
Approved implementation plan
pkg/authserver/runner/embeddedauthserver.go): add anonFatalSecondaryLegs boolfield afteruserKeyedUpstreamStorage; addWithNonFatalSecondaryLegs()afterWithAccessTokenType, no arguments, following the file'sWith<Field>naming; setNonFatalSecondaryLegs: options.nonFatalSecondaryLegsinresolvedCfg. No validation. The doc comment links to theConfigfield instead of copying its list of skippable failures.error=access_denied. The denial is simulated by calling the callback witherror=access_deniedand the state from the leg's authorize URL, becausemockoidccannot inject that error on the authorize request. No unit test of option resolution, because it cannot catch a missingresolvedCfgline, and no log assertions.docs/arch/11-auth-server-storage.mdandpkg/authserver/README.md, say to pass the runner option when using the runner and to set theConfigfield when callingauthserver.Newdirectly. Keep "not a RunConfig field".