Skip to content

Conversation

@retrogtx
Copy link
Contributor

@retrogtx retrogtx commented Apr 13, 2025

What does this PR do?

Enables Microsoft authentication for Cal.com, allowing users to sign up and log in using their Microsoft accounts (Azure AD). This builds upon #16873 by @hbjORbj.

The flow is exactly like google except for one case, in google we add google meet as a conferencing tool. however in microsoft we don't add a conferencing tool, mainly for two reasons: 1. it requires additional permissions unlike google meet 2. MS teams which is conferencing tool for microsoft is only available for school and org accounts unlike meet which is available for all accounts be it free or org.

Fixes #27060

Visual Demo:

signin.with.outlook.flow.mov

Key Changes

Authentication:

  • Azure AD OAuth provider via NextAuth
  • New IdentityProvider.AZUREAD enum value with database migration
  • xms_edov claim validation for email domain verification (handles work/school and personal accounts)
  • Proper identity provider mapping for azure-ad provider

UI:

  • "Continue with Microsoft" button on login and signup pages
  • Accessible Microsoft logo SVG with ARIA attributes

Profile Features:

  • Profile photo sync from Microsoft Graph API
  • Office 365 calendar auto-linking for org users during signup

Infrastructure:

  • New environment variables: OUTLOOK_LOGIN_ENABLED, OUTLOOK_API_CREDENTIALS, AZURE_AD_TENANT_ID
  • SSO route handling to map "microsoft"signIn("azure-ad")
  • Onboarding E2E tests for AZUREAD

Environment Variables

OUTLOOK_LOGIN_ENABLED=false
OUTLOOK_API_CREDENTIALS=   # JSON credentials from Azure portal, the format is something like this {"web":{"client_id":"9b81......","client_secret":"wJT8Q~PH...."}}
AZURE_AD_TENANT_ID=        # Use "common" for multi-tenant

How to Test

  1. Set up Azure AD app in Azure Portal
  2. Configure redirect URI: {WEBAPP_URL}/api/auth/callback/azure-ad
  3. Set environment variables and OUTLOOK_LOGIN_ENABLED=true
  4. Verify the Microsoft button appears and OAuth flow works

-- Added by @sean-brydon

Enable microsoft SALM google etc

Figma: https://www.figma.com/design/wleA2SR6rn60EK7ORxAfMy/Cal.com-New-Features?node-id=12-61094&m=dev

image image

@retrogtx retrogtx requested a review from a team as a code owner April 13, 2025 12:04
@vercel
Copy link

vercel bot commented Apr 13, 2025

@retrogtx is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added ❗️ migrations contains migration files ❗️ .env changes contains changes to env variables labels Apr 13, 2025
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Apr 13, 2025
@graphite-app graphite-app bot requested a review from a team April 13, 2025 12:04
@keithwillcode keithwillcode added the community-interns The team responsible for reviewing, testing and shipping low/medium community PRs label Apr 13, 2025
@dosubot dosubot bot added the authentication area: authentication, auth, google sign in, password, SAML, password reset, can't log in label Apr 13, 2025
@graphite-app
Copy link

graphite-app bot commented Apr 13, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (04/13/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (04/13/25)

1 label was added to this PR based on Keith Williams's automation.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mrge found 16 issues across 16 files. View them in mrge.io

@@ -0,0 +1,6 @@
<svg width="100" height="100" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SVG lacks accessibility attributes (title and description) that would make it accessible to screen readers

{t("continue_with_google")}
</Button>
) : null}
{/* TODO replace true with isMicrosoftLoginEnabled */}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded 'true' value instead of using the isMicrosoftLoginEnabled prop

{t("continue_with_google")}
</Button>
) : null}
{/* TODO replace true with isMicrosoftLoginEnabled */}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO comment left in production code

@Ryukemeister Ryukemeister marked this pull request as ready for review January 22, 2026 06:26
@Ryukemeister
Copy link
Contributor

@cubic-dev-ai review this PR

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Jan 22, 2026

@cubic-dev-ai review this PR

@Ryukemeister I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 19 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/features/auth/lib/next-auth-options.ts">

<violation number="1" location="packages/features/auth/lib/next-auth-options.ts:998">
P1: Rule violated: **Avoid Logging Sensitive Information**

Logging the entire `user` object exposes PII (email) in error logs. Error-level logs are captured in production and could leak sensitive user information. Consider logging only non-PII identifiers or hashing the email for log correlation.</violation>

<violation number="2" location="packages/features/auth/lib/next-auth-options.ts:1250">
P1: Security: Missing SAML tenant validation when converting from GOOGLE to SAML. Other SAML conversions in this file validate that the SAML IdP has domain authority via `validateSamlAccountConversion()`. Without this check, any SAML provider could potentially hijack a Google-authenticated account.</violation>
</file>

<file name="apps/web/modules/auth/login-view.tsx">

<violation number="1" location="apps/web/modules/auth/login-view.tsx:44">
P3: Localize the Microsoft icon alt text instead of hardcoding English so it respects the app’s i18n requirements.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@Ryukemeister
Copy link
Contributor

@cubic-dev-ai can you update the PR description?

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Jan 22, 2026

I've reviewed the PR changes and prepared an updated description. Since I cannot directly modify the GitHub PR body, here's a comprehensive updated description you can copy to replace the current one:


What does this PR do?

Enables Microsoft authentication for Cal.com, allowing users to sign up and log in using their Microsoft accounts (Azure AD). This builds upon #16873 by @hbjORbj.

Key Changes

Authentication:

  • Azure AD OAuth provider via NextAuth
  • New IdentityProvider.AZUREAD enum value with database migration
  • xms_edov claim validation for email domain verification (handles work/school and personal accounts)
  • Proper identity provider mapping for azure-ad provider

UI:

  • "Continue with Microsoft" button on login and signup pages
  • Accessible Microsoft logo SVG with ARIA attributes

Profile Features:

  • Profile photo sync from Microsoft Graph API
  • Office 365 calendar auto-linking for org users during signup

Infrastructure:

  • New environment variables: OUTLOOK_LOGIN_ENABLED, OUTLOOK_API_CREDENTIALS, OUTLOOK_CLIENT_ID, OUTLOOK_CLIENT_SECRET, AZURE_AD_TENANT_ID
  • SSO route handling to map "microsoft"signIn("azure-ad")
  • Onboarding E2E tests for AZUREAD

Environment Variables

OUTLOOK_LOGIN_ENABLED=false
OUTLOOK_API_CREDENTIALS=   # JSON credentials from Azure portal
OUTLOOK_CLIENT_ID=
OUTLOOK_CLIENT_SECRET=
AZURE_AD_TENANT_ID=        # Use "common" for multi-tenant

How to Test

  1. Set up Azure AD app in Azure Portal
  2. Configure redirect URI: {WEBAPP_URL}/api/auth/callback/azure-ad
  3. Set environment variables and OUTLOOK_LOGIN_ENABLED=true
  4. Verify the Microsoft button appears and OAuth flow works

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/features/auth/lib/next-auth-options.ts">

<violation number="1" location="packages/features/auth/lib/next-auth-options.ts:877">
P1: Rule violated: **Avoid Logging Sensitive Information**

Do not log the full `existingUser` object because it includes PII (email, name, etc.). Log only non-sensitive identifiers instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@Ryukemeister Ryukemeister requested a review from hbjORbj January 22, 2026 07:58
orgRole = membership?.role;
}

// Don't spread ...token here - it may contain large OAuth tokens (access_token, refresh_token, id_token)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was causing outlook login to crash because of cookie overload

return `/auth/error?error=wrong-provider&provider=${existingUserWithEmail.identityProvider}`;
} else if (
existingUserWithEmail.identityProvider === IdentityProvider.GOOGLE &&
idP === IdentityProvider.SAML
Copy link
Contributor

@Ryukemeister Ryukemeister Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic rightly pointed out this was a bug

@hbjORbj hbjORbj marked this pull request as draft January 22, 2026 10:43
Copy link
Contributor

@hbjORbj hbjORbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting to draft as it needs some design refinements discussed internally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

authentication area: authentication, auth, google sign in, password, SAML, password reset, can't log in community Created by Linear-GitHub Sync community-interns The team responsible for reviewing, testing and shipping low/medium community PRs ❗️ .env changes contains changes to env variables Medium priority Created by Linear-GitHub Sync ❗️ migrations contains migration files ready-for-e2e size/XXL Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sign up with Microsoft button

10 participants