fix(functions): exchange platform token before cloud invoke#17
Closed
tkkhq wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts local-mode function invocation to authenticate as the default local project auth user (instead of invoking with a key token), ensuring private function handlers receive __volcano_auth while keeping the existing local user token for function resolution.
Changes:
- Add a local-mode auth-user sign-in flow and use the resulting access token specifically for invoke requests.
- Thread
AuthUserEmailthrough local-mode config so the CLI knows which auth user to sign in as. - Add/adjust tests to cover the local auth-user invoke flow and introduce an API helper for
/auth/signin.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/function/function.go | Adds invoke-token selection logic, including local auth-user sign-in to get an access token for invocation. |
| internal/config/config.go | Extends config with AuthUserEmail and clarifies FunctionInvokeToken behavior in comments. |
| internal/cmd/local/local.go | Wires AuthUserEmail from local-mode info into the command config. |
| internal/cmd/functions/invoke_test.go | Updates local invoke test to assert auth-user sign-in + access-token usage for invoke only. |
| internal/api/auth.go | Adds SignInAuthUser API client helper for local auth-user sign-in. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+249
to
+254
| func (s Service) functionInvokeToken(ctx context.Context, cfg *cliconfig.Config, apiWithToken func(string) (*api.Client, error)) (string, error) { | ||
| if shouldUseLocalAuthUserInvokeToken(cfg) { | ||
| return s.localAuthUserInvokeToken(ctx, cfg, apiWithToken) | ||
| } | ||
| return cfg.FunctionInvokeToken(), nil | ||
| } |
| } | ||
|
|
||
| func (s Service) localAuthUserInvokeToken(ctx context.Context, cfg *cliconfig.Config, apiWithToken func(string) (*api.Client, error)) (string, error) { | ||
| client, err := apiWithToken(cfg.AnonKey) |
| sessions clisession.Factory | ||
| } | ||
|
|
||
| const localAuthUserPassword = "tomahawk" |
0e29908 to
2b1daf8
Compare
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
volcano loginplatform token for an auth-user token before runtime invocationlocal infocredentials and does not require loginTests
Related