Skip to content

feat(docs): add Authorization REST API integration guide#285

Draft
marythought wants to merge 2 commits intomainfrom
worktree-DSPX-2802-rest-api-guide
Draft

feat(docs): add Authorization REST API integration guide#285
marythought wants to merge 2 commits intomainfrom
worktree-DSPX-2802-rest-api-guide

Conversation

@marythought
Copy link
Copy Markdown
Contributor

Summary

  • Adds a new guide at /guides/authorization-rest-api showing how to call the OpenTDF Authorization Service directly over HTTP, without an SDK
  • Targets server-side integrators using Node.js, Python, Ruby, or any language without an OpenTDF SDK
  • Covers authentication (OIDC client credentials), health checks, GetDecision, GetDecisionBulk, GetEntitlements, attribute FQN construction, entity identifiers, batching strategies, and production best practices
  • Follows existing guide conventions (mermaid diagrams, tabbed code examples, admonitions, production checklist)

Context

Rocket.Chat PR #39845 built a full Virtru PDP integration by hand-rolling ~200 lines of HTTP calls. The existing authorization docs cover SDK usage only — this guide fills the gap for server-side REST API consumers.

Test plan

  • Dev server renders the page at /guides/authorization-rest-api
  • Mermaid sequence diagram renders
  • Tab components (curl / TypeScript / Python) work
  • Cross-links to /sdks/authorization, /sdks/obligations, /guides/authentication-guide resolve
  • Page appears in the Guides sidebar section

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d11bf108-4d97-4378-9e3a-d7eb0a2732aa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-DSPX-2802-rest-api-guide

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive guide for the Authorization REST API, covering authentication, health checks, and core service endpoints with examples in multiple languages. The review feedback identifies a technical inaccuracy regarding the JSON structure for JWT-based entity identifiers and suggests using versioned REST paths for legacy v1 endpoints to maintain consistency with the OpenAPI specification.

}
```

To use a different identifier type, replace `emailAddress` with the appropriate field:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The instruction to "replace emailAddress with the appropriate field" is misleading for the token identifier type. While clientId and userName are fields within an Entity object (inside entityChain), token is a top-level alternative to entityChain within the EntityIdentifier object and has a different JSON structure.

To use a JWT, you must replace the entire entityChain block with a token block:

{
  "entityIdentifier": {
    "token": {
      "ephemeralId": "token-correlation-id",
      "jwt": "YOUR_JWT_HERE"
    }
  }
}

| `/authorization.v2.AuthorizationService/GetDecision` | v2 | Single entity + action + resource decision |
| `/authorization.v2.AuthorizationService/GetDecisionBulk` | v2 | Batch decisions for multiple entities/resources |
| `/authorization.v2.AuthorizationService/GetEntitlements` | v2 | List all attribute values an entity can access |
| `/authorization.AuthorizationService/GetDecisions` | v1 (legacy) | Batch decisions (v1 format) |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The v1 GetDecisions endpoint is explicitly mapped to /v1/authorization in the OpenAPI specification (specs/authorization/authorization.openapi.yaml). While the gRPC-style path might be supported by the gateway, using the versioned path is more consistent with the RESTful patterns documented in the spec.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

❌ Surge preview build failed — no preview was deployed. Check the workflow logs for details.

Once the build passes, the preview will be at: https://opentdf-docs-pr-285.surge.sh

Common cause: If the build failed on vendored YAML validation, run the following locally and commit the result:

npm run update-vendored-yaml
git add specs/
git commit -m "chore(deps): update vendored OpenAPI specs"

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

❌ Surge preview build failed — no preview was deployed. Check the workflow logs for details.

Once the build passes, the preview will be at: https://opentdf-docs-pr-285.surge.sh

Common cause: If the build failed on vendored YAML validation, run the following locally and commit the result:

npm run update-vendored-yaml
git add specs/
git commit -m "chore(deps): update vendored OpenAPI specs"

Copy link
Copy Markdown

@KevLehman KevLehman left a comment

Choose a reason for hiding this comment

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

Great docs!

<TabItem value="ts" label="TypeScript (fetch)">

```typescript
async function getClientToken(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's probably good to mention the permissions the token should have so virtru can use it to authenticate requests.

Additionally, i needed to put a custom audience to the token that matched the url of virtru so the token was accepted. That would be good to mention on the docs too 👀

}
```

The `decision` field is either `DECISION_PERMIT` or `DECISION_DENY`. If `requiredObligations` is non-empty, your application must enforce those obligations (e.g., watermarking, audit logging). See [Obligations](/sdks/obligations) for details.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's also (on the docs) a decision unknown type. Not sure what this meant, but it's good if we document it here too.


For large-scale evaluations (e.g., re-evaluating room membership for all users), send requests in batches rather than one massive payload:

- **Batch size:** 100–200 decision requests per call
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

batching is also required because GetDecisionBulk supports up to 200 decisions per request.


```typescript
const response = await fetch(
`${platformUrl}/authorization.v2.AuthorizationService/GetDecisionBulk`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One important note is that we have to rely on index-matching for knowing that a decision is made for an entity, since the bulk endpoint doesn't return any information regarding the entity.

Other option would be to pass the entityId on the ephemeralResourceId too, but that seems semantically incorrect.

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