Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Add documentation for tool tokens #10276

Merged
merged 6 commits into from
Feb 15, 2025

Conversation

janthoXO
Copy link
Contributor

@janthoXO janthoXO commented Feb 6, 2025

Description

Add Documentation to explain Tool Tokens and Authorization for the Tokens. The @AllowedTools Annotation restricts Tool Tokens from only accessing certain routes

Find under Contributor Guide at Coding and Design Guidelines -> Server -> REST endpoint best practices for authorization -> Tool-Based Authorization Annotations

or at this https://artemis-platform--10276.org.readthedocs.build/en/10276/dev/guidelines/server.html#tool-based-authorization-annotations

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Review Progress

Documentation Review

  • Documentation Review 1
  • Documentation Review 2

Screenshots

image
image

Summary by CodeRabbit

Summary by CodeRabbit

  • Documentation
    • Enhanced server development guidelines focusing on authorization practices for REST endpoints.
    • Introduced the @AllowedTools(ToolTokenType.__) annotation to restrict access for tool-based requests.
    • Expanded sections on implicit pre- and post-authorization annotations to reinforce security and maintainability.

@coderabbitai pause

@janthoXO janthoXO self-assigned this Feb 6, 2025
@janthoXO janthoXO marked this pull request as ready for review February 6, 2025 17:29
@janthoXO janthoXO requested a review from a team as a code owner February 6, 2025 17:29
Copy link

coderabbitai bot commented Feb 6, 2025

Walkthrough

The changes update the server development guidelines by introducing a new authorization annotation, @AllowedTools(ToolTokenType.__). The documentation now includes a section on tool-based authorization, explaining how REST endpoints can restrict access for requests with a tool claim. The update also expands the guidelines on implicit pre- and post-authorization to include this new annotation and details how to obtain and use tool tokens while following the Principle of Least Privilege.

Changes

File(s) Change Summary
docs/.../server.rst Added a new section on "Tool-Based Authorization Annotations" detailing the usage of @AllowedTools(ToolTokenType.__). Expanded the implicit authorization section to include the new annotation, and provided best practices for tool token usage.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant AuthHandler

    Client->>Server: API Request (with/without tool token)
    Server->>AuthHandler: Validate tool token & @AllowedTools annotation
    AuthHandler-->>Server: Return authorization status
    Server-->>Client: Send response (access granted/denied)
Loading

Possibly related issues

Suggested labels

small, ready to merge

Suggested reviewers

  • cremertim
  • JohannesStoehr
  • SimonEntholzer
  • az108
  • xHadie
  • PaRangger
  • krusche

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/dev/guidelines/server.rst (2)

465-469: Update to Implicit Pre-Authorization Annotations

The addition of the AllowedTools(ToolTokenType.__) bullet clearly signals that tool-based requests must be explicitly whitelisted. This is a good enhancement to enforce the Principle of Least Privilege. Please ensure that elsewhere in the project any endpoints that can be accessed by tool tokens are updated accordingly, and consider clarifying in related documentation that ToolTokenType.__ is a placeholder which must be replaced with a concrete token type when implemented.


498-536: New "Tool-Based Authorization Annotations" Section

This newly added section comprehensively explains the purpose and usage of the @AllowedTools annotation. The section breaks down how tool tokens are handled versus regular requests, provides clear examples (including code blocks demonstrating proper usage), and outlines best practices. A minor suggestion:

  • Consider adding a brief note that ToolTokenType.__ in the earlier section is a placeholder and should be replaced by actual tool types (e.g., ToolTokenType.SCORPIO or ToolTokenType.VSCODE).

Otherwise, the content is well-organized and aligns with the project's security and documentation standards.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5691f2 and 2b6dba3.

📒 Files selected for processing (1)
  • docs/dev/guidelines/server.rst (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 6, 2025
simonbohnen
simonbohnen previously approved these changes Feb 8, 2025
Copy link

@simonbohnen simonbohnen left a comment

Choose a reason for hiding this comment

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

Fixed some small typos, looks good otherwise!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/dev/guidelines/server.rst (2)

519-523: Documented Best Practices for Tool-Based Authorization
The “Best Practices” block explains that endpoints accepting tool-based requests must be explicitly annotated and encourages adherence to the Principle of Least Privilege. Consider including a brief note advising that any changes to tool token behavior should be mirrored in this documentation to avoid discrepancies over time.


527-530: “How to Get Tool Tokens” Instructional Block
This step-by-step guide succinctly details how to obtain a Tool Token, including verifying the tool type in ToolTokenType.java and sending a POST request to the authentication endpoint. For added clarity, you might consider including a sample response or outlining potential error scenarios.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b6dba3 and fc8e295.

📒 Files selected for processing (1)
  • docs/dev/guidelines/server.rst (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
docs/dev/guidelines/server.rst (3)

464-468: Enhance Implicit Authorization Annotation List
The bullet list under “Implicit pre- and post-authorization annotations” now includes the new “AllowedTools(ToolTokenType.__)” annotation. The description clearly explains its role in restricting tool-based requests. Ensure that the language here is consistent with later detailed sections and that it aligns with the implementation in ToolTokenType.java.


498-508: New “Tool-Based Authorization Annotations” Section Added
This section introduces and explains the @AllowedTools annotation in a clear and accessible way. The header and accompanying description effectively differentiate between requests with and without tool claims. Verify that the inline code formatting (especially for JWT claim examples) renders correctly in the final documentation build.


509-517: Clear “When to Use It?” Guidelines with Example
The “When to Use It?” block provides a concise explanation along with a practical Java code example, demonstrating how to annotate an endpoint using @AllowedTools(ToolTokenType.SCORPIO). Confirm that the example (including the referenced DTO name) reflects the actual structures and naming conventions used in the codebase.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 8, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
docs/dev/guidelines/server.rst (1)

498-537: Review the new Tool-Based Authorization Annotations section.
The newly added section does an excellent job of explaining the use, behavior, and best practices for the @AllowedTools annotation, along with concrete examples. To further enhance clarity, verify that the placeholders (e.g., ToolTokenType.__) and examples (e.g., ToolTokenType.SCORPIO, ToolTokenType.VSCODE) match what is implemented in the codebase. Additionally, consider adding a reference or link to ToolTokenType.java for quick access.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc8e295 and fbd1f5f.

📒 Files selected for processing (1)
  • docs/dev/guidelines/server.rst (2 hunks)
🔇 Additional comments (1)
docs/dev/guidelines/server.rst (1)

465-468: Clarify the new AllowedTools bullet in implicit authorization guidelines.
The new bullet introducing AllowedTools(ToolTokenType.__) clearly indicates the intent to restrict tool-based requests. However, consider clarifying that ToolTokenType.__ is a placeholder to be replaced by a specific tool type, ensuring that readers do not mistakenly interpret it as a concrete value.

Copy link

@HawKhiem HawKhiem left a comment

Choose a reason for hiding this comment

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

I added styling to increase consistency

Copy link

@SindiBuklaji SindiBuklaji left a comment

Choose a reason for hiding this comment

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

Looks good👍

@janthoXO janthoXO changed the title Chore: Add Documentation for Tool Tokens General : Add Documentation for Tool Tokens Feb 9, 2025
@janthoXO janthoXO changed the title General : Add Documentation for Tool Tokens General: Add Documentation for Tool Tokens Feb 9, 2025
@janthoXO janthoXO requested a review from simonbohnen February 9, 2025 16:34
Copy link

@kevinfischer4 kevinfischer4 left a comment

Choose a reason for hiding this comment

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

Checked for style consistency, grammar and typos. Looks good 👍

Copy link

@HanyangXu0508 HanyangXu0508 left a comment

Choose a reason for hiding this comment

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

Looks nice for me.

Copy link

@vinceclifford vinceclifford left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link

@flbrgit flbrgit left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link

@simonbohnen simonbohnen left a comment

Choose a reason for hiding this comment

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

Looks good 👌🏼

Copy link

@sawys777 sawys777 left a comment

Choose a reason for hiding this comment

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

Great and clear documentation

@krusche krusche changed the title General: Add Documentation for Tool Tokens Development: Add documentation for tool tokens Feb 15, 2025
@krusche krusche added this to the 7.10.1 milestone Feb 15, 2025
@krusche krusche merged commit 3a1ebcd into develop Feb 15, 2025
12 of 16 checks passed
@krusche krusche deleted the chore/tool-token-documentation branch February 15, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

10 participants