Skip to content

Commit 3771874

Browse files
authored
Merge pull request #120 from netboxlabs/feat/PRD-406
NBE SAML SSO
2 parents a45733e + 8d619c2 commit 3771874

File tree

6 files changed

+142
-0
lines changed

6 files changed

+142
-0
lines changed
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Configuring SAML Group Mapping in NetBox Enterprise
2+
3+
Setting up Group Mapping for SAML requires the [base SAML SSO Setup](./nbe-saml.md) to be configured and working first.
4+
5+
## Configure the IdP
6+
7+
NetBox Enterprise expects a SAML group attribute statement to be named `groups`, which contains a list of group names the user belongs to. If your IdP sends group information under a different attribute name, such as `MemberOf`, you must update its configuration to use `groups` to ensure proper mapping.
8+
9+
Example:
10+
11+
![SAML Settings](../images/netbox-enterprise/SAML/netbox-enterprise-saml-idp-groups.png)
12+
13+
## Configuring Group Mappings
14+
15+
1. Desired groups must first be configured within NetBox
16+
2. In the Admin Console for NetBox Enterprise, navigate to the **Config** tab and scroll to the bottom to check **Advanced Settings**
17+
3. Apply the following into **NetBox Python Configuration Overrides**, replacing the relevant information.
18+
19+
``` python
20+
SOCIAL_AUTH_PIPELINE = (
21+
'social_core.pipeline.social_auth.social_details',
22+
'social_core.pipeline.social_auth.social_uid',
23+
'social_core.pipeline.social_auth.social_user',
24+
'social_core.pipeline.user.get_username',
25+
'social_core.pipeline.social_auth.associate_by_email',
26+
'social_core.pipeline.user.create_user',
27+
'social_core.pipeline.social_auth.associate_user',
28+
'netbox.authentication.user_default_groups_handler',
29+
'social_core.pipeline.social_auth.load_extra_data',
30+
'social_core.pipeline.user.user_details',
31+
'nbc_auth_extensions.saml_authentication.saml_map_groups',
32+
)
33+
34+
SOCIAL_AUTH_PIPELINE_CONFIG = {
35+
'SAML_USER_FLAGS_BY_GROUP': {
36+
"is_staff": {
37+
"idp-staff-group-name" # remove this line if no group should be granted 'Staff'
38+
},
39+
"is_superuser": {
40+
"idp-superuser-group-name" # remove this line if no group should be granted 'Superuser'
41+
}
42+
},
43+
'SAML_GROUP_MAP': {
44+
"idp-group-name-1": "netbox-group-name-1",
45+
"idp-group-name-2": "netbox-group-name-2"
46+
}
47+
}
48+
```
49+

docs/netbox-enterprise/nbe-saml.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# NetBox Enterprise SAML Configuration Guide
2+
3+
## Required Information
4+
5+
- **Entity ID**: This is your IdP's Entity ID obtained from the SAML metadata
6+
- **SSO URL**: Your IdP's SSO login URL
7+
- **x509 Certificate**: The Base64-encoded X.509 certificate used to sign SAML assertions
8+
- **NetBox Enterprise URL**: URL For the NetBox Enterprise instance
9+
10+
## Generate Public and Private Keys
11+
These will be used later during configuration and can be generated from anywhere. Be sure to keep the private key secure.
12+
13+
``` shell
14+
openssl genpkey -algorithm RSA -out saml_private_key.pem -pkeyopt rsa_keygen_bits:2048
15+
16+
openssl req -new -x509 -key saml_private_key.pem -out saml_cert.pem -days <specify number of days valid>
17+
```
18+
19+
## Configure the IdP
20+
Set up the IdP using the public key from the previous section, and the ACS URL (based on the NetBox Enterprise URL). These steps will vary depending on the IdP in use.
21+
22+
**ACS URL**: "{NetBox Enterprise URL}/oauth/complete/saml/"
23+
**SP Entity ID**: "{NetBox Enterprise URL}"
24+
25+
Example:
26+
27+
![SAML Settings](../images/netbox-enterprise/SAML/netbox-enterprise-saml-idp.png)
28+
29+
### Configure Attributes or Claims
30+
Setup similar mappings in the IdP's "Attributes" or "Claims" section. Names may vary on different platforms.
31+
32+
``` shell
33+
"attr_first_name": "first_name"
34+
"attr_last_name": "last_name"
35+
"attr_username": "email"
36+
"attr_email": "email"
37+
```
38+
39+
Example:
40+
41+
![Attribute Settings](../images/netbox-enterprise/SAML/netbox-enterprise-saml-attributes.png)
42+
43+
### Capture x509 Certificate
44+
After setting up the IdP, generate a certificate in the IdP (this may be done by default). The x509 certificate can either be downloaded or viewed in the SAML metadata URL. This certificate data will be used in the next step.
45+
46+
## Update NetBox Enterprise Config
47+
1. In the Admin Console for NetBox Enterprise, navigate to the **Config** tab and scroll to the bottom to check **Advanced Settings**
48+
2. Apply the following into **NetBox Python Configuration Overrides**, replacing the relevant information from previous steps.
49+
50+
``` shell
51+
REMOTE_AUTH_ENABLED = True
52+
REMOTE_AUTH_AUTO_CREATE_USER = True
53+
REMOTE_AUTH_BACKEND = 'social_core.backends.saml.SAMLAuth'
54+
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
55+
56+
SOCIAL_AUTH_SAML_SP_ENTITY_ID = "<NetBox Enterprise Instance URL>"
57+
SOCIAL_AUTH_SAML_SP_PUBLIC_CERT = "-----BEGIN CERTIFICATE-----<Public Key goes here>-----END CERTIFICATE-----"
58+
SOCIAL_AUTH_SAML_SP_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----<Private Key goes here>-----END PRIVATE KEY-----"
59+
60+
SOCIAL_AUTH_SAML_ORG_INFO = {
61+
"en-US": {
62+
"name": "<Org Name>",
63+
"displayname": "<Org Display Name>",
64+
"url": "<Org Website>",
65+
}
66+
}
67+
68+
SOCIAL_AUTH_SAML_TECHNICAL_CONTACT = {
69+
"givenName": "support",
70+
"emailAddress": "[<Support Email Address>](mailto:<Support Email Address>)"
71+
}
72+
73+
SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {
74+
"givenName": "support",
75+
"emailAddress": "[<Support Email Address>](mailto:<Support Email Address>)"
76+
}
77+
78+
SOCIAL_AUTH_SAML_ENABLED_IDPS = {
79+
"idp": {
80+
"entity_id": "<SAML Entity ID>",
81+
"url": "<SAML Sign-on URL>",
82+
"x509cert": "<x509 Certificate>",
83+
"attr_user_permanent_id": "email",
84+
"attr_first_name": "first_name",
85+
"attr_last_name": "last_name",
86+
"attr_username": "email",
87+
"attr_email": "email",
88+
}
89+
}
90+
```

mkdocs.yml

+3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ nav:
114114
- Entra ID:
115115
- Microsoft Entra ID SSO: "netbox-enterprise/nbe-azure-sso.md"
116116
- Entra ID Group Mapping: "netbox-enterprise/nbe-azure-group-mapping.md"
117+
- SAML:
118+
- SAML SSO Setup: "netbox-enterprise/nbe-saml.md"
119+
- SAML Group Mapping: "netbox-enterprise/nbe-saml-group-map.md"
117120
- LDAP: "netbox-enterprise/nbe-ldap.md"
118121
- "Administration":
119122
- "TLS and Ingress": "netbox-enterprise/nbe-tls-ingress.md"

0 commit comments

Comments
 (0)