@better-auth/sso 1.4.7-beta.2 → 1.4.7-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +7 -7
- package/dist/client.d.mts +1 -1
- package/dist/{index-BWvN4yrs.d.mts → index-GoyGoP_a.d.mts} +390 -21
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +559 -63
- package/package.json +4 -4
- package/src/authn-request-store.ts +76 -0
- package/src/authn-request.test.ts +99 -0
- package/src/index.ts +46 -7
- package/src/oidc/discovery.test.ts +823 -0
- package/src/oidc/discovery.ts +355 -0
- package/src/oidc/errors.ts +86 -0
- package/src/oidc/index.ts +31 -0
- package/src/oidc/types.ts +210 -0
- package/src/oidc.test.ts +0 -164
- package/src/routes/sso.ts +415 -96
- package/src/saml.test.ts +781 -48
- package/src/types.ts +81 -0
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OAuth2Tokens, User } from "better-auth";
|
|
2
|
+
import type { AuthnRequestStore } from "./authn-request-store";
|
|
2
3
|
|
|
3
4
|
export interface OIDCMapping {
|
|
4
5
|
id?: string | undefined;
|
|
@@ -259,4 +260,84 @@ export interface SSOOptions {
|
|
|
259
260
|
*/
|
|
260
261
|
tokenPrefix?: string;
|
|
261
262
|
};
|
|
263
|
+
/**
|
|
264
|
+
* SAML security options for AuthnRequest/InResponseTo validation.
|
|
265
|
+
* This prevents unsolicited responses, replay attacks, and cross-provider injection.
|
|
266
|
+
*/
|
|
267
|
+
saml?: {
|
|
268
|
+
/**
|
|
269
|
+
* Enable InResponseTo validation for SP-initiated SAML flows.
|
|
270
|
+
* When enabled, AuthnRequest IDs are tracked and validated against SAML responses.
|
|
271
|
+
*
|
|
272
|
+
* Storage behavior:
|
|
273
|
+
* - Uses `secondaryStorage` (e.g., Redis) if configured in your auth options
|
|
274
|
+
* - Falls back to the verification table in the database otherwise
|
|
275
|
+
*
|
|
276
|
+
* This works correctly in serverless environments without any additional configuration.
|
|
277
|
+
*
|
|
278
|
+
* @default false
|
|
279
|
+
*/
|
|
280
|
+
enableInResponseToValidation?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Allow IdP-initiated SSO (unsolicited SAML responses).
|
|
283
|
+
* When true, responses without InResponseTo are accepted.
|
|
284
|
+
* When false, all responses must correlate to a stored AuthnRequest.
|
|
285
|
+
*
|
|
286
|
+
* Only applies when InResponseTo validation is enabled.
|
|
287
|
+
*
|
|
288
|
+
* @default true
|
|
289
|
+
*/
|
|
290
|
+
allowIdpInitiated?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* TTL for AuthnRequest records in milliseconds.
|
|
293
|
+
* Requests older than this will be rejected.
|
|
294
|
+
*
|
|
295
|
+
* Only applies when InResponseTo validation is enabled.
|
|
296
|
+
*
|
|
297
|
+
* @default 300000 (5 minutes)
|
|
298
|
+
*/
|
|
299
|
+
requestTTL?: number;
|
|
300
|
+
/**
|
|
301
|
+
* Custom AuthnRequest store implementation.
|
|
302
|
+
* Use this to provide a custom storage backend (e.g., Redis-backed store).
|
|
303
|
+
*
|
|
304
|
+
* Providing a custom store automatically enables InResponseTo validation.
|
|
305
|
+
*
|
|
306
|
+
* Note: When not provided, the default storage (secondaryStorage with
|
|
307
|
+
* verification table fallback) is used automatically.
|
|
308
|
+
*/
|
|
309
|
+
authnRequestStore?: AuthnRequestStore;
|
|
310
|
+
/**
|
|
311
|
+
* Clock skew tolerance for SAML assertion timestamp validation in milliseconds.
|
|
312
|
+
* Allows for minor time differences between IdP and SP servers.
|
|
313
|
+
*
|
|
314
|
+
* Defaults to 300000 (5 minutes) to accommodate:
|
|
315
|
+
* - Network latency and processing time
|
|
316
|
+
* - Clock synchronization differences (NTP drift)
|
|
317
|
+
* - Distributed systems across timezones
|
|
318
|
+
*
|
|
319
|
+
* For stricter security, reduce to 1-2 minutes (60000-120000).
|
|
320
|
+
* For highly distributed systems, increase up to 10 minutes (600000).
|
|
321
|
+
*
|
|
322
|
+
* @default 300000 (5 minutes)
|
|
323
|
+
*/
|
|
324
|
+
clockSkew?: number;
|
|
325
|
+
/**
|
|
326
|
+
* Require timestamp conditions (NotBefore/NotOnOrAfter) in SAML assertions.
|
|
327
|
+
* When enabled, assertions without timestamp conditions will be rejected.
|
|
328
|
+
*
|
|
329
|
+
* When disabled (default), assertions without timestamps are accepted
|
|
330
|
+
* but a warning is logged.
|
|
331
|
+
*
|
|
332
|
+
* **SAML Spec Notes:**
|
|
333
|
+
* - SAML 2.0 Core: Timestamps are OPTIONAL
|
|
334
|
+
* - SAML2Int (enterprise profile): Timestamps are REQUIRED
|
|
335
|
+
*
|
|
336
|
+
* **Recommendation:** Enable for enterprise/production deployments
|
|
337
|
+
* where your IdP follows SAML2Int (Okta, Azure AD, OneLogin, etc.)
|
|
338
|
+
*
|
|
339
|
+
* @default false
|
|
340
|
+
*/
|
|
341
|
+
requireTimestamps?: boolean;
|
|
342
|
+
};
|
|
262
343
|
}
|