Skip to content

0.3.0 — Apple, Microsoft and GitLab sign-in, issuer logout, account linking, test provider

Latest

Choose a tag to compare

@robertz robertz released this 15 Nov 20:10
  • A test provider for apps' own specs (boxExpressAuthTestProvider(),
    models/providers/TestProvider.bx). login( app, { identity } ) runs the
    real routes — state, PKCE, verify(), session regeneration — through
    app.inject() and hands back the cookies; deny and fail simulate a
    refusal or a broken provider. Its authorize URL is under .invalid and
    codes only exist once test code calls approve(), so registering it by
    mistake doesn't open a login.
  • Logout at the issuer for OIDC providers (RP-initiated logout). With
    postLogoutRedirectUrl, POST /auth/logout destroys the session and then
    sends the browser to the discovered end_session_endpoint (a 303, or
    200 { logoutUrl } for a fetch()). The ID token is kept for
    id_token_hint only with logoutIdTokenHint: true, so by default the
    session still holds no provider token at all. req.session.auth.provider
    now records which provider a login came through.
  • Microsoft (Entra ID) preset (boxExpressAuthMicrosoft()), with
    tenant (common, organizations, consumers, a tenant id or domain)
    and allowedTenants. The multi-tenant endpoints' templated issuer is
    handled by checking each token's iss against its own tid. The email
    is never reported as verified: Microsoft doesn't verify it.
  • GitLab preset (boxExpressAuthGitLab()), for gitlab.com or a
    self-managed baseUrl.
  • Account linking: with a link( identity, user, tokens, req ) option,
    POST /auth/:provider/link lets a signed-in user attach another provider
    account. POST only (so it sits behind CSRF protection), same callback and
    checks as a login, refused with link_denied if the signed-in user changed
    in between. linkRedirect and linkFailureRedirect options.
  • ES256/ES384/ES512 ID tokens (models/Jwt.bx), verified against EC JWKs
    on the curve the algorithm names, for issuers that sign with ECDSA.
  • Sign in with Apple (boxExpressAuthApple()). Apple's ID tokens are
    ordinary RS256; what's different is everything around them:
    • The client secret is an ES256 JWT signed with the team's .p8 key
      (teamId, keyId, privateKey), minted fresh with a five-minute
      lifetime for every code exchange.
    • Asking for name or email makes Apple return with a cross-site form
      POST, which a SameSite=Lax session cookie doesn't ride along on. The
      new POST /auth/:provider/callback answers it with a 303 to the
      usual GET callback — a top-level navigation, which does carry the
      cookie — so every state, PKCE and ID-token check runs unchanged. Only
      code, state and error go into that URL.
    • The user's name, which Apple posts once on first authorization and
      never in the ID token, is held in memory under a hash of the state
      until the GET callback collects it. The posted email and id_token are
      ignored in favour of the signed token from the token endpoint.
    • auth.formPostRoutes() mounts just that POST route ahead of
      boxExpressCsrf(), which would refuse Apple's tokenless POST.
  • Providers can now override clientSecretValue() (what's sent as
    client_secret) and receive state in fetchProfile()'s context.
  • Guards on WebSocket upgrades: auth.required() in
    app.ws( path, handler, { use: [ sessions, auth.required() ] } ) (BoxExpress
    0.2.27+) answers an anonymous upgrade with a plain 401, never a login
    redirect, whatever its Accept header says. Covered by a spec against a
    real listening server.
  • OIDC subclasses can override discoveryIssuerMatches() and
    tokenIssuerAllowed() for issuers whose iss isn't a fixed string.