-
Notifications
You must be signed in to change notification settings - Fork 929
feat: implement RFC 6750 Bearer token authentication #18644
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
base: thomask33/06-27-feat_oauth2_implement_rfc_9728_protected_resource_metadata_endpoint
Are you sure you want to change the base?
Conversation
ff83df4
to
3665807
Compare
5898895
to
5be6c6a
Compare
3665807
to
56126dd
Compare
5be6c6a
to
fded148
Compare
fca6b9a
to
68baa21
Compare
68baa21
to
578e708
Compare
9b7f5d9
to
7ef25b1
Compare
578e708
to
26c0eeb
Compare
7ef25b1
to
f0608bc
Compare
26c0eeb
to
7b70f7f
Compare
f0608bc
to
c68a923
Compare
7b70f7f
to
1a9400e
Compare
c68a923
to
f55771a
Compare
5f946b1
to
14d91ac
Compare
f55771a
to
34af681
Compare
34af681
to
e72476e
Compare
14d91ac
to
0f4491b
Compare
0f4491b
to
8c975b5
Compare
1a99f3c
to
01a10ef
Compare
8c975b5
to
017f23f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the significance of extended
versus the regular test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was that rfc6750_test.go
contain basic RFC 6750 compliance tests (authentication methods, basic token validation), while the rfc6750_extended_test.go
contain security and edge case testing (malformed headers, precedence, WWW-Authenticate compliance, etc.).
017f23f
to
77e3e55
Compare
01a10ef
to
3b6d8ba
Compare
77e3e55
to
1e1e046
Compare
3b6d8ba
to
dac326d
Compare
1e1e046
to
17982a7
Compare
dac326d
to
1858134
Compare
- Add RFC 6750 bearer token extraction to APITokenFromRequest as fallback methods - Support Authorization: Bearer <token> header and access_token query parameter - Maintain backward compatibility by prioritizing existing custom methods first - Add WWW-Authenticate headers to 401/403 responses per RFC 6750 - Update Protected Resource Metadata to advertise bearer_methods_supported - Add comprehensive test suite for RFC 6750 compliance in rfc6750_test.go - Update MCP test scripts with bearer token authentication tests - Enhance CLAUDE.md with improved Go LSP tool usage guidelines Implements RFC 6750 Section 2.1 (Authorization Request Header Field) and 2.3 (URI Query Parameter). Maintains full backward compatibility with existing Coder authentication methods. Completes major MCP OAuth2 compliance milestone. Change-Id: Ic9c9057153b40728ad91b377d753a7ffd566add7 Signed-off-by: Thomas Kosiewski <tk@coder.com>
17982a7
to
119626d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving but would like a second pair of eyes.
// defaultIPAddressForTests returns a default IP address for test API keys | ||
func defaultIPAddressForTests() pqtype.Inet { | ||
return pqtype.Inet{ | ||
IPNet: net.IPNet{ | ||
IP: net.IPv4(127, 0, 0, 1), | ||
Mask: net.IPv4Mask(255, 255, 255, 255), | ||
}, | ||
Valid: true, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be needed anymore because you're using dbgen
// defaultIPAddressForTests returns a default IP address for test API keys | |
func defaultIPAddressForTests() pqtype.Inet { | |
return pqtype.Inet{ | |
IPNet: net.IPNet{ | |
IP: net.IPv4(127, 0, 0, 1), | |
Mask: net.IPv4Mask(255, 255, 255, 255), | |
}, | |
Valid: true, | |
} | |
} |
Add RFC 6750 Bearer Token Authentication Support
This PR implements RFC 6750 Bearer Token authentication as an additional authentication method for Coder's API. This allows clients to authenticate using standard OAuth 2.0 Bearer tokens in two ways:
Authorization: Bearer <token>
headeraccess_token
query parameterKey changes:
These authentication methods are added as fallback options, maintaining backward compatibility with Coder's existing authentication mechanisms. The existing authentication methods (cookies, session token header, etc.) still take precedence.
This implementation follows the OAuth 2.0 Bearer Token specification (RFC 6750) and improves interoperability with standard OAuth 2.0 clients.