diff --git a/.changeset/microsoft-token-claims.md b/.changeset/microsoft-token-claims.md index 390fdde224..b5a351c098 100644 --- a/.changeset/microsoft-token-claims.md +++ b/.changeset/microsoft-token-claims.md @@ -2,4 +2,4 @@ "@better-auth/core": minor --- -Microsoft profile callbacks now accept numeric token timestamps, claim arrays, and omitted conditional claims or profile photos. Profile mappings must handle these corrected values instead of treating timestamps as `Date` objects or all claims as present. +Microsoft profile callbacks now accept numeric token timestamps, claim arrays, boolean corporate-network flags, and omitted conditional or opaque claims and profile photos. Profile mappings must handle these corrected values instead of treating timestamps as `Date` objects or all claims as present. diff --git a/packages/core/src/social-providers/microsoft-entra-id.test.ts b/packages/core/src/social-providers/microsoft-entra-id.test.ts index 1158f9b7a7..53687486b3 100644 --- a/packages/core/src/social-providers/microsoft-entra-id.test.ts +++ b/packages/core/src/social-providers/microsoft-entra-id.test.ts @@ -345,6 +345,7 @@ describe("microsoft id_token alg omission", () => { * @see https://github.com/better-auth/better-auth/issues/3802 * @see https://learn.microsoft.com/en-us/entra/identity-platform/id-token-claims-reference * @see https://learn.microsoft.com/en-us/entra/identity-platform/optional-claims-reference + * @see https://learn.microsoft.com/en-us/entra/identity-platform/access-token-claims-reference */ it("accepts numeric Microsoft timestamps and configured claim arrays", async () => { const profile = { @@ -353,7 +354,6 @@ it("accepts numeric Microsoft timestamps and configured claim arrays", async () iat: 1700000000, nbf: 1700000000, exp: 1700003600, - aio: "opaque-value", oid: "ms-stable-oid", sub: "ms-pairwise-sub", tid: WORK_TENANT_ID, @@ -361,6 +361,8 @@ it("accepts numeric Microsoft timestamps and configured claim arrays", async () assertType(profile); const configuredProfile = { ...profile, + aio: "opaque-value", + in_corp: true, auth_time: 1700000000, groups: ["group-id"], acrs: ["c1"], diff --git a/packages/core/src/social-providers/microsoft-entra-id.ts b/packages/core/src/social-providers/microsoft-entra-id.ts index 5718a606bf..326783bd51 100644 --- a/packages/core/src/social-providers/microsoft-entra-id.ts +++ b/packages/core/src/social-providers/microsoft-entra-id.ts @@ -45,7 +45,7 @@ export interface MicrosoftEntraIDProfile extends Record { /** Access token hash included in ID tokens when issued with an OAuth 2.0 access token */ at_hash?: string; /** Internal claim used to record data for token reuse */ - aio: string; + aio?: string; /** The primary username that represents the user */ preferred_username?: string; /** User's email address */ @@ -121,7 +121,7 @@ export interface MicrosoftEntraIDProfile extends Record { /** Change Password URL */ pwd_url?: string; /** Inside Corporate Network flag */ - in_corp?: string; + in_corp?: boolean; /** User's family name/surname */ family_name?: string; /** User's given/first name */