Repository navigation
Releases
oauth4s 0.1.1
oauth4s 0.1.1
A small release that follows from wiring 0.1.0 into a real backend. It is binary compatible with 0.1.0 (checked by MiMa), so upgrading is a version bump.
Added
OAuth4sException, the common base ofOAuthExceptionandJwtException: a sign-in endpoint catches both with one handler, whether the server or the ID token refused.AuthorizationFlow.toFieldsandAuthorizationFlow.fromFieldskeep a flow in a session or cookie between the redirect and the callback. A missing field or a bad verifier comes back as anOAuthError.ClientId.parseandClientSecret.parseread a value from configuration. An empty value givesNoneinstead of throwing.StubHttpClient.routesByroutes with a partial function evaluated on each request and answers 404 to anything unrouted.- The README now has a table of what each provider's
UserProfileholds: whether the id is stable or per-application, the email, and whether the provider vouches for it.
Changed
OAuthError.MissingFieldnow reads'name' is missing.
Installation
libraryDependencies ++= Seq(
"now.sendline" %% "oauth4s-cats" % "0.1.1",
"now.sendline" %% "oauth4s-http-jdk" % "0.1.1",
"now.sendline" %% "oauth4s-providers" % "0.1.1",
"now.sendline" %% "oauth4s-testkit" % "0.1.1" % Test,
)Full list in CHANGELOG.md.
v0.1.0
oauth4s 0.1.0 — first public release
oauth4s is an OAuth 2.0 / 2.1 and OpenID Connect client for Scala 3, with eight providers ready to use. The runtime, the JSON codec and the HTTP client are pluggable modules, each wired in through a given. oauth4s-core depends on nothing outside the JDK and the Scala library.
The checks a specification asks you to remember are done by the types. PKCE is on unless you turn it off, and state and the RFC 9207 issuer are checked where the callback arrives. A confidential client cannot be built without its secret, and an endpoint is https or loopback. An ID token is verified before you can read it, and errors are values you can match on instead of strings.
What's in this release
Protocols
- OAuth 2.0 with OAuth 2.1 as the default:
- the authorization code flow with PKCE (S256),
state, the issuer check of RFC 9207 and an optionalnonce - the client credentials and refresh token grants
- the device authorization grant (RFC 8628), with polling
- token revocation (RFC 7009) and introspection (RFC 7662)
requestTokenfor any other grant
- the authorization code flow with PKCE (S256),
- Discovery per RFC 8414, falling back to the OpenID configuration; the issuer in the document is checked.
- OpenID Connect 1.0 (
oauth4s-oidc):- discovery, plus
openidand a nonce on authorization - ID token validation: signature,
iss,aud,azp,exp/nbfwith leeway,nonceandat_hash - UserInfo and RP-initiated logout
- discovery, plus
- JWT, JWK and JWKS (
oauth4s-jwt):- verification and signing for the RS, PS, ES and HS families, with an allow-list that admits only asymmetric algorithms by default
- a remote key set that is cached and refetched when a token carries an unknown
kid - PKCS#8 PEM private keys
TokenSource: a cached access token for client credentials or a refresh token.
Providers (oauth4s-providers)
- Google, Microsoft, Apple, Facebook, Instagram, Strava, VK ID and X, behind one
Provider[F]interface with a normalizedUserProfile. - Each provider's quirks are handled for you:
- Apple's ES256-minted client secret
- VK ID's
device_id - Instagram's wrapped token response
- Facebook's and Instagram's error shapes
Provider.oauthandProvider.oidcbuild a provider of your own.- X is supported on OAuth 2.0 with PKCE only. OAuth 1.0a is not and will not be.
Pluggable modules
- Runtimes:
oauth4s-cats,oauth4s-zio,oauth4s-kyo,oauth4s-rapid. Plainscala.util.Tryworks with no module at all. - HTTP clients:
oauth4s-http-jdk(java.net.http, no dependencies),oauth4s-http4s,oauth4s-sttp. - JSON codecs:
oauth4s-circe,oauth4s-zio-json,oauth4s-jsoniter. A built-in codec with no dependencies is the default, and it reads token responses as fast as circe does.
Testing
oauth4s-testkitprovides:StubHttpClientTestIssuerFakeAuthorizationServer, a loopback authorization server with discovery, PKCE verification, refresh token rotation, the device flow and signed ID tokens
- Every runtime, codec and HTTP client is tested against the same conformance suite for its SPI.
- An
itmodule:- runs an OpenID Connect login over real HTTP on Scala 3.10
- compiles every Scala block of the README and the recipes
- runs the recipes against the fake server
- CI on GitHub Actions compiles, runs the tests and the
ittests, checks formatting and runs the examples.
Docs
- The README, recipes, design notes, compatibility table, benchmarks and roadmap, also at https://oss.sendline.now/oauth4s/
- Examples for cats-effect, ZIO,
Tryand the providers.
Compatibility
- Built on the Scala 3.9.0 LTS; works on 3.9 and later.
- Runs on JDK 17 or newer.
oauth4s-rapidneeds 21 andoauth4s-kyoneeds 25, as the libraries they wrap do. - Built against cats-effect 3.7.1, ZIO 2.1.27, Kyo 1.0.0-RC7, rapid 2.9.10, http4s 0.23.39, sttp client4 4.1.3, circe 0.14.17, zio-json 1.1.3 and jsoniter-scala 2.43.0.
Installation
libraryDependencies ++= Seq(
"now.sendline" %% "oauth4s-cats" % "0.1.0", // core + cats-effect
"now.sendline" %% "oauth4s-http-jdk" % "0.1.0", // java.net.http: no HTTP library to add
"now.sendline" %% "oauth4s-providers" % "0.1.0", // Google, Microsoft, Apple, …; brings oidc and jwt
"now.sendline" %% "oauth4s-testkit" % "0.1.0" % Test,
)See the README for the quick start and the module table, and CHANGELOG.md for the full list.
This is the first tagged release, so the API may still change before 1.0. Issues and PRs are welcome; see CONTRIBUTING.md.