mcp-auth 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +43 -0
- data/CONTRIBUTING.md +107 -0
- data/LICENSE.txt +21 -0
- data/README.md +869 -0
- data/Rakefile +8 -0
- data/app/controllers/mcp/auth/oauth_controller.rb +494 -0
- data/app/controllers/mcp/auth/well_known_controller.rb +147 -0
- data/app/models/mcp/auth/access_token.rb +30 -0
- data/app/models/mcp/auth/authorization_code.rb +33 -0
- data/app/models/mcp/auth/oauth_client.rb +60 -0
- data/app/models/mcp/auth/refresh_token.rb +32 -0
- data/app/views/mcp/auth/consent.html.erb +527 -0
- data/config/routes.rb +43 -0
- data/lib/generators/mcp/auth/install_generator.rb +80 -0
- data/lib/generators/mcp/auth/templates/README +114 -0
- data/lib/generators/mcp/auth/templates/create_access_tokens.rb.erb +23 -0
- data/lib/generators/mcp/auth/templates/create_authorization_codes.rb.erb +26 -0
- data/lib/generators/mcp/auth/templates/create_oauth_clients.rb.erb +22 -0
- data/lib/generators/mcp/auth/templates/create_refresh_tokens.rb.erb +22 -0
- data/lib/generators/mcp/auth/templates/initializer.rb +199 -0
- data/lib/generators/mcp/auth/templates/views/consent.html.erb +527 -0
- data/lib/mcp/auth/engine.rb +32 -0
- data/lib/mcp/auth/scope_registry.rb +113 -0
- data/lib/mcp/auth/services/authorization_service.rb +102 -0
- data/lib/mcp/auth/services/token_service.rb +230 -0
- data/lib/mcp/auth/version.rb +7 -0
- data/lib/mcp/auth.rb +109 -0
- data/lib/tasks/mcp_auth_tasks.rake +89 -0
- metadata +254 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2f3afa0eeb6e176bc47801df4caf7b5298646f86c53c2607b2ac28781abe1f83
|
|
4
|
+
data.tar.gz: 0bbb349fcb1ac5b8ad142946f742a1e75bb9ebdcf11f041f2c9eaf081b8b9d5f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b51073154b563e332913f9a08773acd618858b9a6e067ddb4145ddc73a2a5da86c830c93b75a87fc496e6c7e35ac8e064f18cd3fbabec8920fb3f17dea5a8545
|
|
7
|
+
data.tar.gz: 2f003c85cfa923ea611550c0d2c0f7a86b7c8c7e98ec1d64d2de2c25e50a295b1577209ef3cc500f0168c53135de56763580c94e946d9a6e31c16c72f77f283d
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2025-01-10
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Initial release of MCP Auth gem
|
|
14
|
+
- OAuth 2.1 authorization flow implementation
|
|
15
|
+
- PKCE support (RFC 7636) with S256 method requirement
|
|
16
|
+
- Dynamic Client Registration (RFC 7591)
|
|
17
|
+
- Token Revocation (RFC 7009)
|
|
18
|
+
- Token Introspection (RFC 7662)
|
|
19
|
+
- Authorization Server Metadata (RFC 8414)
|
|
20
|
+
- Protected Resource Metadata (RFC 9728)
|
|
21
|
+
- Resource Indicators support (RFC 8707) for token audience binding
|
|
22
|
+
- OpenID Connect Discovery support
|
|
23
|
+
- Automatic middleware for protecting `/mcp/*` routes
|
|
24
|
+
- JWT access tokens with proper audience validation
|
|
25
|
+
- Refresh token rotation for enhanced security
|
|
26
|
+
- Database-backed token storage for revocation support
|
|
27
|
+
- Customizable user data fetching
|
|
28
|
+
- Rake tasks for token cleanup and management
|
|
29
|
+
- Beautiful consent screen UI
|
|
30
|
+
- Comprehensive test suite
|
|
31
|
+
- Full documentation and examples
|
|
32
|
+
|
|
33
|
+
### Security
|
|
34
|
+
- HTTPS enforcement for production environments
|
|
35
|
+
- Secure token generation using SecureRandom
|
|
36
|
+
- Constant-time string comparison for PKCE validation
|
|
37
|
+
- Short-lived access tokens (1 hour default)
|
|
38
|
+
- Automatic refresh token rotation
|
|
39
|
+
- Token audience validation to prevent confused deputy attacks
|
|
40
|
+
- WWW-Authenticate header with resource metadata on 401 responses
|
|
41
|
+
|
|
42
|
+
[Unreleased]: https://github.com/SerhiiBorozenets/mcp-auth/compare/v0.1.0...HEAD
|
|
43
|
+
[0.1.0]: https://github.com/SerhiiBorozenets/mcp-auth/releases/tag/v0.1.0
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Contributing to MCP Auth
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to MCP Auth! This document provides guidelines and instructions for contributing.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
Be respectful and inclusive. We're all here to build great software together.
|
|
8
|
+
|
|
9
|
+
## How to Contribute
|
|
10
|
+
|
|
11
|
+
### Reporting Bugs
|
|
12
|
+
|
|
13
|
+
Before creating bug reports, please check existing issues to avoid duplicates. When creating a bug report, include:
|
|
14
|
+
|
|
15
|
+
- Clear, descriptive title
|
|
16
|
+
- Steps to reproduce the issue
|
|
17
|
+
- Expected behavior
|
|
18
|
+
- Actual behavior
|
|
19
|
+
- Ruby and Rails versions
|
|
20
|
+
- Any relevant logs or error messages
|
|
21
|
+
|
|
22
|
+
### Suggesting Enhancements
|
|
23
|
+
|
|
24
|
+
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, include:
|
|
25
|
+
|
|
26
|
+
- Clear, descriptive title
|
|
27
|
+
- Detailed description of the proposed functionality
|
|
28
|
+
- Explanation of why this enhancement would be useful
|
|
29
|
+
- Possible implementation approach (optional)
|
|
30
|
+
|
|
31
|
+
### Pull Requests
|
|
32
|
+
|
|
33
|
+
1. Fork the repository
|
|
34
|
+
2. Create a new branch (`git checkout -b feature/amazing-feature`)
|
|
35
|
+
3. Make your changes
|
|
36
|
+
4. Add tests for your changes
|
|
37
|
+
5. Ensure all tests pass (`bundle exec rspec`)
|
|
38
|
+
6. Run RuboCop (`bundle exec rubocop`)
|
|
39
|
+
7. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
40
|
+
8. Push to the branch (`git push origin feature/amazing-feature`)
|
|
41
|
+
9. Open a Pull Request
|
|
42
|
+
|
|
43
|
+
#### Pull Request Guidelines
|
|
44
|
+
|
|
45
|
+
- Follow the existing code style
|
|
46
|
+
- Write clear, descriptive commit messages
|
|
47
|
+
- Include tests for new functionality
|
|
48
|
+
- Update documentation as needed
|
|
49
|
+
- Keep PRs focused on a single feature or bug fix
|
|
50
|
+
- Ensure CI passes before requesting review
|
|
51
|
+
|
|
52
|
+
## Development Setup
|
|
53
|
+
|
|
54
|
+
1. Clone the repository:
|
|
55
|
+
```bash
|
|
56
|
+
git clone https://github.com/SerhiiBorozenets/mcp-auth.git
|
|
57
|
+
cd mcp-auth
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. Install dependencies:
|
|
61
|
+
```bash
|
|
62
|
+
bundle install
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
3. Run tests:
|
|
66
|
+
```bash
|
|
67
|
+
bundle exec rspec
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
4. Run linter:
|
|
71
|
+
```bash
|
|
72
|
+
bundle exec rubocop
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Testing
|
|
76
|
+
|
|
77
|
+
- Write tests for all new features and bug fixes
|
|
78
|
+
- Maintain or improve code coverage
|
|
79
|
+
- Use RSpec for testing
|
|
80
|
+
- Follow existing test patterns
|
|
81
|
+
|
|
82
|
+
## Code Style
|
|
83
|
+
|
|
84
|
+
- Follow Ruby Style Guide
|
|
85
|
+
- Use RuboCop for linting
|
|
86
|
+
- Keep methods small and focused
|
|
87
|
+
- Write descriptive variable and method names
|
|
88
|
+
- Add comments for complex logic
|
|
89
|
+
|
|
90
|
+
## Documentation
|
|
91
|
+
|
|
92
|
+
- Update README.md for user-facing changes
|
|
93
|
+
- Add YARD documentation for public APIs
|
|
94
|
+
- Update CHANGELOG.md following Keep a Changelog format
|
|
95
|
+
- Include examples for new features
|
|
96
|
+
|
|
97
|
+
## Security
|
|
98
|
+
|
|
99
|
+
If you discover a security vulnerability, please email [security@example.com] instead of creating a public issue. We'll work with you to address it promptly.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
104
|
+
|
|
105
|
+
## Questions?
|
|
106
|
+
|
|
107
|
+
Feel free to open an issue for any questions about contributing!
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 [Your Name]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|