fix: support secp256k1 elliptic curve for telegram OIDC
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
Resolves #2534
When attempting to use Telegram OIDC or any Custom OAuth provider that uses the secp256k1 elliptic curve in their JWKS, the authentication flow fails. The underlying go-jose library does not support secp256k1, leading to a failure when attempting to fetch and verify the identity token signature.
What is the new behavior?
This PR introduces a fallback mechanism in ParseIDToken. When verifier.Verify() fails due to an "unsupported elliptic curve" error, the fallback logic:
- Manually fetches the JWKS from the issuer.
- Identifies the
secp256k1EC key. - Performs ECDSA signature validation using the standard
crypto/ecdsapackage andgolang-jwt/jwt, powered bydecred/dcrd/dcrec/secp256k1(which is already a dependency). - Safely reconstructs the
*oidc.IDTokenstruct for downstream compatibility.
This allows Telegram OIDC to work out of the box without requiring forks of go-oidc or go-jose.
Assistance Disclosure
I used Antigravity (a Gemini-based AI coding assistant) to help write the boilerplate and crypto logic for this secp256k1 OIDC support. I have manually verified the implementation and added tests to ensure correctness.
Thank you for the excellent automated security scan findings! I have successfully addressed both the SSRF and OIDC token issuer verification bypass vulnerabilities in the latest commit:
- SSRF Protection: Integrated the internal
utilities.ValidateOAuthURL()andutilities.FetchURLWithTimeout()helper functions to enforce secure outbound connections and prevent private/internal network access. - Token Issuer Verification: Replaced the unverified
claims.Issfield with the trusted OIDC provider issuer URL fromprovider.Claims(), and added a strict equality check ensuring the unverified token's issuer perfectly matches the configured, trusted OIDC provider issuer.
The PR is updated, fully secure, and ready for review! 🚀
Hello, any update on this ?
Hello, any update on this ? It's been close to 2 full month this OIDC is unavailable in my app.