-`netbox.company` is the FQDN of the NetBox install.
-`authentik.company` is the FQDN of the authentik install.
Create an application in authentik and note the slug you choose, as this will be used later. In the Admin Interface, go to _Applications_ -> _Providers_. Create a _OAuth2/OpenID provider_ with the following parameters:
Note the Client ID and Client Secret values. Create an application, using the provider you've created above.
## NetBox
:::info
This setup was tested and developed with NetBox Docker. For a non-Docker installation, the Docker part must be disabled and the non-docker part must be used.
:::
The following Docker env vars are required for the configuration.
To manage groups in NetBox custom social auth pipelines are required. To create them you have to create the `custom_pipeline.py` file in the NetBox directory with the following content.
# Update the user record with any changed info from the auth service.
'social_core.pipeline.user.user_details',
###################
# Custom pipelines
###################
# Set authentik Groups
'netbox.custom_pipeline.add_groups',
'netbox.custom_pipeline.remove_groups',
# Set Roles
'netbox.custom_pipeline.set_roles'
)
```
### Roles
In netbox, there are two special user roles `superuser` and `staff`. To set them, add your users to the `superusers` or `staff` group in authentik.
To use custom group names, the following scope mapping example can be used. In the example, the group `netbox_admins` is used for the `superusers` and the group `netbox_staff` for the `staff` users.
Name: `Netbox roles`
Scope name: `roles`
Expression:
```python
return {
"groups": ["superusers" if group.name == "netbox_admin" else "staff" if group.name == "netbox_staff" else group.name for group in request.user.ak_groups.all()],
}
```
This scope mapping must also be selected in the _OAuth2/OpenID Provider_ created above.