Skip to content

fix(functions): exchange platform token before cloud invoke#17

Closed
tkkhq wants to merge 1 commit into
mainfrom
fix/localmode-invoke-token
Closed

fix(functions): exchange platform token before cloud invoke#17
tkkhq wants to merge 1 commit into
mainfrom
fix/localmode-invoke-token

Conversation

@tkkhq

@tkkhq tkkhq commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • cloud function invoke exchanges the configured volcano login platform token for an auth-user token before runtime invocation
  • invokes the existing function endpoint with the exchanged auth-user token
  • does not persistently cache exchanged auth-user tokens; they are derived on demand from the durable platform token
  • localmode still invokes directly with local local info credentials and does not require login

Tests

  • go test ./...

Related

  • Kong/volcano-hosting#444

@tkkhq tkkhq requested a review from a team as a code owner June 20, 2026 18:34
Copilot AI review requested due to automatic review settings June 20, 2026 18:34

Copilot AI left a comment

Copy link
Copy Markdown

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 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 AuthUserEmail through 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 thread internal/function/function.go Outdated
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
}
Comment thread internal/function/function.go Outdated
}

func (s Service) localAuthUserInvokeToken(ctx context.Context, cfg *cliconfig.Config, apiWithToken func(string) (*api.Client, error)) (string, error) {
client, err := apiWithToken(cfg.AnonKey)
Comment thread internal/function/function.go Outdated
sessions clisession.Factory
}

const localAuthUserPassword = "tomahawk"
@tkkhq tkkhq force-pushed the fix/localmode-invoke-token branch from 0e29908 to 2b1daf8 Compare June 20, 2026 18:51
@tkkhq tkkhq changed the title fix(functions): invoke local private functions as auth user docs(functions): clarify invoke token selection Jun 20, 2026
@tkkhq tkkhq changed the title docs(functions): clarify invoke token selection docs(functions): clarify CLI invoke token selection Jun 20, 2026
@tkkhq tkkhq closed this Jun 20, 2026
@tkkhq tkkhq changed the title docs(functions): clarify CLI invoke token selection fix(functions): exchange platform token before cloud invoke Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants