Skip to content

Remote Auth does not sanitize usernames #9669

@D3luxee

Description

@D3luxee

NetBox version

v3.2.2

Python version

3.10

Steps to Reproduce

  1. Setup netbox with remote auth based on netbox.authentication.RemoteUserBackend / Header
  2. Auto Create User must be enabled, see configuration example below
  3. Now open netbox and set the define AUTH_HEADER to a username that contains invalid characters like : which is used for example by Google IAP
  4. This creates a new user in netbox, now open the admin interface of netbox and try to change anything in the user (/admin/auth/user/)
  5. The user edit dialog validates the username if you change something, the frontend does not allow saving any changes there because of an invalid character in the username.
REMOTE_AUTH_ENABLED: true
REMOTE_AUTH_BACKEND: "netbox.authentication.RemoteUserBackend"
REMOTE_AUTH_HEADER: "HTTP_X_GOOG_AUTHENTICATED_USER_EMAIL"
REMOTE_AUTH_AUTO_CREATE_USER: true                                                                                                                                                                                                                                                                                                                                                 

Expected Behavior

Netbox should sanitize the usernames that are provided via REMOTE_AUTH_HEADER to create valid usernames.

Observed Behavior

Google IAPs headers have a value of: accounts.google.com:[email protected] and it creates a new user based on this in netbox.
But the admin dialogs to change or update those user accounts validates the username and rejects any changes because of invalid characters in the username:

Enter a valid username. This value may contain only letters, numbers, and @/./+/-/_ characters.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions