Skip to content

Conversation

jp-ayyappan
Copy link
Contributor

🚀 Overview

This PR significantly improves the authorization SDK documentation to address developer experience issues and community requests.

🔧 Problems Addressed

API Version Inconsistencies

  • Fixed broken code examples that mixed v1 and v2 APIs
  • Updated Go imports to include missing entity package
  • Corrected method calls to use proper v2 API structure

Documentation Flow Issues

  • Added conceptual introduction before code examples
  • Clear explanation of "Entitlements vs Decisions"
  • Progressive learning approach from basic to advanced

Missing Language Support

  • Added complete JavaScript/TypeScript examples (previously empty)
  • Consistent examples across Go, Java, and JavaScript

Lack of Best Practices

  • Added performance optimization guidance
  • Security considerations and error handling
  • Integration patterns and middleware examples

📋 Changes Made

Fixed Files:

  • code_samples/authorization/get_entitlements.mdx: Fixed v1→v2 API migration
  • code_samples/authorization/get_decision.mdx: Updated to proper v2 structure

New Files:

  • docs/sdks/authorization-improved.mdx: Comprehensive authorization guide
  • AUTHORIZATION_DOC_IMPROVEMENTS.md: Detailed analysis and improvement plan

✅ Key Improvements

Aspect Before After
API Consistency Mixed v1/v2 (broken) Consistent v2 API
Language Support Go + Java (partial) Go + Java + JavaScript
Learning Flow Jump to code Conceptual → Practical
Integration No guidance Middleware, patterns, best practices
Error Handling Basic log.Fatal Production-ready strategies

🎯 Community Impact

This addresses:

🧪 Testing

  • All Go examples compile with v2 API
  • JavaScript examples follow modern SDK patterns
  • Java examples updated for consistency
  • Documentation builds successfully

📖 Usage

The improved documentation provides:

  1. Quick Setup: Authentication and client initialization
  2. Core Concepts: When to use entitlements vs decisions
  3. Complete Examples: All languages with working code
  4. Advanced Patterns: Bulk operations, token auth, middleware
  5. Production Ready: Error handling, performance, security

Ready for review and integration into the main documentation site.

@jp-ayyappan jp-ayyappan self-assigned this Aug 11, 2025
@jp-ayyappan jp-ayyappan requested a review from a team as a code owner August 11, 2025 15:08
Copy link

@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.

Summary of Changes

Hello @jp-ayyappan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the authorization SDK documentation to improve developer experience and address community feedback. It focuses on resolving API version inconsistencies in code examples, streamlining the documentation's learning flow, adding comprehensive JavaScript/TypeScript support, and integrating best practices for performance, security, and error handling. The changes aim to provide clearer, more consistent, and production-ready guidance for integrating authorization into applications.

Highlights

  • API Consistency: Migrated code examples from mixed v1/v2 APIs to consistent v2 API usage, resolving previously broken examples and ensuring compatibility.
  • Improved Documentation Structure and Flow: Introduced a new comprehensive guide (authorization-improved.mdx) with a progressive learning approach, starting with conceptual explanations like 'Entitlements vs. Decisions' before presenting code examples.
  • Expanded Language Support: Added complete JavaScript/TypeScript examples, ensuring consistent and comprehensive code coverage across Go, Java, and JavaScript for all major authorization patterns.
  • Best Practices and Integration Guidance: Incorporated crucial guidance on performance optimization, security considerations, robust error handling, and practical integration patterns such as middleware examples.
  • Detailed Documentation Analysis: A new document (AUTHORIZATION_DOC_IMPROVEMENTS.md) was added to detail the identified issues with the existing documentation and outline the comprehensive plan for its improvement.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@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 does an excellent job of overhauling the authorization SDK documentation, addressing API inconsistencies, and adding comprehensive examples for Go, Java, and JavaScript. The new authorization-improved.mdx guide is well-structured and a significant improvement. My review focuses on ensuring the new code examples are complete and runnable for developers. I've identified a few places where imports are missing in the Go and Java setup snippets, and a minor issue with an undefined variable in one of the Go examples. Addressing these points will make the documentation even more helpful and prevent compilation errors for users.

@jp-ayyappan jp-ayyappan added documentation Improvements or additions to documentation enhancement New feature or request javascript Pull requests that update javascript code labels Aug 11, 2025
@jp-ayyappan jp-ayyappan marked this pull request as draft August 11, 2025 16:10
@jp-ayyappan jp-ayyappan force-pushed the docs/improve-authorization-sdk-documentation branch from e394b11 to 1b86835 Compare August 11, 2025 16:13
@jp-ayyappan jp-ayyappan marked this pull request as ready for review August 11, 2025 16:16
@jp-ayyappan
Copy link
Contributor Author

/gemini review

Copy link

@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 provides a significant improvement to the authorization SDK documentation, fixing API version inconsistencies and adding comprehensive examples for multiple languages. The new documentation is well-structured and much more helpful for developers. My review focuses on further improving the clarity, consistency, and correctness of the new code examples in the docs/sdks/authorization.mdx file. I've suggested corrections for some minor typos, inconsistent API usage patterns, a misleading code comment, and a problematic error handling example.

pflynn-virtru
pflynn-virtru previously approved these changes Aug 11, 2025
@jp-ayyappan
Copy link
Contributor Author

/gemini review

Copy link

@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 is a great step forward in improving the documentation and fixing API inconsistencies. The new authorization.mdx guide is comprehensive and well-structured. My review focuses on a few key areas to ensure consistency across all code examples:

  • Updating remaining Java examples from the v1 to the v2 API to match the Go examples and the PR's goal.
  • Completing the language examples in the new documentation for sections that currently only show Go code.
  • Standardizing the code formatting in Java examples for better readability.
    Addressing these points will make the documentation even more valuable for developers.

pflynn-virtru
pflynn-virtru previously approved these changes Aug 11, 2025
@jp-ayyappan
Copy link
Contributor Author

Resolved in commit 08cabbe

Issue: Java GetDecision example was using outdated v1 GetDecisions API instead of v2 GetDecision API.

Fix: Updated code_samples/authorization/get_decision.mdx to use v2 API with proper EntityIdentifier structure:

  • Migrated from GetDecisionsRequest to GetDecisionRequest
  • Added proper EntityIdentifier with EntityChain structure
  • Updated imports to include required entity and policy packages
  • Changed class name from GetDecisions to GetDecision
  • Updated API call from getDecisions() to getDecision()

Now matches the Go example and maintains API version consistency across all languages.

Resolves review comment: #140 (comment)

@jp-ayyappan
Copy link
Contributor Author

Resolved in commit 08cabbe

Issue: Java GetEntitlements example was using v1 API instead of v2 API with EntityIdentifier.

Fix: Updated code_samples/authorization/get_entitlements.mdx to use v2 API pattern:

  • Added EntityIdentifier wrapper around entity chain structure
  • Updated imports to include io.opentdf.platform.entity.*
  • Modified request building to use setEntityIdentifier() pattern
  • Enhanced response handling to match v2 API patterns
  • Updated iteration logic for better output formatting

Now consistent with Go example and new documentation in docs/sdks/authorization.mdx.

Resolves review comment: #140 (comment)

@jp-ayyappan
Copy link
Contributor Author

Resolved in commit 08cabbe

Issue: Java code indentation was inconsistent across examples (8-space vs 4-space continuation indent).

Fix: Standardized all Java method chaining to use 4-space continuation indent in docs/sdks/authorization.mdx:

Before:

SDK sdk = builder.platformEndpoint(platformEndpoint)
        .clientSecret(clientId, clientSecret)
        .useInsecurePlaintextConnection(true)
        .build();

After:

SDK sdk = builder.platformEndpoint(platformEndpoint)
    .clientSecret(clientId, clientSecret)
    .useInsecurePlaintextConnection(true)
    .build();

Now all Java examples use consistent 4-space indentation for better readability.

Resolves review comment: #140 (comment)

@jp-ayyappan
Copy link
Contributor Author

Resolved in commit 08cabbe

Issue: Several sections were missing Java and JavaScript examples, only showing Go code.

Fix: Added comprehensive Java and JavaScript examples to all missing sections in docs/sdks/authorization.mdx:

Entitlements with Scope (was line 215+)

  • Added Java example with setWithComprehensiveHierarchy(true)
  • Added JavaScript example with withComprehensiveHierarchy: true

Bulk Authorization Decisions (was line 401+)

  • Added complete Java example with GetDecisionBulkRequest and multiple resources
  • Added JavaScript example with proper bulk request structure and response handling

Token-Based Authentication Example (was line 482+)

  • Added Java example with Token.newBuilder().setJwt(jwtToken)
  • Added JavaScript example with token-based entity identifier

All sections now have complete Go, Java, and JavaScript coverage for better developer experience.

Resolves review comment: #140 (comment)

Copy link
Contributor Author

@jp-ayyappan jp-ayyappan left a comment

Choose a reason for hiding this comment

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

Comment 2267505396: Addressed via commit 08cabbe

Copy link
Contributor Author

@jp-ayyappan jp-ayyappan left a comment

Choose a reason for hiding this comment

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

Addressing review comments with commit 08cabbe

@jp-ayyappan
Copy link
Contributor Author

/gemini review

Copy link

@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 provides a significant improvement to the authorization SDK documentation, migrating examples to the v2 API and adding comprehensive guides for Go, Java, and JavaScript. The changes are well-structured and address the key issues outlined in the description, such as API version inconsistencies and missing language support. The new authorization.mdx guide is particularly valuable.

I've found one minor issue in a Go code sample within the new documentation. My detailed feedback is in the review comments. Overall, this is a great contribution to improving the developer experience.

@jp-ayyappan
Copy link
Contributor Author

/gemini review

Copy link

@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 does a great job of improving the authorization SDK documentation and fixing API version inconsistencies. The new documentation is much more comprehensive and provides valuable examples for Go, Java, and JavaScript. I've identified a few areas with opportunities for improvement, including some minor inefficiencies in code samples, a critical bug in a JavaScript example, and some remaining API inconsistencies in the Go examples. Addressing these points will further enhance the quality and correctness of the documentation.

- Fix Go error handling example to use v2 API (authorizationv2.GetDecisionRequest)
- Fix Go constant in decision example (authorization.DecisionResponse_DECISION_PERMIT)
- Add note explaining getEntitlementsWithScope uses v1 API for WithComprehensiveHierarchy feature
- Improve Java example efficiency by storing decision in local variable

Addresses critical issues with incorrect Go API types and constants that would
cause compilation errors for developers following the documentation.
…mple

- Add Entity_CategorySchema to the import statement in get_decision.mdx
- Fixes runtime error when Entity_CategorySchema.SUBJECT is used on line 244
- Addresses GitHub PR comment #2278054492

This ensures the JavaScript code sample will run without import errors.
pflynn-virtru
pflynn-virtru previously approved these changes Aug 15, 2025
resolving comments

Co-authored-by: Eugene Yakhnenko <eugenioenko@gmail.com>
b-long
b-long previously approved these changes Aug 23, 2025
@jp-ayyappan jp-ayyappan enabled auto-merge (squash) August 23, 2025 14:30
The architecture documentation is updated to make the OpenTDF services the primary focus. The diagram and narrative now lead with OpenTDF components, referencing the NIST ABAC model as the underlying framework. This change improves clarity by centering the explanation on the platform's concrete services while still highlighting its standards-based design.
This commit completely revises the architecture documentation with a new structure and improved content based on extensive feedback.

The key changes include:
- **Narrative Focus:** The document is now centered on the OpenTDF components, with the NIST ABAC model used as supporting context rather than the primary structure.
- **New Diagram:** A new, portrait-oriented Mermaid diagram is used to improve readability on standard screens.
- **Clickable Elements:** The nodes in the Mermaid diagram and the section headings for each component are now linked to their respective documentation pages for easier navigation.
- **External Links:** The text now includes links to the NIST homepage and their official guide on ABAC for further reading.
- **Layout:** The page now uses a single-column layout with the diagram presented above the explanatory text.
@jp-ayyappan
Copy link
Contributor Author

jp-ayyappan commented Aug 25, 2025

/gemini review

@jp-ayyappan jp-ayyappan merged commit 79162c6 into main Aug 25, 2025
3 checks passed
@jp-ayyappan jp-ayyappan deleted the docs/improve-authorization-sdk-documentation branch August 25, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants