Skip to content

SK-2679: Add JSON object context support for Conditional Data Access#293

Open
samsternberg wants to merge 1 commit intomainfrom
feature/SK-2679-conditional-data-access-ctx-map-support
Open

SK-2679: Add JSON object context support for Conditional Data Access#293
samsternberg wants to merge 1 commit intomainfrom
feature/SK-2679-conditional-data-access-ctx-map-support

Conversation

@samsternberg
Copy link
Copy Markdown
Collaborator

@samsternberg samsternberg commented Apr 7, 2026

Summary

  • Add setCtx(Map<String, Object>) overloads to BearerToken and SignedDataTokens builders so the JWT ctx claim can be a nested JSON object (required for Conditional Data Access CEL expressions like request.context.role == 'admin')
  • Add setContext(Map<String, Object>) and getContextAsObject() to Credentials for high-level Skyflow client usage
  • Fully backwards compatible — existing setCtx(String) and setContext(String) APIs unchanged

Changes

  • Core: BearerToken.java, SignedDataTokens.java — widen internal ctx field to Object, add Map overloads to builders
  • Config: Credentials.java — add setContext(Map) setter and getContextAsObject() getter (preserves getContext() returning String)
  • Utils: Utils.java — dispatch context to correct setCtx overload based on type
  • Validation: Validations.java — validate empty Map context same as empty String
  • Tests: 8 new unit tests across BearerTokenTests, SignedDataTokensTests, CredentialsTests
  • Samples: Updated BearerTokenGenerationWithContextExample and SignedTokenGenerationExample with Map context examples
  • README: Documented Conditional Data Access with CEL expressions, string vs. JSON object context usage

Replaces #291 (which was created from a fork and couldn't run CI).

Test plan

  • mvn compile — clean
  • mvn test -Dtest=BearerTokenTests,SignedDataTokensTests,CredentialsTests — 51 tests, 0 failures
  • Samples compile against locally installed SDK
  • End-to-end test with a Skyflow vault using a Conditional Data Access policy

Refs SK-2679, DOCU-1438

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Gitleaks Findings: No secrets detected. Safe to proceed!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Semgrep Findings: Issues with Error level severity are found (Error is Highest severity in Semgrep), Please resolve the issues before merging.

The ctx claim in bearer tokens and signed data tokens previously only
accepted a String, which meant structured CEL expressions like
request.context.role == 'admin' could not be satisfied. Add
setCtx(Map<String, Object>) overloads to BearerToken and
SignedDataTokens builders so the JWT ctx claim is serialized as a
nested JSON object. Also add setContext(Map) and getContextAsObject()
to Credentials for use with the high-level Skyflow client.

All changes are backwards compatible — existing setCtx(String) and
setContext(String) APIs are unchanged.

Refs SK-2679
Co-Authored-By: Claude <noreply@anthropic.com>
@samsternberg samsternberg force-pushed the feature/SK-2679-conditional-data-access-ctx-map-support branch from 67c6762 to c683024 Compare April 7, 2026 13:30
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Gitleaks Findings: No secrets detected. Safe to proceed!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Semgrep Findings: Issues with Error level severity are found (Error is Highest severity in Semgrep), Please resolve the issues before merging.

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