Skip to content

Commit 405720d

Browse files
authored
Release v0.3.0: OAuth Authentication Support
## 新機能 - OAuth 2.0 Authentication Code Flow with PKCE対応 - FastMCPのOIDCProxyを活用した二段階認証 - 本番環境向けリダイレクトURI制限機能 - セキュリティ強化とログ機能の改善 ## 主要な変更点 - 新しい認証モード: SHAREPOINT_AUTH_MODE=oauth - Azure AD v2.0対応のカスタムOIDCプロキシ - SharePoint専用トークン検証器 - OAuth設定の事前検証とFail Fast原則 ## 技術的詳細 - HTTPトランスポート専用(OAuth認証) - 証明書認証との後方互換性維持 - PKCE使用によるセキュリティ向上 - 設定の柔軟性とエラーハンドリング改善 詳細な技術記事: https://claude.ai での実装内容解説を参照
1 parent 7833655 commit 405720d

23 files changed

+1650
-883
lines changed

.env.example

Lines changed: 84 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,97 @@
1-
# SharePoint設定
1+
# ============================================================================
2+
# SharePoint Configuration / SharePoint設定
3+
# ============================================================================
4+
5+
# SharePoint site URL / SharePointサイトURL
26
SHAREPOINT_BASE_URL=https://yourcompany.sharepoint.com
7+
8+
# Azure AD Tenant ID / Azure ADテナントID
39
SHAREPOINT_TENANT_ID=your-tenant-id-here
4-
SHAREPOINT_CLIENT_ID=your-client-id-here
510

6-
# SHAREPOINT_SITE_NAMEで検索対象を指定(複数可、カンマ区切り)
7-
# @onedrive: OneDriveを検索対象に含める(SHAREPOINT_ONEDRIVE_PATHSが必要)
8-
# @all: テナント全体(セキュリティ上の理由から推奨されません)
9-
# サイト名: 特定のSharePointサイト
10-
# 例: @onedrive,team-site,project-alpha
11-
# SHAREPOINT_SITE_NAME=yoursite
11+
# Search targets (comma-separated) / 検索対象(カンマ区切り)
12+
# Options: @onedrive, @all, or site names / オプション: @onedrive、@all、またはサイト名
13+
# Example: @onedrive,team-site,project-alpha
14+
SHAREPOINT_SITE_NAME=yoursite
15+
16+
# ============================================================================
17+
# Authentication Mode / 認証モード
18+
# ============================================================================
1219

13-
# 証明書認証設定(ファイルパスまたはテキストのいずれかを指定)
14-
# 優先順位: 1. テキスト、2. ファイルパス
20+
# "certificate" or "oauth" (default: certificate)
21+
# "certificate" または "oauth"(デフォルト: certificate)
22+
SHAREPOINT_AUTH_MODE=certificate
1523

16-
# ファイルパスで指定する場合
17-
SHAREPOINT_CERTIFICATE_PATH=path/to/your/certificate.pem
18-
SHAREPOINT_PRIVATE_KEY_PATH=path/to/your/private_key.pem
24+
# ============================================================================
25+
# Certificate Authentication / 証明書認証
26+
# (Required when SHAREPOINT_AUTH_MODE=certificate)
27+
# (SHAREPOINT_AUTH_MODE=certificate の場合に必要)
28+
# ============================================================================
1929

20-
# または、テキストで直接指定する場合
21-
# テキストが設定されている場合、ファイルパスより優先されます
30+
# Azure AD Application (Client) ID / Azure ADアプリケーション(クライアント)ID
31+
SHAREPOINT_CLIENT_ID=your-client-id-here
32+
33+
# Certificate file paths / 証明書ファイルパス
34+
SHAREPOINT_CERTIFICATE_PATH=path/to/certificate.pem
35+
SHAREPOINT_PRIVATE_KEY_PATH=path/to/private_key.pem
36+
37+
# Or use text format (priority: text > path) / またはテキスト形式(優先: テキスト > パス)
2238
# SHAREPOINT_CERTIFICATE_TEXT="-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
2339
# SHAREPOINT_PRIVATE_KEY_TEXT="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"
2440

25-
# OneDrive設定(オプション)
26-
# 形式: [email protected][:/folder/path][,[email protected][:/folder/path]]...
27-
# 例: [email protected],[email protected]:/Documents/Projects
28-
# [email protected],[email protected]:/Documents/重要書類
41+
# ============================================================================
42+
# OAuth Authentication / OAuth認証
43+
# (Required when SHAREPOINT_AUTH_MODE=oauth, HTTP transport only)
44+
# (SHAREPOINT_AUTH_MODE=oauth の場合に必要、HTTPトランスポート専用)
45+
# ============================================================================
46+
47+
# OAuth Client ID (fallback to SHAREPOINT_CLIENT_ID if not set)
48+
# OAuthクライアントID(未設定の場合は SHAREPOINT_CLIENT_ID にフォールバック)
49+
# SHAREPOINT_OAUTH_CLIENT_ID=your-oauth-client-id-here
2950

30-
# 検索設定(オプション)
51+
# OAuth Client Secret (required for OAuth mode)
52+
# OAuthクライアントシークレット(OAuth認証で必須)
53+
# SHAREPOINT_OAUTH_CLIENT_SECRET=your-oauth-client-secret-here
54+
55+
# FastMCP server base URL (default: http://localhost:8000)
56+
# FastMCPサーバーのベースURL(デフォルト: http://localhost:8000)
57+
# Note: Register {BASE_URL}/auth/callback in Azure AD redirect URIs
58+
# 注: Azure ADのリダイレクトURIに {BASE_URL}/auth/callback を登録
59+
# SHAREPOINT_OAUTH_SERVER_BASE_URL=http://localhost:8000
60+
61+
# Allowed MCP client redirect URIs (comma-separated, supports wildcards)
62+
# 許可するMCPクライアントのリダイレクトURI(カンマ区切り、ワイルドカード対応)
63+
# If not set (commented out): All redirect URIs are allowed (convenient for development)
64+
# If set: Only specified patterns are allowed (recommended for production)
65+
# 未設定(コメントアウト): すべてのリダイレクトURIを許可(開発環境向け)
66+
# 設定済: 指定されたパターンのみ許可(本番環境推奨)
67+
# Example for production / 本番環境の例:
68+
# SHAREPOINT_OAUTH_ALLOWED_REDIRECT_URIS=https://claude.ai/*,https://*.anthropic.com/*
69+
# Example for local development / ローカル開発の例:
70+
# SHAREPOINT_OAUTH_ALLOWED_REDIRECT_URIS=http://localhost:*,http://127.0.0.1:*
71+
72+
# ============================================================================
73+
# OneDrive Settings (Optional) / OneDrive設定(オプション)
74+
# ============================================================================
75+
76+
# Format: [email protected][:/folder/path][,[email protected][:/folder/path]]
77+
# 形式: [email protected][:/folder/path][,[email protected][:/folder/path]]
78+
# Example: [email protected],[email protected]:/Documents/Projects
79+
# [email protected],[email protected]:/Documents/Important
80+
81+
# ============================================================================
82+
# Search Settings (Optional) / 検索設定(オプション)
83+
# ============================================================================
84+
85+
# Maximum search results / 最大検索結果数
3186
SHAREPOINT_DEFAULT_MAX_RESULTS=20
87+
88+
# Allowed file extensions / 許可するファイル拡張子
3289
SHAREPOINT_ALLOWED_FILE_EXTENSIONS=pdf,docx,xlsx,pptx,txt,md
3390

34-
# ツール説明文のカスタマイズ(オプション)
35-
# SHAREPOINT_SEARCH_TOOL_DESCRIPTION=社内文書を検索します
36-
# SHAREPOINT_DOWNLOAD_TOOL_DESCRIPTION=検索結果からファイルをダウンロードします
91+
# ============================================================================
92+
# Tool Descriptions (Optional) / ツール説明文(オプション)
93+
# ============================================================================
94+
95+
# Customize tool descriptions for MCP clients / MCPクライアント用のツール説明文をカスタマイズ
96+
# SHAREPOINT_SEARCH_TOOL_DESCRIPTION=Search internal documents
97+
# SHAREPOINT_DOWNLOAD_TOOL_DESCRIPTION=Download files from search results

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,7 @@ cert/
188188

189189
.claude/
190190
.ruff_cache/
191+
192+
# OAuth token cache
193+
.sharepoint_tokens.json
194+
.vscode/

CLAUDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ uv run lint # Lint code with ruff
3636
uv run fmt # Format code with ruff
3737
```
3838

39+
## Documentation Guidelines
40+
41+
**IMPORTANT**: When updating documentation, always update both English and Japanese versions:
42+
43+
- `README.md` and `README_ja.md` - Main project documentation
44+
- `docs/setup.md` and `docs/setup_ja.md` - Setup instructions
45+
- `docs/usage.md` and `docs/usage_ja.md` - Usage guide
46+
- `docs/development.md` and `docs/development_ja.md` - Development guide
47+
- `.env.example` - Include bilingual comments
48+
49+
Ensure consistency between English and Japanese documentation to maintain user experience for both language speakers.
50+
3951
## Coding Guidelines
4052

4153
**IMPORTANT**: Always run quality checks before committing:

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
FROM ghcr.io/astral-sh/uv:python3.12-bookworm
22

3+
# Pythonのバイトコードを生成しないように設定
4+
ENV PYTHONDONTWRITEBYTECODE=1
5+
# Pythonの標準出力をバッファリングしないように設定
6+
ENV PYTHONUNBUFFERED=1
7+
# Pythonのモジュール検索パスに現在のディレクトリを追加
8+
ENV PYTHONPATH=".:$PYTHONPATH"
39
# タイムゾーンを日本に設定
410
ENV TZ=Asia/Tokyo
511
# デフォルトのポート設定

0 commit comments

Comments
 (0)