-
Notifications
You must be signed in to change notification settings - Fork 9
Add Support for Separate Authorization Server Mode #9
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
1bcb85b
Phase 1: Add configuration for integrated/separate auth modes
bhosmer-ant 98cec05
Phase 2: Extract shared auth logic
bhosmer-ant 0135abd
Phase 3: Implement MCP server mode switching
bhosmer-ant 03deb88
Fix build and lint issues
bhosmer-ant 4771c6e
Add retry logic and token caching
bhosmer-ant 5c408eb
Phase 4: Create standalone authorization server
bhosmer-ant 3f930c5
Phase 7: Complete README documentation for dual auth modes
bhosmer-ant b796560
add docker-compose.yml
bhosmer-ant d368c8d
address comments:
bhosmer-ant 9ffe376
Fix endpoint consistency and documentation accuracy
bhosmer-ant 40773bd
Add end-to-end verification scripts and fix server issues
bhosmer-ant 1e47b07
Update documentation for current implementation
bhosmer-ant 890beed
Add rate limiting and improve e2e testing workflow
bhosmer-ant ecd82f4
Add rate limiting to auth server static file endpoint
bhosmer-ant 4e3414f
Fix undefined staticFileRateLimit in auth server
bhosmer-ant fdbf40b
Simplify build scripts to catch all compilation errors
bhosmer-ant 5f545ce
Fix CI build by using public npm registry in package-lock.json
bhosmer-ant 67d9a94
improvements to README.md
bhosmer-ant 56a43ac
Fix OAuth metadata endpoint in separate mode
bhosmer-ant b32d638
Consolidate TypeScript build configuration
bhosmer-ant 4fe1374
Add debug logging for OAuth flow troubleshooting
bhosmer-ant 4a081bc
Improve e2e tests with OAuth flow validation
bhosmer-ant 34fe20e
Implement Redis namespace isolation for auth and MCP keys
bhosmer-ant e393cb2
Add OAuth protected resource metadata endpoint for separate mode
bhosmer-ant dbd3e9a
Revert OAuth metadata change for backwards compatibility
bhosmer-ant a735b98
Add comprehensive token validation to ExternalAuthVerifier
bhosmer-ant 67def73
Fix token audience validation in separate auth mode
bhosmer-ant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AUTH_MODE=integrated | ||
BASE_URI=http://localhost:3232 | ||
PORT=3232 | ||
REDIS_URL=redis://localhost:6379 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
AUTH_MODE=separate | ||
BASE_URI=http://localhost:3232 | ||
PORT=3232 | ||
REDIS_URL=redis://localhost:6379 | ||
AUTH_SERVER_URL=http://localhost:3001 | ||
AUTH_SERVER_PORT=3001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,3 +129,6 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# Claude config directory | ||
.claude/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# MCP Standalone Authorization Server | ||
|
||
This is a demonstration OAuth 2.0 authorization server for MCP. | ||
|
||
## Purpose | ||
|
||
This server demonstrates how MCP servers can delegate authentication to a separate | ||
authorization server (Mode 2 in our implementation). In production environments, | ||
you would typically use established OAuth providers like: | ||
|
||
- Auth0 | ||
- Okta | ||
- Google OAuth | ||
- GitHub OAuth | ||
- Microsoft Azure AD | ||
|
||
## Architecture | ||
|
||
When running in separate mode, the architecture looks like: | ||
|
||
1. MCP Client (e.g., Inspector) discovers auth server URL from MCP server metadata | ||
2. Client registers and authenticates directly with this auth server | ||
3. Auth server issues tokens | ||
4. MCP server validates tokens by calling this auth server's introspection endpoint | ||
|
||
## Endpoints | ||
|
||
- `/.well-known/oauth-authorization-server` - OAuth 2.0 server metadata | ||
- `/oauth/authorize` - Authorization endpoint | ||
- `/oauth/token` - Token endpoint | ||
- `/oauth/register` - Dynamic client registration | ||
- `/oauth/introspect` - Token introspection (for MCP server validation) | ||
- `/fakeupstreamauth/authorize` - Fake upstream auth page (demo only) | ||
- `/fakeupstreamauth/callback` - Fake upstream callback (demo only) | ||
- `/health` - Health check endpoint | ||
|
||
## Development | ||
|
||
This server shares Redis with the MCP server for development convenience. | ||
In production, these would typically be separate. | ||
|
||
## Running the Auth Server | ||
|
||
### Standalone | ||
```bash | ||
# From the repository root | ||
npm run dev:auth-server | ||
``` | ||
|
||
### With MCP Server (Separate Mode) | ||
```bash | ||
# Start both servers together | ||
npm run dev:with-separate-auth | ||
``` | ||
|
||
## Testing | ||
|
||
### Health Check | ||
```bash | ||
curl http://localhost:3001/health | ||
``` | ||
|
||
### OAuth Metadata | ||
```bash | ||
curl http://localhost:3001/.well-known/oauth-authorization-server | ||
``` | ||
|
||
### With MCP Inspector | ||
1. Start this auth server: `npm run dev:auth-server` | ||
2. Start MCP server in separate mode: `AUTH_MODE=separate npm run dev` | ||
3. Open Inspector: `npx -y @modelcontextprotocol/inspector` | ||
4. Connect to `http://localhost:3232` | ||
bhosmer-ant marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
5. Auth flow will redirect to this server (port 3001) | ||
|
||
## Configuration | ||
|
||
The auth server uses the same environment variables as the main server: | ||
- `AUTH_SERVER_PORT` - Port to run on (default: 3001) | ||
- `AUTH_SERVER_URL` - Base URL (default: http://localhost:3001) | ||
- `REDIS_URL` - Redis connection (shared with MCP server) | ||
|
||
## Production Considerations | ||
|
||
In production: | ||
- Use real OAuth providers instead of this demonstration server | ||
- Separate Redis instances for auth and resource servers | ||
- Enable HTTPS with proper certificates | ||
- Implement proper rate limiting and monitoring | ||
- Use secure client secrets and token rotation |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.