Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .changeset/concurrent-refresh-replay.md

This file was deleted.

19 changes: 0 additions & 19 deletions .changeset/csrf-origin-host.md

This file was deleted.

15 changes: 0 additions & 15 deletions .changeset/guard-jwks-verify.md

This file was deleted.

30 changes: 30 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# @seamless-auth/core

## 0.27.0

### Minor Changes

- 193298a: Tighten cross-site request protection when no `allowedOrigins` list is configured, and default the auth cookies to `SameSite=Lax`.

Behaviour changes:

- Without `allowedOrigins`, a state-changing request that is `Sec-Fetch-Site: same-site`, or that carries an `Origin` and no `Sec-Fetch-Site` (or `none`), must come from an `Origin` whose host equals the request's `Host`. It used to pass, so a page on a sibling subdomain could send a request that carried the session cookie. A `same-site` request with no `Origin` is now refused. Refusals answer `403 {"error":"cross_site_request_blocked"}`. This applies to the auth routes and to the `requireAuth` and role guards on cookie sessions.
- A `Sec-Fetch-Site` value the Fetch Metadata spec does not define is treated as cross-site and refused.
- `cookieSameSite` now defaults to `lax` whatever `cookieSecure` says. It used to default to `none` when the cookie was secure.
- `checkOrigin` in core takes a new `host` input. Without `allowedOrigins`, a caller that leaves it out has every request with a non-same-origin `Origin` refused.

Express and Fastify read the host from `req.host`, which follows `X-Forwarded-Host` only behind a proxy the framework is told to trust (`trust proxy`, `trustProxy`). Next.js reads the `Host` header.

What to do when upgrading: if your browser app is served from a different host than the adapter, or a proxy in front of the adapter rewrites `Host`, set `allowedOrigins` to the origins your app is served from (or configure the framework to trust the proxy). If your browser app is on a different site from the adapter, set `cookieSameSite: "none"` (with `cookieSecure` left on) to keep the cookie on its requests.
- c835725: Verify the access token inside a session cookie against the auth API's JWKS in the Express and Fastify guards, and take the session's roles, permissions and organization from it alone.

Behaviour changes:

- `requireAuth` in `@seamless-auth/express` and `@seamless-auth/fastify` now requires `authServerUrl` and `audience`, and throws when it is constructed without them. The types mark both as required. Before, leaving them out gave a cookie-only guard that trusted the cookie's payload, so anyone holding `cookieSecret` could sign a cookie with any identity, roles or permissions. The Next.js guards already worked this way.
- With the pair set, the guard verifies the cookie's inner access token (issuer, audience, expiry, `typ: "access"`) and refuses the cookie when it does not verify or its `sub` differs from the token's. It also accepts the auth API's access token as `Authorization: Bearer`, as it already did when the pair was configured.
- `req.user.roles` (and `request.user.roles`) is the verified token's `roles` claim, or `[]` when the token has none. It no longer falls back to the roles copied into the cookie from the login response. `permissions`, `organizationRoles`, `organizationPermissions` and `organizationId` come from the verified token too.

What to do when upgrading: pass the same `authServerUrl` and `audience` you give `createSeamlessAuthServer` (or the plugin) to every `requireAuth`, plus `authServerIssuer` if you set one there. The guard fetches the auth API's JWKS once and caches it.

### Patch Changes

- f24a5a1: Document multi-instance deployment and test that two adapter instances refreshing the same cookie at once both succeed with the same refresh cookie, and that `refresh_token_reused` clears the cookies without a retry. Needs the auth API release that ships the refresh replay window (fells-code/seamless-auth-api#613).

## 0.26.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@seamless-auth/core",
"version": "0.26.0",
"version": "0.27.0",
"description": "Framework-agnostic core authentication logic for SeamlessAuth",
"keywords": [
"authentication",
Expand Down
33 changes: 33 additions & 0 deletions packages/express/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# @seamless-auth/express

## 0.27.0

### Minor Changes

- 193298a: Tighten cross-site request protection when no `allowedOrigins` list is configured, and default the auth cookies to `SameSite=Lax`.

Behaviour changes:

- Without `allowedOrigins`, a state-changing request that is `Sec-Fetch-Site: same-site`, or that carries an `Origin` and no `Sec-Fetch-Site` (or `none`), must come from an `Origin` whose host equals the request's `Host`. It used to pass, so a page on a sibling subdomain could send a request that carried the session cookie. A `same-site` request with no `Origin` is now refused. Refusals answer `403 {"error":"cross_site_request_blocked"}`. This applies to the auth routes and to the `requireAuth` and role guards on cookie sessions.
- A `Sec-Fetch-Site` value the Fetch Metadata spec does not define is treated as cross-site and refused.
- `cookieSameSite` now defaults to `lax` whatever `cookieSecure` says. It used to default to `none` when the cookie was secure.
- `checkOrigin` in core takes a new `host` input. Without `allowedOrigins`, a caller that leaves it out has every request with a non-same-origin `Origin` refused.

Express and Fastify read the host from `req.host`, which follows `X-Forwarded-Host` only behind a proxy the framework is told to trust (`trust proxy`, `trustProxy`). Next.js reads the `Host` header.

What to do when upgrading: if your browser app is served from a different host than the adapter, or a proxy in front of the adapter rewrites `Host`, set `allowedOrigins` to the origins your app is served from (or configure the framework to trust the proxy). If your browser app is on a different site from the adapter, set `cookieSameSite: "none"` (with `cookieSecure` left on) to keep the cookie on its requests.
- c835725: Verify the access token inside a session cookie against the auth API's JWKS in the Express and Fastify guards, and take the session's roles, permissions and organization from it alone.

Behaviour changes:

- `requireAuth` in `@seamless-auth/express` and `@seamless-auth/fastify` now requires `authServerUrl` and `audience`, and throws when it is constructed without them. The types mark both as required. Before, leaving them out gave a cookie-only guard that trusted the cookie's payload, so anyone holding `cookieSecret` could sign a cookie with any identity, roles or permissions. The Next.js guards already worked this way.
- With the pair set, the guard verifies the cookie's inner access token (issuer, audience, expiry, `typ: "access"`) and refuses the cookie when it does not verify or its `sub` differs from the token's. It also accepts the auth API's access token as `Authorization: Bearer`, as it already did when the pair was configured.
- `req.user.roles` (and `request.user.roles`) is the verified token's `roles` claim, or `[]` when the token has none. It no longer falls back to the roles copied into the cookie from the login response. `permissions`, `organizationRoles`, `organizationPermissions` and `organizationId` come from the verified token too.

What to do when upgrading: pass the same `authServerUrl` and `audience` you give `createSeamlessAuthServer` (or the plugin) to every `requireAuth`, plus `authServerIssuer` if you set one there. The guard fetches the auth API's JWKS once and caches it.

### Patch Changes

- Updated dependencies [f24a5a1]
- Updated dependencies [193298a]
- Updated dependencies [c835725]
- @seamless-auth/core@0.27.0

## 0.26.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/express/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@seamless-auth/express",
"version": "0.26.0",
"version": "0.27.0",
"description": "Express adapter for Seamless Auth passwordless authentication",
"keywords": [
"authentication",
Expand Down
33 changes: 33 additions & 0 deletions packages/fastify/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# @seamless-auth/fastify

## 0.18.0

### Minor Changes

- 193298a: Tighten cross-site request protection when no `allowedOrigins` list is configured, and default the auth cookies to `SameSite=Lax`.

Behaviour changes:

- Without `allowedOrigins`, a state-changing request that is `Sec-Fetch-Site: same-site`, or that carries an `Origin` and no `Sec-Fetch-Site` (or `none`), must come from an `Origin` whose host equals the request's `Host`. It used to pass, so a page on a sibling subdomain could send a request that carried the session cookie. A `same-site` request with no `Origin` is now refused. Refusals answer `403 {"error":"cross_site_request_blocked"}`. This applies to the auth routes and to the `requireAuth` and role guards on cookie sessions.
- A `Sec-Fetch-Site` value the Fetch Metadata spec does not define is treated as cross-site and refused.
- `cookieSameSite` now defaults to `lax` whatever `cookieSecure` says. It used to default to `none` when the cookie was secure.
- `checkOrigin` in core takes a new `host` input. Without `allowedOrigins`, a caller that leaves it out has every request with a non-same-origin `Origin` refused.

Express and Fastify read the host from `req.host`, which follows `X-Forwarded-Host` only behind a proxy the framework is told to trust (`trust proxy`, `trustProxy`). Next.js reads the `Host` header.

What to do when upgrading: if your browser app is served from a different host than the adapter, or a proxy in front of the adapter rewrites `Host`, set `allowedOrigins` to the origins your app is served from (or configure the framework to trust the proxy). If your browser app is on a different site from the adapter, set `cookieSameSite: "none"` (with `cookieSecure` left on) to keep the cookie on its requests.
- c835725: Verify the access token inside a session cookie against the auth API's JWKS in the Express and Fastify guards, and take the session's roles, permissions and organization from it alone.

Behaviour changes:

- `requireAuth` in `@seamless-auth/express` and `@seamless-auth/fastify` now requires `authServerUrl` and `audience`, and throws when it is constructed without them. The types mark both as required. Before, leaving them out gave a cookie-only guard that trusted the cookie's payload, so anyone holding `cookieSecret` could sign a cookie with any identity, roles or permissions. The Next.js guards already worked this way.
- With the pair set, the guard verifies the cookie's inner access token (issuer, audience, expiry, `typ: "access"`) and refuses the cookie when it does not verify or its `sub` differs from the token's. It also accepts the auth API's access token as `Authorization: Bearer`, as it already did when the pair was configured.
- `req.user.roles` (and `request.user.roles`) is the verified token's `roles` claim, or `[]` when the token has none. It no longer falls back to the roles copied into the cookie from the login response. `permissions`, `organizationRoles`, `organizationPermissions` and `organizationId` come from the verified token too.

What to do when upgrading: pass the same `authServerUrl` and `audience` you give `createSeamlessAuthServer` (or the plugin) to every `requireAuth`, plus `authServerIssuer` if you set one there. The guard fetches the auth API's JWKS once and caches it.

### Patch Changes

- Updated dependencies [f24a5a1]
- Updated dependencies [193298a]
- Updated dependencies [c835725]
- @seamless-auth/core@0.27.0

## 0.17.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/fastify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@seamless-auth/fastify",
"version": "0.17.0",
"version": "0.18.0",
"description": "Fastify adapter for Seamless Auth passwordless authentication",
"keywords": [
"authentication",
Expand Down
24 changes: 24 additions & 0 deletions packages/nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# @seamless-auth/nextjs

## 0.11.0

### Minor Changes

- 193298a: Tighten cross-site request protection when no `allowedOrigins` list is configured, and default the auth cookies to `SameSite=Lax`.

Behaviour changes:

- Without `allowedOrigins`, a state-changing request that is `Sec-Fetch-Site: same-site`, or that carries an `Origin` and no `Sec-Fetch-Site` (or `none`), must come from an `Origin` whose host equals the request's `Host`. It used to pass, so a page on a sibling subdomain could send a request that carried the session cookie. A `same-site` request with no `Origin` is now refused. Refusals answer `403 {"error":"cross_site_request_blocked"}`. This applies to the auth routes and to the `requireAuth` and role guards on cookie sessions.
- A `Sec-Fetch-Site` value the Fetch Metadata spec does not define is treated as cross-site and refused.
- `cookieSameSite` now defaults to `lax` whatever `cookieSecure` says. It used to default to `none` when the cookie was secure.
- `checkOrigin` in core takes a new `host` input. Without `allowedOrigins`, a caller that leaves it out has every request with a non-same-origin `Origin` refused.

Express and Fastify read the host from `req.host`, which follows `X-Forwarded-Host` only behind a proxy the framework is told to trust (`trust proxy`, `trustProxy`). Next.js reads the `Host` header.

What to do when upgrading: if your browser app is served from a different host than the adapter, or a proxy in front of the adapter rewrites `Host`, set `allowedOrigins` to the origins your app is served from (or configure the framework to trust the proxy). If your browser app is on a different site from the adapter, set `cookieSameSite: "none"` (with `cookieSecure` left on) to keep the cookie on its requests.

### Patch Changes

- Updated dependencies [f24a5a1]
- Updated dependencies [193298a]
- Updated dependencies [c835725]
- @seamless-auth/core@0.27.0

## 0.10.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@seamless-auth/nextjs",
"version": "0.10.0",
"version": "0.11.0",
"description": "Next.js App Router adapter for Seamless Auth passwordless authentication",
"keywords": [
"authentication",
Expand Down