Microsoft Entra ID
Connect your Microsoft Entra ID (formerly Azure AD) tenant to Squid to authorize user actions like querying and updating data, calling executables, and more.
Microsoft Entra ID is Microsoft's cloud identity platform. With the Entra ID auth connector, your users sign in with Microsoft, and Squid validates their tokens and populates getUserAuth() in your backend.
To connect your tenant to Squid:
- Navigate to the Squid Console. Choose your app and environment (dev or prod), and then click the Connectors tab.
- Click Available Connectors, find Microsoft Entra ID, and select Add Connector.
- Provide the following details:
- Connector ID - Choose an ID that is brief and helps identify the connector.
- Tenant ID - Your Entra tenant's ID, from the app registration's overview page in the Azure portal.
- Client ID - The Application (client) ID of the app registration your frontend signs in with.
- Client Secret (for token exchange) - Optional. A client secret of the app registration, used only to derive tokens for connectors that run as the signed-in user via the on-behalf-of flow. See Connector access modes.
- Click Add Connector.
Token requirements
- Tokens must be v2.0 tokens, issued by
https://login.microsoftonline.com/<tenantId>/v2.0. A v1 token (issuersts.windows.net) is rejected, so setrequestedAccessTokenVersion: 2in the app registration's manifest if your tokens still come out as v1. - The token's
audclaim must equal or contain the Client ID. A matchingazpclaim is not enough: a token whoseaudnames another resource is treated as unauthenticated even whenazpis your client ID. - The Squid user ID is taken from the token's
oidclaim, the user's stable object ID in the tenant.
Using the connector
Acquire a token with MSAL and pass it to Squid:
Client code
import { PublicClientApplication } from '@azure/msal-browser';
const msal = new PublicClientApplication({
auth: {
clientId: 'YOUR_CLIENT_ID',
authority: 'https://login.microsoftonline.com/YOUR_TENANT_ID',
},
});
await msal.initialize();
squid.setAuthProvider({
integrationId: 'ENTRA_CONNECTOR_ID',
getToken: async () => {
const account = msal.getAllAccounts()[0];
const result = await msal.acquireTokenSilent({
account,
scopes: ['YOUR_CLIENT_ID/.default'],
});
return result.accessToken;
},
});
Once the token is passed to the client, Squid populates the user's authentication information for use in your backend functions:
Backend code
@secureCollection('users', 'read')
secureUsersRead(context: QueryContext<User>): boolean {
const userAuth = this.getUserAuth();
return userAuth !== undefined;
}