Building blocks for an OAuth 2.1 client.
(This is pre-release and not yet stable. It is initially built for the atproto OAuth requirements (DPoP, PAR))
See AtprotoOAuth for an example of using these to build a full featured client.
This package comprises components and compositions of those components with some adopter-supplied objects that handle application-specific state.
This package supplies:
- free functions under the
OAuthnamespace for making requests of OAuth endpoints. - object implementations of client authentication methods
- object implementations of DPoP request signing
To construct a full authentication flow, an adopter can
- Supply an implementation of the
Authorizerprotocol - OAuth4Swift provides an implementation of
performUserAuthentication, relying on the implementation ofAuthorizerto negotiate initial client authentication and produce a stubOAuth.ClientAuth.Authenticablefor the intitial authorization flow.performUserAuthenticationproduces a session archive. - The adopter can supply an implementation of
SessionCapabilitiesthat restores from aOAuth.SessionState.Archive. OAuth4Swift provides default implementations of protected resource requests and token refresh methods.
This library provides a SessionState and a corresponding, codable Archive. This state includes both immutable session state (clientId, issuingServer, initial grant scopes, and dPoPKey if using), and mutable state (refresh and auth tokens).
The client may have additional state that needs to be persisted - client auth state or application specific data conveyed as additional parameters in token responses. The client may choose to store them alongside a SessionState.Archive, but we don't reserve entries for this state within SessionState.Archive.
We welcome contributions!
Please follow our guidelines for contributing code
To give clarity of what is expected of our members, Germ has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the Code of Conduct