Care Core

Documentation › Integrations › Sign in with Microsoft

Sign in with Microsoft

Setting up Entra single sign-on.

If your organisation uses Microsoft 365, staff can sign in to Care Core with their work account. Care Core uses OpenID Connect (the authorisation code flow with PKCE) against one Entra tenant.

What you need

  • Permission to register applications in Microsoft Entra ID (Application Administrator or similar).
  • Access to Care Core’s settings file (.env) on the server.
  • Care Core served over HTTPS.

Step by step

  1. In the Entra admin centre go to Identity › Applications › App registrations › New registration.
  2. Name it “Care Core”. Under Supported account types choose Accounts in this organisational directory only (single tenant).
  3. Under Redirect URI choose Web and enter https://YOUR-CARE-CORE-ADDRESS/login/entra/callback. (Admin › Integrations shows the exact address.)
  4. After registering, copy the Application (client) ID and the Directory (tenant) ID from the Overview page.
  5. Go to Certificates & secrets › New client secret, create one, and copy its Value immediately (it is shown once).
  6. Add to Care Core’s .env:
    APP_URL=https://YOUR-CARE-CORE-ADDRESS
    ENTRA_TENANT_ID=00000000-0000-0000-0000-000000000000
    ENTRA_CLIENT_ID=00000000-0000-0000-0000-000000000000
    ENTRA_CLIENT_SECRET=the-secret-value
  7. Reload the sign-in page. A Sign in with Microsoft button now appears. Admin › Integrations shows “On”.

The default permissions (User.Read, plus the sign-in scopes openid profile email) are enough. Care Core never asks for access to mail, files or the directory.

Who can sign in this way

Only people who already have a Care Core login. Signing in with Microsoft never creates an account. Logins come from the joiner process, an administrator, or Entra provisioning. Someone with a Microsoft account but no Care Core login is told their account “is not set up for Care Core”.

How people are matched

  1. First sign-in. Care Core looks for a login whose email address equals the person’s Microsoft sign-in name (user principal name). It then links the login to the person’s permanent Microsoft identifier (tenant id plus object id).
  2. Every later sign-in matches on that permanent identifier. If the person’s email address changes, they still get their own account. And a different Microsoft account with a recycled or similar name cannot take it over.

The “email” claim in the token is never used to find an account, because it is not verified by Microsoft and could be set to someone else’s address.

A login that is invited becomes active the first time its owner signs in with Microsoft, and the one-time invitation link is spent.

When access ends

Microsoft sign-in obeys the same rules as a password: a disabled login, or one whose access end date has passed, is refused with the same message. A leaver cannot get in with Microsoft the day after their last day.

Switching passwords off

Once Microsoft sign-in works you can require it for staff:

PASSWORD_LOGIN=false

Staff and managers can then only sign in with Microsoft. Administrators keep a password (under “Administrator password sign-in” on the page), so you can still get in if Microsoft is unavailable or the settings are wrong. Passwords stay on automatically if Microsoft sign-in is not configured, so you cannot lock yourself out by setting this early.

How it is protected

  • State and nonce tie the response to the sign-in you started, so a response cannot be replayed or forged. A sign-in must be completed within 10 minutes and can be used once.
  • PKCE protects the authorisation code.
  • The ID token must have a valid RS256 signature from the tenant’s published keys (cached for an hour, and re-fetched if a key is unknown), the right issuer, tenant and audience, and be in date. Tokens signed with other algorithms (including none) are refused.
  • Connections to Microsoft check the server’s certificate and allow HTTPS only.
  • Single tenant only: tokens from any other tenant are refused.

If it does not work

What you seeLikely cause
No Microsoft buttonOne of the three ENTRA_ settings, or APP_URL, is missing.
Microsoft shows “redirect URI mismatch”The Redirect URI in Entra is not exactly the address shown in Admin › Integrations (https, no trailing slash).
“Microsoft would not complete the sign-in”The client secret is wrong or has expired. Create a new one and update .env.
“Your Microsoft sign-in could not be verified”The tenant id or client id is wrong, or the server’s clock is badly out.
“Your Microsoft account is not set up for Care Core”There is no login whose email matches their sign-in name, or it is disabled or ended. Create or fix the login.
“That sign-in took too long or was not started here”Took over 10 minutes, or cookies are blocked. Try again from the Care Core page.

Client secrets expire (up to 24 months). Put the date in your calendar.