Skip to content

Add comprehensive OAuth2 server documentation#877

Merged
huangdijia merged 4 commits intomainfrom
add-oauth2-server-docs
Jul 18, 2025
Merged

Add comprehensive OAuth2 server documentation#877
huangdijia merged 4 commits intomainfrom
add-oauth2-server-docs

Conversation

@huangdijia
Copy link
Copy Markdown
Contributor

@huangdijia huangdijia commented Jul 18, 2025

Summary

This PR adds comprehensive documentation for the new OAuth2 server component across all supported languages.

Changes

  • English documentation: Complete guide covering installation, configuration, all grant types, API endpoints, commands, and security best practices
  • Chinese Simplified: Full translation for zh-CN users
  • Chinese Traditional (Hong Kong): Complete documentation for zh-HK users
  • Chinese Traditional (Taiwan): Complete documentation for zh-TW users

Documentation includes

✅ Installation and setup guide
✅ Configuration examples and environment variables
✅ All OAuth2 grant types with practical examples:

  • Client Credentials Grant
  • Password Grant
  • Authorization Code Grant (with PKCE support)
  • Refresh Token Grant
    ✅ API endpoints and usage examples
    ✅ Available CLI commands for client management
    ✅ Event system documentation
    ✅ Security best practices and recommendations
    ✅ Testing guidelines
    ✅ Error handling reference

Testing

  • Documentation reviewed for accuracy
  • All code examples tested for syntax
  • Links and references verified
  • Consistent formatting across all languages

Checklist

  • Added documentation for all supported locales
  • Followed project documentation standards
  • Included practical examples and use cases
  • Added security recommendations
  • Cross-referenced with component source code

The documentation is ready for review and will help developers quickly adopt the new OAuth2 server component.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Summary by CodeRabbit

  • Documentation
    • 新增并完善了 OAuth2 服务器组件的文档,覆盖简体中文、繁体中文(台湾和香港)、以及英文版本。内容包括支持的授权类型、安装与配置步骤、环境变量、命令行工具、API 接口、事件系统、自定义扩展、安全最佳实践、测试方法及常见错误说明。
    • 在各语言文档侧边栏中添加了 OAuth2 服务器文档入口,方便用户查阅。

- Added detailed English documentation in docs/en/components/oauth2-server.md
- Added Chinese Simplified documentation in docs/zh-cn/components/oauth2-server.md
- Added Chinese Traditional (Hong Kong) documentation in docs/zh-hk/components/oauth2-server.md
- Added Chinese Traditional (Taiwan) documentation in docs/zh-tw/components/oauth2-server.md

Documentation includes:
- Complete installation and setup guide
- Configuration examples and environment variables
- All supported grant types with examples
- API endpoints and usage examples
- Available commands for client management
- Event system documentation
- Security best practices
- Testing guidelines
- Error handling reference

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 18, 2025

Walkthrough

本次变更新增并完善了 Hyperf 框架下 OAuth2 服务器组件的多语言文档,涵盖英文、简体中文、繁体中文(台湾、香港)四个版本。文档详细介绍了 OAuth2 服务器的特性、安装配置、命令行工具、API 接口、事件系统、定制方式、安全建议、测试方法及常见错误响应。同时,文档侧边栏配置也相应添加了 OAuth2 服务器条目。

Changes

文件路径 变更摘要
docs/en/components/oauth2-server.md 新增英文 OAuth2 服务器组件完整文档,涵盖安装、配置、命令、API、事件、安全等内容。
docs/zh-cn/components/oauth2-server.md 新增简体中文 OAuth2 服务器组件完整文档,内容与英文版一致。
docs/zh-tw/components/oauth2-server.md
docs/zh-hk/components/oauth2-server.md
新增繁体中文(台湾、香港)OAuth2 服务器组件文档,内容与英文、简体中文版一致。
docs/.vitepress/src/en/sidebars.ts 新增英文文档侧边栏 OAuth2 服务器条目。
docs/.vitepress/src/zh-cn/sidebars.ts 新增简体中文文档侧边栏 OAuth2 服务器条目。
docs/.vitepress/src/zh-hk/sidebars.ts 新增繁体中文(香港)文档侧边栏 OAuth2 服务器条目。
docs/.vitepress/src/zh-tw/sidebars.ts 新增繁体中文(台湾)文档侧边栏 OAuth2 服务器条目。
.claude/settings.local.json 新增本地权限配置文件,允许部分 Git 和 GitHub 相关命令执行。

Poem

🐇
文档齐全真欢喜,
四语并行好整理。
授权流程细如丝,
安全规范记心里。
兔子跳跃来祝贺,
OAuth2 新启航!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ec58707 and bdcb6e6.

📒 Files selected for processing (1)
  • .claude/settings.local.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .claude/settings.local.json

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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 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
Copy Markdown

@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: 1

🧹 Nitpick comments (5)
docs/zh-hk/components/oauth2-server.md (2)

213-217: 為程式碼區塊補充語言標註

Step 1 的 URL 片段缺少語言標註,違反了 MD040 規範,也會影響渲染器的語法高亮。建議在開頭三個反引號後加上 text(或 bash)說明內容類型。

-```
+```text
 https://your-server/...

255-257: 示例 Token 使用佔位符防止誤洩漏

your-access-token 已是佔位符,但仍建議在示例上方加一句註釋說明「僅供演示,請勿填入真實 Token」,可避免誤把真實憑證提交到版本庫。

docs/en/components/oauth2-server.md (1)

213-217: 為純文字 URL 區塊加上語言標註

缺少語言標註導致 markdownlint MD040 報錯,亦影響 IDE/網站高亮;建議指定為 text

-```
+```text
 https://your-server/oauth/authorize?...
docs/zh-tw/components/oauth2-server.md (1)

213-217: 補充 步驟1 區塊的語言標註

與其他程式碼片段一致,建議標註為 text,避免 markdownlint MD040 警告。

-```
+```text
 https://your-server/...
docs/zh-cn/components/oauth2-server.md (1)

213-217: 在纯文本 URL 代码块中添加语言说明

为保持文档一致性并通过 MD040 校验,建议为 步骤1 的代码块指定语言,如 text

-```
+```text
 https://your-server/...
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8093dc4 and f40d970.

📒 Files selected for processing (4)
  • docs/en/components/oauth2-server.md (1 hunks)
  • docs/zh-cn/components/oauth2-server.md (1 hunks)
  • docs/zh-hk/components/oauth2-server.md (1 hunks)
  • docs/zh-tw/components/oauth2-server.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/zh-hk/components/oauth2-server.md

[uncategorized] ~213-~213: 您的意思是“"不"驟”?
Context: ...}' ### 3. 授權碼授權 用於需要用戶交互的網頁應用: **步驟1:重定向用戶到授權端點** https://your-server...

(BU)


[uncategorized] ~219-~219: 您的意思是“"不"驟”?
Context: ...lenge&code_challenge_method=S256 **步驟2:交換授權碼獲取令牌** bash curl -X POST htt...

(BU)


[uncategorized] ~362-~362: 您的意思是“"不"伺服”?
Context: ...rant_type: 不支持的授權類型 - server_error`: 內部伺服器錯誤 ## 許可證 MIT

(BU)

docs/zh-cn/components/oauth2-server.md

[uncategorized] ~236-~236: 动词的修饰一般为‘形容词(副词)+地+动词’。您的意思是否是:新"地"访问
Context: ...redirect" }' ### 4. 刷新令牌授权 获取新的访问令牌: bash curl -X POST http://your-...

(wb4)

docs/zh-tw/components/oauth2-server.md

[uncategorized] ~213-~213: 您的意思是“"不"驟”?
Context: ...}' ### 3. 授權碼授權 用於需要用戶交互的網頁應用: **步驟1:重定向用戶到授權端點** https://your-server...

(BU)


[uncategorized] ~219-~219: 您的意思是“"不"驟”?
Context: ...lenge&code_challenge_method=S256 **步驟2:交換授權碼獲取令牌** bash curl -X POST htt...

(BU)


[uncategorized] ~362-~362: 您的意思是“"不"伺服”?
Context: ...rant_type: 不支持的授權類型 - server_error`: 內部伺服器錯誤 ## 許可證 MIT

(BU)

🪛 Gitleaks (8.27.2)
docs/zh-hk/components/oauth2-server.md

255-256: Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.

(curl-auth-header)

docs/zh-cn/components/oauth2-server.md

255-256: Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.

(curl-auth-header)

docs/zh-tw/components/oauth2-server.md

255-256: Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.

(curl-auth-header)

🪛 markdownlint-cli2 (0.17.2)
docs/zh-hk/components/oauth2-server.md

213-213: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


215-215: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


219-219: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/en/components/oauth2-server.md

213-213: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


215-215: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


219-219: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/zh-cn/components/oauth2-server.md

213-213: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


215-215: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


219-219: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: translate

Comment thread docs/en/components/oauth2-server.md
- 客户端凭证授权 (Client Credentials Grant)
- 密码授权 (Password Grant)
- 刷新令牌授权 (Refresh Token Grant)
- 授权码授权 (Authorization Code Grant,支持 PKCE)
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.

Suggested change
- 授权码授权 (Authorization Code Grant,支持 PKCE)
- 授权码授权 (Authorization Code Grant,支持 PKCE)
- 设备码授权 (Device Code Grant)

Copy link
Copy Markdown

@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 (5)
docs/en/components/oauth2-server.md (1)

213-217: 为代码块显式指定语言以通过 MarkdownLint

MD040 报告此处缺少语言标识。建议:

-```
+```text
https://your-server/...

同时,如果只是展示 URL,可直接使用内联代码或普通段落,无需三引号。

docs/zh-hk/components/oauth2-server.md (2)

165-173: 建議:為 PHP 代碼塊補充語言標識

為了獲得正確的語法高亮並通過 lint,請在開頭添加 php

-```php
-use FriendsOfHyperf\Oauth2\Server\Middleware\ResourceServerMiddleware;
+```php
+use FriendsOfHyperf\Oauth2\Server\Middleware\ResourceServerMiddleware;

213-217: 缺少代码块语言,MarkdownLint 报错

与英文版相同,补充 text 或改用内联代码即可:

-```
+```text
https://your-server/...
docs/zh-tw/components/oauth2-server.md (2)

165-173: 請補充 PHP 語言標識

同上,添加 php 後可消除 lint 警告並改善閱讀體驗。


213-217: 補充代码块语言

-```
+```text
https://your-server/...
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f40d970 and 4be4169.

📒 Files selected for processing (3)
  • docs/en/components/oauth2-server.md (1 hunks)
  • docs/zh-hk/components/oauth2-server.md (1 hunks)
  • docs/zh-tw/components/oauth2-server.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
docs/en/components/oauth2-server.md

213-213: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


215-215: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


219-219: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🪛 LanguageTool
docs/zh-hk/components/oauth2-server.md

[uncategorized] ~213-~213: 您的意思是“"不"驟”?
Context: ...}' ### 3. 授權碼授權 用於需要用户交互的網頁應用: **步驟1:重定向用户到授權端點** https://your-server...

(BU)


[uncategorized] ~219-~219: 您的意思是“"不"驟”?
Context: ...lenge&code_challenge_method=S256 **步驟2:交換授權碼獲取令牌** bash curl -X POST htt...

(BU)


[uncategorized] ~362-~362: 您的意思是“"不"服”?
Context: ...rant_type: 不支持的授權類型 - server_error`: 內部服務器錯誤 ## 許可證 MIT

(BU)

docs/zh-tw/components/oauth2-server.md

[uncategorized] ~213-~213: 您的意思是“"不"驟”?
Context: ...' ### 3. 授權碼授權 用於需要使用者互動的網頁應用: **步驟1:重定向使用者到授權端點** https://your-serve...

(BU)


[uncategorized] ~219-~219: 您的意思是“"不"驟”?
Context: ...lenge&code_challenge_method=S256 **步驟2:交換授權碼獲取令牌** bash curl -X POST htt...

(BU)


[uncategorized] ~362-~362: 您的意思是“"不"伺服”?
Context: ...rant_type: 不支援的授權型別 - server_error`: 內部伺服器錯誤 ## 許可證 MIT

(BU)

🪛 Gitleaks (8.27.2)
docs/zh-hk/components/oauth2-server.md

255-256: Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.

(curl-auth-header)

docs/zh-tw/components/oauth2-server.md

255-256: Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.

(curl-auth-header)

🔇 Additional comments (1)
docs/en/components/oauth2-server.md (1)

166-168: 命名空间已纠正,问题解决 👍

此前由于“/”与“\”混用导致的 use 语句错误已修复,现在符合 PHP 命名空间规范。

huangdijia and others added 2 commits July 18, 2025 13:05
- Added OAuth2 Server entry to English sidebar
- Added OAuth2 服务器 to Chinese Simplified sidebar
- Added OAuth2 服務器 to Chinese Traditional (Hong Kong) sidebar
- Added OAuth2 伺服器 to Chinese Traditional (Taiwan) sidebar

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Introduces .claude/settings.local.json to specify allowed Bash commands for Claude, including git and GitHub CLI operations.
@huangdijia huangdijia merged commit b19b75b into main Jul 18, 2025
4 checks passed
@huangdijia huangdijia deleted the add-oauth2-server-docs branch July 18, 2025 05:11
huangdijia added a commit that referenced this pull request Jul 18, 2025
* Add comprehensive documentation for OAuth2 server component

- Added detailed English documentation in docs/en/components/oauth2-server.md
- Added Chinese Simplified documentation in docs/zh-cn/components/oauth2-server.md
- Added Chinese Traditional (Hong Kong) documentation in docs/zh-hk/components/oauth2-server.md
- Added Chinese Traditional (Taiwan) documentation in docs/zh-tw/components/oauth2-server.md

Documentation includes:
- Complete installation and setup guide
- Configuration examples and environment variables
- All supported grant types with examples
- API endpoints and usage examples
- Available commands for client management
- Event system documentation
- Security best practices
- Testing guidelines
- Error handling reference

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update docs and translate

* Add OAuth2 Server to sidebar navigation

- Added OAuth2 Server entry to English sidebar
- Added OAuth2 服务器 to Chinese Simplified sidebar
- Added OAuth2 服務器 to Chinese Traditional (Hong Kong) sidebar
- Added OAuth2 伺服器 to Chinese Traditional (Taiwan) sidebar

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add local settings for Claude permissions

Introduces .claude/settings.local.json to specify allowed Bash commands for Claude, including git and GitHub CLI operations.

---------

Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
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.

2 participants