• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

go-pkgz / auth / 45053338163
89%

Build:
DEFAULT BRANCH: master
Ran 22 Nov 2026 06:10PM UTC
Jobs 1
Files 25
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

22 Nov 2026 06:08PM UTC coverage: 87.33% (+0.07%) from 87.262%
45053338163

push

github

web-flow
Add an OAuth 2.0 provider for X (Twitter) to v2 (#332)

* Add an OAuth 2.0 provider for X (Twitter) to v2

Previously, the only way to sign in with X was the OAuth 1.0a `twitter`
provider, which reads the user from API v1.1. X's documentation
describes v1.1 as limited support and points new projects to v2.

After this change, v2 has `NewTwitterV2`, registered as
`AddProvider("twitter_v2", clientID, clientSecret)`. It uses the
authorization code flow with PKCE, authenticates at the token endpoint
with the Basic header only and reads the user from `GET /2/users/me`.
The provider name stays `twitter` and the user ID is derived from the
account ID as in `NewTwitter`, so the routes, the callback URL and the
user IDs are the same with either provider. `NewTwitter` is unchanged.

In v2, `Oauth2Handler.AuthHandler` now returns HTTP 503 without issuing
a session when any OAuth 2.0 or custom provider maps a user to an empty
ID. This prevents different users from sharing an empty identity.
`NewTwitterV2` returns an empty ID unless `data.id` is a non-empty
string; custom providers using `CustomHandlerOpt.MapUserFn` must also
return a non-empty ID.

The README Twitter section gets the current X console steps for both
providers.

* Refuse a user mapped to an empty ID in the v1 OAuth2 callback

`Oauth2Handler.AuthHandler` already rejects empty user IDs in v2.
The v1 handler could still issue sessions for users mapped to an empty
ID, allowing different users to share an identity. Return HTTP 503 in
v1 as well to keep this behaviour consistent across both modules.

`TestOauth2LoginRejectsEmptyUserID` covers the refusal in both modules
with a provider that maps a user without an ID.

* Document that MapUserFn must return an empty ID for a user without one

The OAuth2 callback refuses a user mapped to an empty ID, but a mapper
that hashes the source id without checking it never returns one: a
prefix plus a hash of an empty value is a valid ID shared by every such
login.... (continued)

5 of 5 new or added lines in 1 file covered. (100.0%)

3398 of 3891 relevant lines covered (87.33%)

10.76 hits per line

Jobs
ID Job ID Ran Files Coverage
1 45053338163.1 22 Nov 2026 06:10PM UTC 25
87.33
GitHub Action Run
Source Files on build 45053338163
  • Tree
  • List 25
  • Changed 3
  • Source Changed 0
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 57c7be7e on github
  • Prev Build on master (#44944187456)
  • Next Build on master (#45053338132)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc