netbox-community / netbox-docker

🐳 Docker Image of NetBox
https://github.com/netbox-community/netbox-docker/wiki
Apache License 2.0
1.81k stars 828 forks source link

Issues with REMOTE_AUTH_BACKEND variable and social_core for SSO #1248

Closed alexandrud closed 4 months ago

alexandrud commented 4 months ago

Current Behavior

Netbox setup is working without SSO. I've added the following to the netbox.env file:

REMOTE_AUTH_ENABLED=true
REMOTE_AUTH_AUTO_CREATE_USER=true
REMOTE_AUTH_BACKEND='social_core.backends.open_id_connect.OpenIdConnectAuth'
SOCIAL_AUTH_OIDC_OIDC_ENDPOINT='<endpoint>'
SOCIAL_AUTH_OIDC_KEY='<oidc_client_id>'
SOCIAL_AUTH_OIDC_SECRET='<oidc_client_secret>'

The error is No module named "'social_core". Notice the strong quote included in the module name. For some reason the configuration.py script includes that quote as part of the library string.

If I enter just the string without quotes I can see the OIDC login button.

REMOTE_AUTH_BACKEND=social_core.backends.open_id_connect.OpenIdConnectAuth

However, when I press it I get:

<class 'TypeError'>
unsupported operand type(s) for +: 'NoneType' and 'str'

I'm at a loss. Can anyone help?

Expected Behavior

Get redirected to the OIDC login page.

Docker Compose Version

podman-compose version: 1.0.6

Docker Version

Client:       Podman Engine
Version:      4.6.1
API Version:  4.6.1
Go Version:   go1.20.12
Built:        Fri Apr 19 04:05:11 2024
OS/Arch:      linux/amd64

The git Revision

0c99ff8b5663db3e0db5a45660cebda9f917508b

The git Status

On branch release.

Startup Command

podman-compose up -d

NetBox Logs

podman logs -f netbox-docker_netbox_1
↩️ Skip creating the superuser
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
✅ Initialisation is done.
⏳ Waiting for control socket to be created... (1/10)
2024/05/31 11:51:28 [warn] 2#2 Unit is running unprivileged, then it cannot use arbitrary user and group.
2024/05/31 11:51:28 [info] 2#2 unit 1.32.0 started
2024/05/31 11:51:28 [info] 83#83 discovery started
2024/05/31 11:51:28 [notice] 83#83 module: python 3.11.6 "/usr/lib/unit/modules/python3.11.unit.so"
2024/05/31 11:51:29 [info] 2#2 controller started
2024/05/31 11:51:29 [notice] 2#2 process 83 exited with code 0
2024/05/31 11:51:29 [info] 85#85 router started
2024/05/31 11:51:29 [info] 85#85 OpenSSL 3.0.10 1 Aug 2023, 300000a0
⚙️ Applying configuration from /etc/unit/nginx-unit.json
2024/05/31 11:51:30 [info] 88#88 "netbox" prototype started
2024/05/31 11:51:30 [info] 89#89 "netbox" application started
✅ Unit configuration loaded successfully
2024/05/31 11:51:32 [notice] 2#2 process 81 exited with code 0
2024/05/31 11:51:42 [info] 119#119 "netbox" application started
::1 - - [31/May/2024:11:51:54 +0000] "GET /login/ HTTP/1.1" 200 3447 "-" "curl/8.2.1"
10.89.0.150 - - [31/May/2024:11:52:04 +0000] "GET / HTTP/1.1" 200 33201 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0"
10.89.0.150 - - [31/May/2024:11:52:06 +0000] "GET /login/?next=/ HTTP/1.1" 200 3528 "http://<redacted>:7080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0"
10.89.0.150 - - [31/May/2024:11:52:08 +0000] "GET /oauth/login/oidc/?next=%2F HTTP/1.1" 500 1646 "http://<redacted>:7080/login/?next=/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0"
::1 - - [31/May/2024:11:52:10 +0000] "GET /login/ HTTP/1.1" 200 3447 "-" "curl/8.2.1"
::1 - - [31/May/2024:11:52:26 +0000] "GET /login/ HTTP/1.1" 200 3447 "-" "curl/8.2.1"

Content of docker-compose.override.yml

version: '3.4'
services:
  netbox:
    ports:
      - 7080:8080
cimnine commented 4 months ago

SOCIAL_* can not be configured via the environment variables, since they are not read in our configuration.py.

You will need to provide your own extra.py configuration file (can be a different name as well) and either (a) mount it into the container at /etc/netbox/config/you_file.py or (b) extend the netbox-docker image.