Skip to content

Submit oauth secrets to vault DON#332

Open
timothyF95 wants to merge 4 commits intomainfrom
submit-oauth-secret-vault
Open

Submit oauth secrets to vault DON#332
timothyF95 wants to merge 4 commits intomainfrom
submit-oauth-secret-vault

Conversation

@timothyF95
Copy link
Copy Markdown
Contributor

@timothyF95 timothyF95 commented Mar 31, 2026

Summary

Completes the browser (--secrets-auth=browser) vault flow after platform OAuth: the CLI now submits the same digest-bound JSON-RPC body to the configured gateway with Authorization: Bearer, then parses the gateway response using the existing ParseVaultGatewayResponse path (create, update, delete, and list).

Previously, the flow stopped after token exchange and discarded the access token.

Changes

  • GatewayClient: add PostWithBearer; HTTPClient implements it with Authorization: Bearer, retries on transport/read failures only (no on-chain allowlist retry semantics).
  • executeBrowserUpsert: marshal the JSON-RPC request and pass requestBody into ExecuteBrowserVaultAuthorization so the POST matches the digest sent to createVaultAuthorizationUrl.
  • ExecuteBrowserVaultAuthorization: new parameter requestBody []byte (validated non-empty); after code exchange, call postVaultGatewayWithBearer.
  • postVaultGatewayWithBearer: POST + non-200 handling + ParseVaultGatewayResponse for all methods.
  • cre secrets list / cre secrets delete (browser): pass the marshaled JSON-RPC body into ExecuteBrowserVaultAuthorization.
  • mockGatewayClient: implement PostWithBearer by delegating to the existing post mock.
  • Tests: PostWithBearer (success, empty token, non-200, transport retry), and postVaultGatewayWithBearer (create, list, non-200, invalid JSON).

Notes

Owner-key / allowlist flows are unchanged; they still use Post without Bearer.
End-to-end success still depends on the gateway and vault DON accepting JWT-backed requests.

return b, resp.StatusCode, nil
}

func (g *HTTPClient) postOnceWithBearer(body []byte, bearerToken string) ([]byte, int, error) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timothyF95 timothyF95 marked this pull request as ready for review April 1, 2026 12:07
@timothyF95 timothyF95 requested a review from a team as a code owner April 1, 2026 12:07
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.

1 participant