Skip to content

Releases

1.1.0

Choose a tag to compare

@jozefizso jozefizso released this 19 Nov 23:09
1.1.0
0da6147

This release renames the main objects so that each one says which OAuth party it talks to (ADR 0016):
OAuthClient for the authorization server, OAuthSession for the signed-in user and ProtectedResourceClient for
the protected resource. The renames break source compatibility in a minor release. This is a deliberate exception to
the promise of 1.0.0, made while the library has no known consumers, and no deprecated aliases are kept. Protocol
behaviour and the format of stored credentials are unchanged, so signed-in users stay signed in after the update.

Added

  • CredentialStore lists its built-in stores as static members, so store: .keychain() and store: .inMemory()
    appear in autocomplete. They take the parameters of the KeychainCredentialStore and InMemoryCredentialStore
    initializers.
  • Documentation of what signing in and out leave at the server: OAuthSession.signIn(with:requestedScope:) adopts
    tokens and authenticates nobody, and signOut(revoke:) leaves the person signed in at the authorization server.
    The session article and the spec name an ephemeral browser session as the only control the client enforces, and
    say that prompt=login (OpenID Connect Core §3.1.2.1) is a request that the server may ignore.

Changed

  • Breaking: TokenManager is OAuthSession, so the two entry points OAuthClient and OAuthSession appear
    together in autocomplete. load() is restore(). invalidate(_:) is discard(_:), because it drops a cached
    token and sends nothing to the server.
  • Breaking: the types that belong to the session are nested in it. SessionEvent is OAuthSession.Event, and
    SignOutReason, SignOutResult and PendingSignOut are OAuthSession.SignOutReason,
    OAuthSession.SignOutResult and OAuthSession.PendingSignOut.
  • Breaking: the event refreshed(target:) is accessTokenUpdated(target:), because a token exchange emits it
    too. Its documentation states that the session caches the token only when its lifetime is known, and that a
    sign-in and exchangeRefreshToken do not emit it.
  • Breaking: CredentialCoding.encode(_:) and CredentialCoding.decode(_:) are Credential.serializedData()
    and Credential(serializedData:). The record format and its version are unchanged, so credentials stored by 1.0
    stay readable.
  • Breaking: RequestAuthorizer is ProtectedResourceClient, because it talks to a protected resource (RFC 6749
    §1.1) and "authorize" names the sign-in flow. Its initializer takes session: instead of manager:.
    sign(_:for:) is addingToken(to:for:), because a bearer token is not a signature.
    data(for:target:session:) is data(for:target:urlSession:), because "session" means the OAuth session.
    RetryDecision is ProtectedResourceClient.RetryDecision.
  • Breaking: PassportObserver is RequestObserver and PassportEvent is RequestEvent, because the events
    report requests and the Passport prefix said only which library they come from. EndpointKind is
    RequestEvent.Endpoint. PassportError is the only type left with the library prefix.

Removed

  • Breaking: EndpointKind.resource. No code emitted it, so an observer never received it.

1.0.1

Choose a tag to compare

@github-actions github-actions released this 01 Nov 21:36
1.0.1
8b8127c

Fixed

  • An app that depends on PassportKit through Xcode can build it again. Package.swift treated all warnings as errors,
    which Xcode combines with the -suppress-warnings it uses for remote packages and then refuses ("conflicting options
    '-warnings-as-errors' and '-suppress-warnings'"). Warnings are now errors only in this repository's own make
    targets.

1.0.0

Choose a tag to compare

@github-actions github-actions released this 01 Nov 20:42
1.0.0
93b5c24

The first stable release: from here on, a breaking change to the public API of PassportKit or PassportKitTesting
needs a new major version.

Added

  • OAuthClient.revokeBestEffort(_:typeHint:timeLimit:) revokes a token best effort (RFC 7009) and returns a
    RevocationOutcome instead of throwing: revoked, failed, timedOut after the limit on the client's clock,
    cancelled, or skipped without a revocation endpoint. It is for a token that never became a session, such as a
    refresh token the app obtained but did not adopt. The limit defaults to OAuthClient.revocationTimeLimit (5
    seconds), the limit TokenManager applies on sign-out, so apps need not copy it.
  • TokenManager.beginSignOut(revoke:) clears the session without suspending and returns a PendingSignOut, whose
    result (get async, like Task.value) waits for the store delete and the revocation (RFC 7009) and returns the
    SignOutResult. Apps no longer need to watch for .signedOut(.userInitiated) to learn that the session is gone
    (ADR 0014).

Changed

  • Breaking: OAuthClient.beginAuthorization(_:) throws .invalidConfiguration when prompt combines
    .noInteraction (none) with another value, which OpenID Connect Core §3.1.2.1 forbids. Such a request used to be
    sent.
  • Breaking: LoopbackRedirectListener.waitForCallback(timeout:accept:) is waitForCallback(timeLimit:accept:)
    and LoopbackUserAgent(listener:timeout:openURL:) is LoopbackUserAgent(listener:timeLimit:openURL:), matching
    the timeLimit of the other APIs that give up after a duration on the injected clock.
  • Breaking: the members of PassportError (code, recovery, statusCode, errorURI, underlying) are
    read-only outside the library, like detail already was. Create an error with the initializers instead of
    changing one.
  • Breaking: SignOutResult.Revocation is the top-level RevocationOutcome, shared by sign-out and
    OAuthClient.revokeBestEffort(_:typeHint:timeLimit:); SignOutResult.revocation has that type. Its cases are
    unchanged.
  • Breaking: TokenManager.exchangeRefreshToken returns the response when the server answered, even if the
    session ended or was replaced while the request was in flight; it used to throw .notAuthenticated and drop the
    issued token, which stayed valid at the server. The rotated subject still goes to the ended session's revocation
    and the new session is not touched. Callers that must not use a token of an ended session check their own state
    and revoke it as the audience client (ADR 0015).
  • Breaking: the response of TokenManager.exchangeRefreshToken has refreshToken set to nil. The rotated
    refresh token belongs to the session, which saves it; handing it out invited presenting it twice.
  • TokenManager.signOut(revoke:) is beginSignOut(revoke:) followed by await result. The revocation's time
    limit and its log line now run in a task the manager owns, so a revocation outcome is logged even when the caller
    of signOut was cancelled. Results are unchanged.
  • Every public enumeration states whether it is frozen. TokenAcceptance and JSONValue are frozen; PassportEvent,
    IssuerValidation, Discovery.Style, KeychainCredentialStore.Accessibility and the enumerations of
    PassportKitTesting may gain cases in a minor release, so a switch over them needs a default.

Removed

  • Breaking: Credential.additionalFields and the matching initializer parameter. Nothing in the library set or
    read it, and TokenManager offered no way to fill it. Stored records that carry the field still decode; the field
    is ignored.

Fixed

  • A Retry-After in the obsolete RFC 850 date form with a two-digit year up to 50 years ahead is read as a future
    date (RFC 9110 §5.6.7); years 46 to 76 used to be read as the 20th century, which made the delay zero.
  • LoopbackUserAgent installs its state filter before it opens the browser, so a request with another state
    that reaches the listener while the browser opens is refused instead of being taken as the redirect.
  • TokenManager.load() reads the store only after every save and delete decided before it, so a load that runs
    while the delete of a signed-out or rejected session is still in progress no longer restores that session.
  • KeychainCredentialStore updates an existing item in place instead of deleting it and adding it again, so a save
    that fails (device locked, denied prompt) or a process that dies mid-save no longer loses the stored credential,
    and stores writing the same item at once no longer fail with errSecDuplicateItem. A save whose payload could not
    be archived fails with .storageFailure instead of storing an item without data.
  • KeychainCredentialStore finds, replaces and deletes its item by class, service, account and access group, never
    by accessibility class. An app that changes accessibility keeps its stored credential (on iOS it was no longer
    found), and the next save moves the item to the new class.
  • The documentation of RequestAuthorizer.sign(_:for:) for HTTPRequest and of URLSessionTransport states that
    the never-indexed marking of Authorization (RFC 7541 §7.1.3) reaches the wire only through a transport that keeps
    the indexing strategy of HTTPFields. URLSessionTransport converts to URLRequest, which drops it.
  • DeviceAuthorization.expiresAt keeps the fractional part of a fractional expires_in instead of truncating it to
    whole seconds.

0.3.2

Choose a tag to compare

@github-actions github-actions released this 19 Oct 12:08
0.3.2
ccb691b

Changed

  • Expected failures are logged at .notice instead of .warning, so apps that forward .info and above to remote
    logging no longer report them: a request to the authorization server that failed for lack of connectivity (offline,
    timeout, DNS), a revocation on sign-out that failed that way or timed out, and a renewed access token that the
    resource rejects again. Other transport failures (TLS, certificates, refused redirects, oversized responses) and
    revocations refused by the server stay at .warning. Messages and metadata are unchanged.

0.3.1

Choose a tag to compare

@github-actions github-actions released this 15 Oct 14:03
0.3.1
fa8cdac

Fixed

  • PassportKitTesting: a token exchange with a refresh token subject, requested_token_type refresh token and an
    audience that names a registered client issued the refresh token for the requesting client inside the requester's
    own grant. It is now issued for the audience client in a new grant with its own rotation chain, lifetimes and
    rotation settings, so that client can redeem it, other clients get invalid_grant, and revoking either chain does
    not revoke the other. An audience that is not a registered client behaves as before, and a registered audience
    client without the refresh token grant gets invalid_target.

0.3.0

Choose a tag to compare

@github-actions github-actions released this 15 Oct 13:58
0.3.0
a11831b

Changed

  • Breaking (security, #1): endpoints are https only. Plain http on a loopback host (localhost, 127.0.0.1,
    ::1) is no longer accepted for the authorization, token, device authorization and revocation endpoints, the issuer,
    the discovery URL, the endpoints in fetched metadata, device verification URIs and the resource URLs of
    RequestAuthorizer. Local development servers need the new opt-in
    ClientConfiguration.allowsInsecureLoopbackEndpoints, which is also a parameter of
    Discovery.fetchMetadata(issuer:…), Endpoints.init(metadata:) and ClientConfiguration.init(metadata:…) (all
    default false). A non-loopback http URL is refused even with it. Violations throw invalidConfiguration and the
    message names the opt-in. http loopback redirect URIs (RFC 8252 §7.3) are unaffected. See ADR 0012.
  • Breaking (security, #2): the authorization code flow requires ClientConfiguration.issuer.
    beginAuthorization(_:), authorize(_:using:) and completeAuthorization(_:callbackURL:additionalParameters:)
    throw invalidConfiguration, before any request, when it is nil. Before, a response iss was accepted unchecked
    without a configured issuer. Comparison stays exact (RFC 9207 §2.4), and
    requiresIssuerInAuthorizationResponse still follows authorization_response_iss_parameter_supported when the
    configuration comes from metadata. Servers without RFC 9207 need another mix-up defence, such as a distinct redirect
    URI per authorization server; the device flow is not affected. See ADR 0013.

0.2.0

Choose a tag to compare

@github-actions github-actions released this 15 Oct 12:50
0.2.0
985eb79

Upgrading from 0.1.0: macOS 14 and iOS 17 are the only supported platforms, KeychainCredentialStore.init(decodeLegacy:)
is gone, and the ManualClock waits in PassportKitTesting throw. See the Breaking entries.

Added

  • TokenManager.signIn(refreshToken:grantedScope:idToken:) async throws starts a session from a refresh token the app
    already holds, for example the one exchangeRefreshToken(audiences:) issued for another client, or one read from
    the storage of a previous OAuth library. Like signIn(with:requestedScope:) it replaces the session, saves the
    credential and emits .signedIn, but it caches no access token: the first accessToken(for:) refreshes. It throws
    invalidConfiguration for an empty token and then leaves the current session untouched.
  • A DocC article, "Migrating stored tokens", on moving users from another OAuth library without signing them out: read
    the old refresh token, call signIn(refreshToken:) under a new account, delete the old item once a token request
    succeeded.
  • ManualClock.WaitTimeout, thrown by the waits of ManualClock (see Changed).
  • Documentation of exact scope matching: RequireAnyScope and the resource access article state that scopes are
    compared as exact strings and * is not a wildcard, with a compiled .custom policy that accepts a scope prefix.
  • A release workflow: pushing a version tag runs the CI workflow (now also callable with workflow_call) and, only if
    every job passes, creates the GitHub release with the tag's changelog section as notes. The procedure is in
    CONTRIBUTING.md.

Changed

  • Breaking (PassportKitTesting): ManualClock.waitForSleeper() and ManualClock.advanceToNextSleeper() are
    throws; call them with try await. When no task sleeps within 60 seconds of real time (it was 10 seconds) they
    throw ManualClock.WaitTimeout instead of stopping the whole test process, so a slow wake-up on a loaded machine
    fails only the waiting test. The wait is resumed by the sleeper that arrives instead of polling.
    waitForSleeper(timeout:) is unchanged.
  • TokenManager.init: the default of rejectedTokenCacheDuration is 5 seconds (it was 30). The window only has to
    absorb tight retry loops, which would otherwise rotate the refresh token on every attempt; a long one makes a
    permission that was just granted look denied. Pass .seconds(30) to keep the old behaviour.
  • The iOS test job boots the simulator first, prints the full test output and uploads the result bundle when it
    fails.

Removed

  • Breaking: KeychainCredentialStore.init(decodeLegacy:) and the migration code behind it. The store reads and
    writes only its own format, and an item it cannot decode is a .storageFailure. An app migrates by reading its old
    storage itself and calling TokenManager.signIn(refreshToken:grantedScope:idToken:). This also removes the
    write-back, which replaced the migrated item by deleting and adding it and could lose it. Items written directly as
    the record JSON by builds before 0.1.0 are no longer read.
  • Breaking: tvOS, watchOS and visionOS are no longer supported. Package.swift declares macOS 14 and iOS 17 only,
    and the platform guards that existed for the other three are gone: WebAuthenticationSessionUserAgent,
    LoopbackRedirectListener and LoopbackUserAgent exist on both supported platforms (ADR 0011, Update).

Fixed

  • KeychainCredentialStore.delete matches the item by service, account and access group only. It no longer carries
    the accessibility class, so an item stored with another class is removed on sign-out, and it no longer matches items
    of other access groups.
  • The documentation of KeychainCredentialStore, KeychainCredentialStore.Accessibility and the security model said
    accessibility classes and access groups protect the item. On macOS the store uses the file-based login keychain,
    which enforces neither; they apply on iOS.

Security

  • KeychainCredentialStore sets kSecAttrSynchronizable to false explicitly when it adds, fetches and deletes an
    item, instead of relying on the default, so a credential never reaches iCloud Keychain. Items written before are
    found as before.

0.1.0

Choose a tag to compare

@filipbodor filipbodor released this 12 Oct 12:16
0.1.0
c95b893

First release of PassportKit, an OAuth 2.0 client library for Apple platforms (macOS 14, iOS 17, tvOS 17, watchOS 10, visionOS 1).

Highlights

  • Grants: authorization code with PKCE (RFC 7636, RFC 9207 iss), device authorization (RFC 8628), refresh, client credentials, token exchange (RFC 8693) with resource indicators (RFC 8707), revocation (RFC 7009), metadata discovery (RFC 8414).
  • TokenManager: one session per app with refresh-token rotation handled safely (single refresh lane, persist before use, coalesced requests), token targets for resource-bound tokens, and an acceptance policy that turns "200 with narrowed scope" into .resourceDenied without signing the user out.
  • RequestAuthorizer: bearer signing with one 401 retry.
  • Keychain storage, ASWebAuthenticationSession and loopback redirect user agents.
  • PassportKitTesting: a fake authorization server and manual clocks for your own tests.
  • Logging through swift-log; secrets are redacted everywhere.

The API may change in 0.x releases. See CHANGELOG.md for details and known limitations (docs/security-model.md, "Known limits").