Microsoft Entra ID Group Mapping
Configure NetBox Enterprise to automatically assign permissions and user flags based on Microsoft Entra ID (formerly Azure Active Directory) group membership. This guide builds on basic SSO authentication and enables group-based access control.
Prerequisites
Before configuring group mapping, ensure the following requirements are met:
Microsoft Entra ID SSO Configuration:
- Basic SSO authentication must be working (see Microsoft Entra ID Single Sign-On)
- Users can successfully log in via Entra ID
- App registration is configured with appropriate redirect URIs
Microsoft Entra ID Requirements:
- Optional claims configured to include groups in tokens
- Azure AD group object IDs for groups you want to map
- Access to view group memberships in Entra ID
NetBox Enterprise Requirements:
- NetBox Enterprise v1.10 or later
- Admin console access
- NetBox groups created and configured with appropriate permissions
- Understanding of NetBox permission model
Important: NetBox groups must exist before you configure mapping. Group mapping does not create NetBox groups automatically.
Understanding Group Mapping
When a user authenticates via Microsoft Entra ID, NetBox Enterprise queries the Microsoft Graph API to retrieve the user's group memberships. The authentication pipeline then maps Azure AD groups to NetBox groups based on your configuration.
How It Works
- User authenticates via Microsoft Entra ID OAuth 2.0
- NetBox Enterprise receives an access token from Azure AD
- NetBox queries Microsoft Graph API endpoint:
users/{user-id}/transitiveMemberOf - Microsoft returns all groups the user belongs to (including nested groups)
- NetBox clears the user's existing group memberships
- NetBox maps Azure AD group IDs to NetBox groups based on configuration
- NetBox sets user flags (
is_staff,is_superuser) based on group membership - User receives permissions from their assigned NetBox groups
Microsoft Graph API Integration
NetBox Enterprise uses the Microsoft Graph API to retrieve group information:
API Endpoint:
https://graph.microsoft.com/v1.0/users/{user-id}/transitiveMemberOf
Key Features:
- Retrieves all groups including nested group memberships
- Supports pagination for users with many group memberships
- Filters results to only include groups (not directories or other objects)
- Requires
https://graph.microsoft.com/as the OAuth resource
Group Identifiers
Microsoft Entra ID group mapping uses object IDs (GUIDs), not display names. Object IDs are stable identifiers that do not change when group names are updated.
Example object ID:
a1b2c3d4-e5f6-7890-1234-567890abcdef
You can find group object IDs in the Microsoft Entra admin center under Groups > [Group Name] > Overview.
Microsoft Entra ID Configuration
Configure your Entra ID app registration to include group information in authentication tokens.
Configuring Group Claims
- Navigate to the Microsoft Entra admin center
- Select Identity > Applications > App registrations
- Select your NetBox Enterprise app registration
- Navigate to Token configuration
- Click Add optional claim
- Select ID as the token type
- Select the groups claim from the list
- Check Turn on the Microsoft Graph groups claim
- Select group types to include:
- Security groups: Recommended for most deployments
- All groups: Includes distribution lists and Microsoft 365 groups
- Click Add
Granting API Permissions
The app registration requires permissions to read group information:
- Navigate to API permissions in your app registration
- Verify User.Read permission is present (added by default)
- For group claims, you may need GroupMember.Read.All depending on your configuration
- If prompted, grant admin consent for your organization
Locating Group Object IDs
For each Azure AD group you want to map:
- Navigate to Identity > Groups > All groups
- Search for the group by name
- Click the group name to open the group details
- Note the Object ID from the Overview page
- Document the object ID and group purpose for NetBox configuration
NetBox Enterprise Configuration
Configure group mapping through the NetBox Enterprise admin console by modifying the authentication pipeline and adding group mapping configuration.
Accessing Configuration
- Access the admin console at
https://<your-cluster-host-or-ip>:30000/ - Navigate to the Config tab
- Enable Show Advanced Settings
- Locate the NetBox Python Configuration Overrides section
Complete Configuration
Add the following configuration, including both basic SSO settings and group mapping configuration:
# Basic SSO authentication
REMOTE_AUTH_BACKEND = 'social_core.backends.azuread.AzureADOAuth2'
SOCIAL_AUTH_AZUREAD_OAUTH2_KEY = '<application-id>'
SOCIAL_AUTH_AZUREAD_OAUTH2_SECRET = '<client-secret-value>'
SOCIAL_AUTH_AZUREAD_OAUTH2_TENANT_ID = '<tenant-id>'
# Microsoft Graph API access (required for group mapping)
SOCIAL_AUTH_AZUREAD_OAUTH2_RESOURCE = 'https://graph.microsoft.com/'
# Authentication pipeline with group mapping
SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.social_auth.associate_by_email',
'social_core.pipeline.user.create_user',
'social_core.pipeline.social_auth.associate_user',
'netbox.authentication.user_default_groups_handler',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
'nbc_auth_extensions.azure_authentication.azuread_map_groups',
)
# Group mapping configuration
SOCIAL_AUTH_PIPELINE_CONFIG = {
'AZUREAD_USER_FLAGS_BY_GROUP': {
'is_staff': ['<azure-group-id-for-staff>'],
'is_superuser': ['<azure-group-id-for-superusers>']
},
'AZUREAD_GROUP_MAP': {
'<azure-group-id-1>': '<netbox-group-name-1>',
'<azure-group-id-2>': '<netbox-group-name-2>'
}
}
Configuration Parameters
SOCIAL_AUTH_AZUREAD_OAUTH2_RESOURCE
- Specifies the OAuth resource for Microsoft Graph API
- Must be set to
'https://graph.microsoft.com/' - Required for group mapping to function
SOCIAL_AUTH_PIPELINE
- Defines the authentication pipeline steps
- Must include
'nbc_auth_extensions.azure_authentication.azuread_map_groups'as the final step - Do not modify the order of other pipeline steps
SOCIAL_AUTH_PIPELINE_CONFIG
- Container for all group mapping configuration
- Must include both
AZUREAD_USER_FLAGS_BY_GROUPandAZUREAD_GROUP_MAPkeys
AZUREAD_USER_FLAGS_BY_GROUP
- Maps Azure AD group IDs to NetBox user flags
is_staff: Grants access to the NetBox admin interfaceis_superuser: Grants all permissions and superuser status- Users in multiple mapped groups will have the highest privilege level
- Warning: Exercise extreme caution when assigning superuser status
AZUREAD_GROUP_MAP
- Maps Azure AD group IDs to NetBox group names
- Keys: Azure AD group object IDs (GUIDs)
- Values: NetBox group names (must match exactly)
- NetBox groups must already exist before mapping
Configuration Example
A practical example for a typical deployment:
SOCIAL_AUTH_PIPELINE_CONFIG = {
'AZUREAD_USER_FLAGS_BY_GROUP': {
'is_staff': [
'a1b2c3d4-e5f6-7890-1234-567890abcdef', # NetBox Admins
'11111111-2222-3333-4444-555555555555' # NetBox Superusers
],
'is_superuser': [
'11111111-2222-3333-4444-555555555555' # NetBox Superusers
]
},
'AZUREAD_GROUP_MAP': {
'a1b2c3d4-e5f6-7890-1234-567890abcdef': 'Network Admins',
'b2c3d4e5-f6a7-8901-2345-678901bcdefg': 'Network Engineers',
'c3d4e5f6-a7b8-9012-3456-789012cdefgh': 'Read Only Users'
}
}
In this example:
- Members of "NetBox Admins" or "NetBox Superusers" Azure AD groups can access the admin interface
- Members of "NetBox Superusers" Azure AD group become NetBox superusers
- Three Azure AD groups are mapped to corresponding NetBox groups
Deploying Configuration
After adding configuration:
- Scroll to the bottom of the Config page
- Click Save config
- Click Go to updated version when prompted
- Click Deploy to apply changes
- Wait for NetBox Enterprise to reach Ready state
Configuration changes require application restart. Existing user sessions remain active during deployment.
Creating NetBox Groups
Before group mapping can function, you must create NetBox groups and assign appropriate permissions.
Creating Groups
- Navigate to Admin > Authentication > Groups in NetBox
- Click Add Group
- Configure the group:
- Name: Must match exactly the name used in
AZUREAD_GROUP_MAP - Permissions: Select specific permissions for this group
- Name: Must match exactly the name used in
- Click Save
Assigning Permissions
NetBox uses a fine-grained permission model. For each group, assign permissions based on the principle of least privilege:
Common Permission Patterns:
Read Only Users:
- View permissions for all relevant object types (dcim, ipam, circuits, etc.)
- No add, change, or delete permissions
Network Engineers:
- View permissions for all object types
- Add, change, and delete permissions for devices, interfaces, IP addresses
- Limited or no permissions for administrative functions
Network Admins:
- All permissions for network-related objects
- View permissions for administrative objects
- May include some admin permissions like managing users
Superusers:
- Assigned via
is_superuserflag, not group permissions - Have all permissions automatically
Verifying Group Configuration
After creating groups:
- Navigate to Admin > Authentication > Groups
- Verify all groups referenced in
AZUREAD_GROUP_MAPexist - Click each group name to verify permissions are assigned correctly
- Document which Azure AD groups map to which NetBox groups
Testing Group Mapping
After configuring group mapping, test that permissions are assigned correctly.
Initial Test
- Identify a test user who is a member of mapped Azure AD groups
- Verify the test user's Azure AD group memberships in Entra admin center
- Log out of NetBox if currently authenticated
- Log in via Microsoft Entra ID as the test user
- After successful authentication, verify you are logged in
Verifying User Flags
Check that user flags were set correctly:
- Navigate to Admin > Authentication > Users (requires admin access)
- Locate the test user in the user list
- Click the username to view user details
- Verify the following:
- Staff status: Should be checked if user is in an
is_staffgroup - Superuser status: Should be checked if user is in an
is_superusergroup - Active: Should be checked (enabled by default)
- Staff status: Should be checked if user is in an
Verifying Group Membership
Check that NetBox groups were assigned correctly:
- In the user details page, scroll to the Groups section
- Verify the user is a member of expected NetBox groups
- Group memberships should match the user's Azure AD groups based on your mapping configuration
Example:
- Azure AD groups: "NetBox Admins", "Network Engineers"
- Expected NetBox groups: "Network Admins", "Network Engineers"
Verifying Permissions
Test that permissions are functional:
- Log in as the test user (if not already logged in)
- Attempt to access functionality that should be permitted
- Attempt to access functionality that should be denied
- Verify permission enforcement matches expectations
Common Tests:
- Read only users should be able to view but not edit devices
- Engineers should be able to create and modify devices
- Admins should be able to access the admin interface
- Superusers should have unrestricted access
Testing Group Membership Updates
Group membership is refreshed on each login. To test updates:
- Add the test user to a new Azure AD group
- Add the new Azure AD group to your
AZUREAD_GROUP_MAPconfiguration - Deploy the updated configuration
- Log out and log back in as the test user
- Verify the new NetBox group appears in the user's group memberships
Group Membership Behavior
Understanding how NetBox handles group membership is important for managing access control.
Group Synchronization
On each login:
- NetBox queries Microsoft Graph API for current group memberships
- NetBox removes all existing group memberships for the user
- NetBox adds new group memberships based on current Azure AD groups
- User flags (
is_staff,is_superuser) are updated based on current groups
Important: Group memberships are cleared and rebuilt on each login. Any manually assigned groups will be removed.
Manual Group Assignments
Do not manually assign groups to Entra ID-authenticated users in NetBox:
- Manual assignments will be removed on next login
- Group assignments are managed exclusively through Azure AD
- To grant access, add users to appropriate Azure AD groups
Nested Groups
NetBox retrieves nested group memberships:
- If a user is in Group A, and Group A is a member of Group B, the user is considered a member of both groups
- This behavior matches Azure AD's transitive group membership
- Use nested groups to simplify Azure AD group management
Multiple Mapped Groups
If a user is in multiple mapped Azure AD groups:
- The user will be added to all corresponding NetBox groups
- Permissions are additive (union of all group permissions)
- User flags use the highest privilege level (if any group grants
is_superuser, the user becomes a superuser)
Troubleshooting
Groups Not Syncing
Symptoms:
- User logs in successfully via Entra ID
- NetBox groups do not match Azure AD groups
- User has no group memberships after login
Resolution:
-
Verify group claims are configured:
- Open the Microsoft Entra admin center
- Navigate to your app registration Token configuration
- Verify the groups claim is present for ID tokens
- Ensure Turn on the Microsoft Graph groups claim is enabled
-
Check NetBox logs for errors:
kubectl logs <netbox-pod> -n kotsadm | grep -i "azure.*group"Look for errors related to Microsoft Graph API or group mapping.
-
Verify SOCIAL_AUTH_AZUREAD_OAUTH2_RESOURCE:
- Must be set to
'https://graph.microsoft.com/' - Without this setting, NetBox cannot query the Graph API
- Must be set to
-
Check pipeline configuration:
- Verify
'nbc_auth_extensions.azure_authentication.azuread_map_groups'is included inSOCIAL_AUTH_PIPELINE - Verify it is the last step in the pipeline
- Verify
-
Test Graph API access manually: Verify NetBox can reach Microsoft Graph API:
kubectl exec <netbox-pod> -n kotsadm -- curl https://graph.microsoft.com/v1.0/
NetBox Groups Not Found
Symptoms:
- NetBox logs show: "group not found locally"
- User logs in successfully but is not added to any groups
- Some groups work but others do not
Resolution:
-
Verify NetBox groups exist:
- Navigate to Admin > Authentication > Groups in NetBox
- Verify each group referenced in
AZUREAD_GROUP_MAPexists - Group names must match exactly (case-sensitive)
-
Check for typos:
- Common issues: extra spaces, capitalization differences
- NetBox group name: "Network Admins" (with space)
- Configuration:
'Network_Admins'(with underscore) - this will not match
-
Create missing groups:
- For each group referenced in configuration, create a corresponding NetBox group
- Assign appropriate permissions to each group
Permissions Not Applied
Symptoms:
- User is added to NetBox groups successfully
- User does not have expected permissions
- "You do not have permission to access this page" errors
Resolution:
-
Verify group permissions:
- Navigate to Admin > Authentication > Groups
- Click each group name
- Verify permissions are assigned to the group
- Empty groups grant no permissions
-
Check user flags:
- Navigate to Admin > Authentication > Users
- Locate the user
- Verify Active is checked (required for all access)
- Verify Staff status is checked if user needs admin access
-
Review permission requirements:
- Different NetBox features require different permissions
- Admin interface requires
is_staffflag - Some actions require multiple permissions (view and change)
Microsoft Graph API Errors
Symptoms:
- Login fails after Entra ID authentication
- NetBox logs show errors contacting Microsoft Graph API
- Error messages mention timeouts or authorization failures
Resolution:
-
Verify network connectivity:
kubectl exec <netbox-pod> -n kotsadm -- curl -I https://graph.microsoft.comVerify NetBox can reach Microsoft Graph API.
-
Check API permissions:
- Navigate to your app registration in Entra admin center
- Select API permissions
- Verify User.Read permission is granted
- If missing, add the permission and grant admin consent
-
Verify access token:
- Check NetBox logs for token-related errors
- Verify
SOCIAL_AUTH_AZUREAD_OAUTH2_RESOURCEis set correctly - Access tokens must include the correct audience for Graph API
-
Check for expired secrets:
- Client secrets expire based on the configured lifetime
- If the secret expired, generate a new one and update NetBox configuration
Group Object IDs vs Display Names
Symptoms:
- Configuration uses group display names instead of object IDs
- Groups do not sync despite correct configuration syntax
Resolution:
Azure AD group mapping requires object IDs, not display names. Object IDs are GUIDs that look like:
a1b2c3d4-e5f6-7890-1234-567890abcdef
Incorrect (display names):
'AZUREAD_GROUP_MAP': {
'Network Admins': 'Network Admins',
'Network Engineers': 'Network Engineers'
}
Correct (object IDs):
'AZUREAD_GROUP_MAP': {
'a1b2c3d4-e5f6-7890-1234-567890abcdef': 'Network Admins',
'b2c3d4e5-f6a7-8901-2345-678901bcdefg': 'Network Engineers'
}
To find object IDs:
- Navigate to Groups in Entra admin center
- Click the group name
- Copy the Object ID from the Overview page
Configuration Not Taking Effect
Symptoms:
- Configuration updated but behavior unchanged
- Old group mappings still in effect
Resolution:
-
Verify configuration was deployed:
- Check that you clicked Save config and Deploy
- Verify NetBox Enterprise reached Ready state after deployment
-
Check for configuration errors:
- Review the Config page for syntax errors
- Python syntax errors may prevent configuration from loading
-
Force a re-login:
- Log out of NetBox completely
- Clear browser cookies for the NetBox domain
- Log in again via Entra ID
- Group mappings are applied at login time
Security Considerations
Superuser Assignment
Exercise extreme caution when configuring is_superuser groups:
- Superusers have unrestricted access to NetBox
- Superusers can modify any data, including configuration
- Superusers can elevate other users to superuser status
- Superusers can access the Django admin interface
Recommendations:
- Limit
is_superuserto a small, well-controlled Azure AD group - Regularly audit membership of superuser groups
- Use group-based permissions for most users instead of superuser status
- Document who has superuser access and why
Group Membership Synchronization
Group memberships are synchronized on each login:
- Removing a user from an Azure AD group immediately revokes their NetBox access on next login
- Adding a user to an Azure AD group immediately grants access on next login
- Users may retain access until their session expires if removed from groups
- Consider forcing re-authentication for terminated employees
Access Token Security
NetBox Enterprise uses OAuth access tokens to query Microsoft Graph API:
- Access tokens are short-lived (typically 1 hour)
- Tokens are stored in memory during authentication only
- Tokens are not persisted after group mapping completes
- Ensure HTTPS is used for all authentication flows in production
Audit Logging
All group mapping operations are logged:
- Log entries include user, groups added, and user flags set
- Logs are written to the NetBox application log
- Monitor logs for unexpected group assignments
- Review logs during security audits
View group mapping logs:
kubectl logs <netbox-pod> -n kotsadm | grep "Azure AD group mapping"
Privileged Access Management
Consider implementing privileged access management:
- Use Azure AD Privileged Identity Management for temporary superuser access
- Require approval workflows for adding users to superuser groups
- Implement just-in-time access for administrative operations
- Regularly review group memberships and access patterns
Related Documentation
- Microsoft Entra ID Single Sign-On - Configure basic SSO authentication
- SAML Group Mapping - Alternative group mapping using SAML
- OpenID Connect (OIDC) SSO - Alternative OAuth 2.0 configuration
- LDAP Authentication - Alternative authentication method using LDAP