Home
Support Forums

Spaces in un/pw in `Basic-Auth` headers file

Hi there,

I’m wondering if the Basic-Auth “pseudo-header” that can be set via a _headers override file can contain spaces. I have a number of users who prefer usernames and passwords that contain spaces, but I haven’t been able to provide these in the _headers override file without running into syntax errors during a Netlify build.

Example _headers file that doesn’t work:

/*
  Basic-Auth: my username:my pass with spaces

If I collapse the username and password to not include any spaces, the _headers file works just fine:

/*
  Basic-Auth: myusername:mypasswithspaces

I have tried quoting this pair in various ways, but haven’t been able to get things working.

Thanks for the help!

Aaron @ FINE
aaron@wearefine.com

Welcome to the forums @fine

Using Basic Auth you might access a site https://user:password@example.com so having https://test user:test password@example.com will translate to https://test%20user:test%20password@example.com (use of such URLs is deprecated now too.)

However, like you, I cannot get anything like that working via using escaping, quoting, etc. I cannot say if this is by design, a bug, or otherwise, in Netlify’s case. I did find open tickets with others here and here both of which are from May 2019.

Keeping in mind that

Basic authentication does not encrypt access credentials or provide a method for user-initiated logout.
—Source: Password protection | Netlify Docs

perhaps Netlify Identity or RBAC are better options.