Repository navigation
feat!: managers, zero-value providers, and a fake, shaped after socialite - #2
Merged
Merged
Conversation
…lite The package is rebuilt around Socialite's own structure. New makes a Manager, Socialite's SocialiteManager; Driver(name) on it hands back the driver with Redirect, User, Callback, UserFromToken and RefreshToken, and the chain of Scopes, SetScopes, With, RedirectURL and Stateless. There is no package-level state, so an application makes its manager at boot and a test makes its own and runs in parallel. A provider is a zero value registered with WithDriver[T]: Socialite's four abstract methods, Endpoint, Scoping, GetUserByToken and MapUserToStruct, with the credentials passed in so a provider can carry an issuer, a host or a client id. The driver fetches through the provider, maps through it, and attaches the token and the approved scopes. Google, GitHub, GitLab, Facebook, Bitbucket, LinkedIn, Slack, Twitch and X are built in, one file each; an OpenID Connect provider declares its issuer and the ID token is verified for signature, issuer, audience, expiry and nonce. Fake swaps a driver for Socialite's FakeProvider: a redirect to a URL nobody serves, the given user at the callback, and everything else forwarded to the driver it replaced. The chain keeps the fake. The handshake is an encrypted cookie under Key, or the application's own Session. It carries state, the PKCE verifier and the nonce, expires after ten minutes, and is spent whether the callback succeeds or not. PKCE is on unless a provider says it cannot; the cookie is Secure over TLS or when APIURL is https; a RedirectURL given as a path resolves against APIURL. Tests cover the package at 99.3%, the remainder being error returns that cannot occur. CI measures coverage of the package alone so the examples, whose main cannot run under test, do not count against it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The package is rebuilt around Socialite's own structure. New makes a
Manager, Socialite's SocialiteManager; Driver(name) on it hands back the
driver with Redirect, User, Callback, UserFromToken and RefreshToken, and
the chain of Scopes, SetScopes, With, RedirectURL and Stateless. There is
no package-level state, so an application makes its manager at boot and a
test makes its own and runs in parallel.
A provider is a zero value registered with WithDriver[T]: Socialite's four
abstract methods, Endpoint, Scoping, GetUserByToken and MapUserToStruct,
with the credentials passed in so a provider can carry an issuer, a host or
a client id. The driver fetches through the provider, maps through it, and
attaches the token and the approved scopes. Google, GitHub, GitLab,
Facebook, Bitbucket, LinkedIn, Slack, Twitch and X are built in, one file
each; an OpenID Connect provider declares its issuer and the ID token is
verified for signature, issuer, audience, expiry and nonce.
Fake swaps a driver for Socialite's FakeProvider: a redirect to a URL
nobody serves, the given user at the callback, and everything else
forwarded to the driver it replaced. The chain keeps the fake.
The handshake is an encrypted cookie under Key, or the application's own
Session. It carries state, the PKCE verifier and the nonce, expires after
ten minutes, and is spent whether the callback succeeds or not. PKCE is on
unless a provider says it cannot; the cookie is Secure over TLS or when
APIURL is https; a RedirectURL given as a path resolves against APIURL.
Tests cover the package at 99.3%, the remainder being error returns that
cannot occur. CI measures coverage of the package alone so the examples,
whose main cannot run under test, do not count against it.