Skip to content

SK-2681: Add dict context support for Conditional Data Access#238

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

SK-2681: Add dict context support for Conditional Data Access#238
samsternberg wants to merge 1 commit intomainfrom
feature/SK-2681-conditional-data-access-ctx-dict-support

Conversation

@samsternberg
Copy link
Copy Markdown
Collaborator

Summary

  • Add dict support for the ctx parameter in bearer token and signed data token generation
  • Add _validate_and_resolve_ctx() with key validation (alphanumeric + underscores only for CEL compatibility)
  • Add error messages for invalid ctx type and invalid dict keys
  • Add 14+ unit tests for the new validation function
  • Update README with string vs dict context documentation and CEL expression examples
  • Update sample files with both string and dict context approaches

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

Test plan

  • _validate_and_resolve_ctx() manually verified: string, dict, None, empty string, invalid type, invalid keys, nested objects
  • Pre-existing test collection error on main (requires credentials.json — not a regression)
  • End-to-end test with a Skyflow vault using a Conditional Data Access policy

Refs SK-2681, DOCU-1440

The ctx parameter in bearer tokens and signed data tokens previously
only accepted a string. Add dict support so the JWT ctx claim can be
a nested JSON object, enabling Conditional Data Access CEL expressions
like request.context.role == 'admin'.

Add _validate_and_resolve_ctx() with key validation (alphanumeric +
underscores only for CEL compatibility). Add error messages for
invalid ctx type and keys. Add 14+ unit tests for validation.
Update README and samples with string and dict context examples.

Refs SK-2681, DOCU-1440
Co-Authored-By: Claude <noreply@anthropic.com>
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