angel3_auth_client 10.0.1
angel3_auth_client: ^10.0.1 copied to clipboard
Angel3 library for authenticating users with external identity providers via OAuth2.
Change Log #
10.0.1 #
Fixes in 10.0.1 #
- Docs: The README is rewritten in plain English, with a table of contents, one complete GitHub example, and the login flow split into routes and cookies, several instances, errors and the HTTP client. The Null Safety badge link is fixed
10.0.0 #
Breaking changes in 10.0.0 #
- Breaking: Renamed from
angel3_auth_oauth2: depend onangel3_auth_client, and importpackage:angel3_auth_client/angel3_auth_client.dart - Breaking: Each login has a random
state, checked on the callback (against login CSRF), kept with its PKCE code verifier in a signed,HttpOnlycookie of its own, scoped to the path that the route that starts the login shares with the redirect URI, which expires after the newloginTimeout.authenticateCallbackrefuses a callback without it, asinvalid_statetoonError
New in 10.0.0 #
cookieName,cookieKey,cookieSameSite,cookiePath,loginTimeout,maxLogins,tokenTimeoutandhttpClient;tokenTimeout(default 30 seconds, and positive) is how long the token endpoint may take to answer, after which the callback is a 502;close()closes the strategy, after which a request to it is a 503, and its own HTTP client;cookiePathsets the path of the cookies of logins, as behind a proxy that maps another path to the app's; one that a cookie may not have throws anArgumentError, and one that is not the redirect URI's path or above it, of which every login fails, throws tooauthorizationParameters, more query parameters of the authorization URL, such asaccess_type,promptorresponse_modebasicAuth,falseto send the client secret to the token endpoint in the form (client_secret_post)- OpenID Connect:
openId, anOpenIdOptionsof the issuer and JSON Web Key Set of an OpenID Provider, or ofOpenIdOptions.discover, checks the ID token of each login (OpenID Connect Core 1.0 §3.1.3.7): of a key of the provider, ofRS256orES256and nevernonenorHS256, of its issuer, of the app as audience andazp, unexpired, of thenoncethat each login now sends, and of theat_hashof its access token. The verifier is given theIdTokeninreq.container; a token that is refused goes toonErrorasinvalid_token.OpenIdProvider.endSessionUrl, of theend_session_endpointit discovers, signs the user out of the provider too (OpenID Connect RP-Initiated Logout 1.0). The JSON Web Key Set, and the URLs thatdiscoverreads, must behttps; logins share a fetch of the keys, and keep those fetched before of a refresh that fails;discoverhas atimeout
Fixes in 10.0.0 #
- Callback: A
statethat is not of the form of one the strategy gives, as of a crafted link, goes toonErrorasinvalid_state, where one of a character a cookie name may not have, such as;or a space, was an error of the framework. Of a strategy ofresponse_mode=form_post, ofauthorizationParametersor of the query of the authorization endpoint, a posted callback whose body cannot be read, as a malformed, too large or not UTF-8 form, goes toonErrorasinvalid_request, where it was the framework's own 400, or the start of another login; a posted form that starts a login is of its query alone, as before, and so are the fields of a posted form that has nostate, as one that starts a login of a field namedcode, which was taken for a callback. Repeated query parameters of the authorization endpoint, such asresource, are kept, where only the last was, but those thatauthorizationParametersreplace. The cookie of a login that is refused, as one that timed out, is cleared, as that of one that is done. A callback without acode, and without anerror, goes toonErrorasinvalid_request, and a token response that cannot be read, as an error page of the provider, is a 502, as is a provider that cannot be reached, as of a TLS failure or no answer in time, which were a 500, where it wasinvalid_request; an error of the provider, as when the user refuses, goes toonErrorof itserror,error_descriptionanderror_uri, which is left out if it is not a URI. A callback whosestateshares the start of that of a login in progress, but is another, ends no login. A request is the callback if it has anerror, or acodeand astate, so that a link to the start of a login of acodeof its own, as of a referral, starts it, where it wasinvalid_state, while an error of nostatestill goes toonErrorasinvalid_state, rather than start another login; a refusal of the provider of a login that timed out, whose cookie shows it is of this browser, goes toonErroras that refusal, where it wasinvalid_state - HTTP clients: Without an
httpClient, the strategy's own client is shared by every login, rather than one of each, which the token exchange of a failure left open - Login cookies: Starting a login, or finishing one, expires the cookies of the oldest logins of the browser beyond the new
maxLogins(default 5), so that a user who starts many cannot make theCookieheader of the callback too large for the server; only cookies of logins that the strategy started are expired, not those of another strategy of the samecookieName, or of another client of the samecookieKey; and a callback of no login of the browser, as of a crafted link, expires none of those in progress.maxLoginsmust be at least 1, andloginTimeoutat least a second, of which the cookie would expire at once; the cookie'sMax-Ageis its whole seconds, rounded up, so that the browser keeps it as long as the server takes the login. A login started more thanloginTimeoutahead of now, as of an instance whose clock is ahead, is refused as one that timed out. A cookie of a login started byangel3_auth_oauth210.0.0, which does not name its client, is taken for one of each strategy of itscookieNameandcookieKey, until it expires. The cookies are of the path the start of the login shares with the redirect URI, so that the start is sent them - Settings:
response_mode=form_postwithoutSameSite.none, of which every login fails, throws anArgumentError; the strategy warns ofSameSite.noneof anhttpredirect URI, whose cookie browsers drop, and ofauthorizationParametersthat it drops, asscope. AcookieKeyof under 16 bytes, as of an unset variable of the environment, of which anyone could forge a login cookie, and acookieNamethat a cookie may not have, throw anArgumentError. The warning of a client without a secret names isolates, each of which has a random key of its own. AcookieKeymust be of bytes, of values of 0 to 255, as ofutf8.encode, not the code units of aString, of which the HMAC drops the high bits - Docs: The README samples compile, and the example's
parseParamsFromGithub, of the type ofgetParametersand of JSON values as they are, is passed, as GitHub answers the token request as a form - Example: Reads the credentials of a GitHub OAuth app from
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRET, where it had an app's id and secret in its source, and itsjwtKeyfromJWT_KEY, or a random one; its verifier refuses a login of no GitHub user, as of a failed request of GitHub's API, where it was of a user of no GitHub id, the same of every such login, as is the README's - Client without a secret: Sends its
client_idalone to the token endpoint, rather than an empty secret, by HTTP Basic or in the form - Starting a login: Redirects to the provider, where it answered
400: a request withcodeorerroris now the callback - PKCE: Each login uses its own code verifier for the token exchange, which providers that check PKCE refused
onError: Its result is never taken for a user (a declined login signed users in when users are maps), and is sent as the response. A malformed callback isinvalid_request, and an unreachable provider is a502form_post: A posted callback (e.g. Sign in with Apple) is read from its form, withcookieSameSite: SameSite.none- Cookies: Logins in two tabs no longer replace each other's, and a client without a secret signs with a random key
- Client: Logins share one HTTP client,
httpClientor one of the strategy's own, so that connections to the provider are kept, where each made one of its own; theoauth2.Clientgiven to the verifier is of it, and closing the strategy's own does nothing; a verifier that closes it closes neither, so thathttpClienttoo stays open for the logins after - Verifier: It may return
null, of aUserthat is not nullable, to refuse a user, whichAngelAuthanswers as any failed login: its type isFutureOr<User?> Function(...), of which a verifier ofFutureOr<User>is one onError: A response that it writes but does not close is closed, so thatAngelAuthdoes not answer it again, as with itsfailureRedirector a 401, nor try another strategy- Docs: The README tells how to install and use the package, and how to migrate from 9.x, how the routes are told apart and how a login is kept
9.1.0 #
- Require Dart >= 3.13
9.0.0 #
- Require Dart >= 3.12
8.4.0 #
- Require Dart >= 3.8
- Updated
lintsto 6.0.0 - Updated dependencies to the latest release
8.3.0 #
- Require Dart >= 3.6
- Updated
lintsto 5.0.0 - Updated dependencies to the latest release
8.2.0 #
- Require Dart >= 3.3
- Updated
lintsto 4.0.0
8.1.1 #
- Updated repository link
8.1.0 #
- Updated
lintsto 3.0.0 - Fixed linter warnings
8.0.0 #
- Require Dart >= 3.0
- Issue:
oauth2does not supporthttp1.0.0
7.0.1 #
- Updated example
7.0.0 #
- Require Dart >= 2.17
6.0.0 #
- Require Dart >= 2.16
5.0.0 #
- Skipped release
4.1.0 #
- Updated linter to
package:lints
4.0.2 #
- Updated example
4.0.1 #
- Updated README
4.0.0 #
- Migrated to support Dart >= 2.12 NNBD
3.0.0 #
- Migrated to work with Dart >= 2.12.x Non NNBD
2.1.0 #
- Angel 2 + Dart 2 update
- Support for handling errors + rejections.
- Use
ExternalAuthOptions.
2.0.0+1 #
- Meta update to improve Pub score.
2.0.0 #
- Angel 2 + Dart 2 updates.
1.0.2 #
Added getParameters to AngelOAuth2Options.