Add token_endpoint_auth_method configuration for OIDC providers to fix Okta authentication #3360
+227
−16
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.
Problem
Semaphore was failing OIDC authentication with Okta (and potentially other identity providers) with a persistent
invalid_client
error during the Authorization Code Exchange step. The root cause was a protocol mismatch in how client credentials are transmitted to the token endpoint:Authorization: Basic
header (client_secret_basic
)client_secret_post
)This mismatch caused Okta to reject authentication requests even when all other configuration (Issuer URL, Redirect URI, Client ID/Secret) was correct.
Solution
This PR adds support for configuring the token endpoint authentication method in OIDC provider configurations. Users can now explicitly specify how credentials should be sent during the OAuth2 token exchange.
Changes
New Configuration Field: Added
token_endpoint_auth_method
to theOidcProvider
struct"client_secret_post"
,"client_secret_basic"
, or empty (auto-detect)Authentication Logic: Modified
getOidcProvider()
to configure the OAuth2 endpoint'sAuthStyle
based on provider settings:Comprehensive Testing: Added 3 new tests covering all authentication methods (all tests passing)
Documentation: Created example Okta configuration with detailed setup instructions and troubleshooting guide
Usage
For Okta (or other providers requiring POST body credentials):
Or via environment variable:
Technical Details
The implementation uses the Go
golang.org/x/oauth2
library's built-inAuthStyle
support:AuthStyleInParams
(1) - Sends credentials in POST body (client_secret_post
)AuthStyleInHeader
(2) - Sends credentials in Authorization header (client_secret_basic
)AuthStyleAutoDetect
(0) - Auto-detect based on provider (default, maintains backward compatibility)Backward Compatibility
✅ Full backward compatibility maintained:
token_endpoint_auth_method
continue to work unchangedTesting
Fixes #[issue_number]
Original prompt
Fixes #3348
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.