Client St0r now supports Azure AD (Microsoft Entra ID) Single Sign-On authentication. Users can log in using their Microsoft work accounts.
- Go to Azure Portal
- Navigate to Azure Active Directory → App registrations
- Click New registration
- Configure:
- Name: Client St0r
- Supported account types: Accounts in this organizational directory only
- Redirect URI:
- Type: Web
- URL:
https://your-domain.com/accounts/auth/azure/callback/
- Click Register
After registration, note the following values (you'll need them later):
- Application (client) ID: Found on the Overview page
- Directory (tenant) ID: Found on the Overview page
- Go to Certificates & secrets → Client secrets
- Click New client secret
- Add description: "Client St0r OAuth"
- Select expiration (recommended: 24 months)
- Click Add
- IMPORTANT: Copy the Value immediately (you won't be able to see it again)
- Go to API permissions
- Ensure User.Read permission is present (should be added automatically)
- If not present:
- Click Add a permission
- Select Microsoft Graph → Delegated permissions
- Add User.Read
- Click Grant admin consent (if you have admin rights)
- Log in to Client St0r as superuser
- Go to Admin → Settings → Directory Services
- Under Azure AD / Microsoft Entra ID, configure:
- Enable Azure AD: ✓ (checked)
- Tenant ID: Paste your Directory (tenant) ID
- Client ID: Paste your Application (client) ID
- Client Secret: Paste the secret value you copied
- Redirect URI:
https://your-domain.com/accounts/auth/azure/callback/ - Auto-create users: ✓ (recommended - creates users on first login)
- Sync groups: Optional (not yet implemented)
- Click Save
Run SQL to configure settings:
-- Enable Azure AD
INSERT INTO core_systemsetting (key, value, value_type, category, description, is_public, created_at, updated_at)
VALUES ('azure_ad_enabled', 'true', 'boolean', 'authentication', 'Enable Azure AD authentication', 0, NOW(), NOW());
-- Tenant ID
INSERT INTO core_systemsetting (key, value, value_type, category, description, is_public, created_at, updated_at)
VALUES ('azure_ad_tenant_id', 'YOUR-TENANT-ID-HERE', 'string', 'authentication', 'Azure AD Tenant ID', 0, NOW(), NOW());
-- Client ID
INSERT INTO core_systemsetting (key, value, value_type, category, description, is_public, created_at, updated_at)
VALUES ('azure_ad_client_id', 'YOUR-CLIENT-ID-HERE', 'string', 'authentication', 'Azure AD Client ID', 0, NOW(), NOW());
-- Client Secret
INSERT INTO core_systemsetting (key, value, value_type, category, description, is_public, created_at, updated_at)
VALUES ('azure_ad_client_secret', 'YOUR-CLIENT-SECRET-HERE', 'string', 'authentication', 'Azure AD Client Secret', 0, NOW(), NOW());
-- Redirect URI
INSERT INTO core_systemsetting (key, value, value_type, category, description, is_public, created_at, updated_at)
VALUES ('azure_ad_redirect_uri', 'https://your-domain.com/accounts/auth/azure/callback/', 'string', 'authentication', 'Azure AD Redirect URI', 0, NOW(), NOW());
-- Auto-create users
INSERT INTO core_systemsetting (key, value, value_type, category, description, is_public, created_at, updated_at)
VALUES ('azure_ad_auto_create_users', 'true', 'boolean', 'authentication', 'Auto-create users on first Azure login', 0, NOW(), NOW());Apply database migrations:
python manage.py migrate accounts- Go to the login page:
https://your-domain.com/ - You should see a "Sign in with Microsoft" button
- Click the button
- You'll be redirected to Microsoft login
- After successful authentication, you'll be logged into Client St0r
When enabled, users who successfully authenticate via Azure AD will automatically have accounts created in Client St0r:
- Username: Derived from email (e.g.,
john.doefromjohn.doe@company.com) - Email: From Azure AD
- Name: First and last name from Azure AD
- Auth Source: Marked as
azure_ad
Users who authenticate via Azure AD bypass 2FA requirements. Azure AD authentication is already secure through Microsoft's multi-factor authentication.
User information (name, email) is automatically updated from Azure AD on each login.
- Client Secret: Store securely, never commit to version control
- Redirect URI: Must exactly match what's configured in Azure
- HTTPS Required: Azure AD requires HTTPS for redirect URIs (except localhost)
- Session Security: Azure authentication status is stored in session
- Verify all settings are saved correctly
- Check that
azure_ad_enabledis set totrue - Ensure all required fields (tenant_id, client_id, client_secret, redirect_uri) are populated
- Verify client secret is correct (may have expired)
- Check redirect URI matches exactly between Azure and Client St0r
- Ensure Azure app has User.Read permission
- Check that user's email is valid
- If auto-create is disabled, ensure user already exists in Client St0r
- Review audit logs for more details
- Check browser console for JavaScript errors
- Verify
/accounts/auth/azure/status/endpoint returns{"enabled": true} - Clear browser cache
- Login Initiation:
/accounts/auth/azure/login/ - OAuth Callback:
/accounts/auth/azure/callback/ - Status Check:
/accounts/auth/azure/status/
- AzureADBackend (
accounts/azure_auth.py): Django authentication backend - AzureOAuthClient (
accounts/azure_auth.py): OAuth helper for MSAL - OAuth Views (
accounts/oauth_views.py): Login initiation and callback handling - Login Template (
templates/two_factor/core/login.html): UI with Azure button
- User clicks "Sign in with Microsoft"
- Redirected to
/accounts/auth/azure/login/ - MSAL generates authorization URL
- User redirected to Microsoft login
- After authentication, Microsoft redirects to
/accounts/auth/azure/callback/ - Client St0r exchanges code for access token
- Fetches user info from Microsoft Graph API
- Authenticates user in Django
- Creates user account if needed
- Sets session flag
azure_ad_authenticated = True - Redirects to dashboard
For issues or questions, please file an issue on GitHub.