Skip to content

feat(cred_inject): add value_prefix to CredInjectHeader#8

Merged
vessux merged 1 commit into
mainfrom
feat/cred-inject-value-prefix
Jun 12, 2026
Merged

feat(cred_inject): add value_prefix to CredInjectHeader#8
vessux merged 1 commit into
mainfrom
feat/cred-inject-value-prefix

Conversation

@vessux

@vessux vessux commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a value_prefix field to the gateway's cred_inject mechanism so it can prepend a literal prefix (e.g. "Bearer ") to a raw stored credential when composing an injected header. This lets cred_inject emit Authorization: Bearer <token> from a token stored without the prefix — required for gateway-native OAuth refresh (which stores raw access tokens).

This is the sole fork delta for openlock's upcoming Claude /login subscription-billing feature.

Changes

  • proto/sandbox.proto: CredInjectHeader.value_prefix = 3 (field 3 free; CredInjectHeader is a fork-only message → no upstream collision).
  • crates/openshell-sandbox/src/secrets.rs: CredInjectDirective.value_prefix, prepended at the header-composition site; new test cred_inject_applies_value_prefix.
  • Threaded end-to-end through the runtime path: opa.rs (proto→OPA-JSON serialize) → Rego passthrough → l7/mod.rs (parse into directive). Also wired crates/openshell-policy/src/lib.rs YAML↔proto conversions.
  • Empty value_prefix is a no-op → fully back-compatible (byte-identical output for existing directives).

Test Plan

  • cargo test -p openshell-sandbox -p openshell-policy → 819 + 78 pass
  • cargo clippy --workspace --features openshell-prover/bundled-z3 -- -D warnings → clean
  • Land on fork main (force-push per fork-sync flow), tag vX.Y.0, release workflow builds binaries
  • Bump OPENSHELL_FORK_TAG in openlock src/sandbox/fork-binaries.ts
  • Real-request e2e: confirm apply_cred_inject emits exactly one Authorization: Bearer <raw> (not zero, not double)

Review artifact for the openlock subscription-billing work (openlock-ndb).

Lets cred_inject prepend a literal prefix (e.g. "Bearer ") to the
resolved credential value when composing the injected header, so a raw
stored token can emit `Authorization: Bearer <token>`. Wires the new
proto field through the YAML policy def, OPA serialization, and the
sandbox CredInjectDirective. Empty prefix is a no-op (back-compat).
@vessux vessux merged commit 3dfa8cd into main Jun 12, 2026
2 checks passed
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