Preview Deploy Authentication

Hello,

I can see from the documentation that it is possible to enable Basic Auth for preview deploys in order to restrict access. Is it possible to enable other authentication for preview deploys like Netlify Identity or use a third party like GitHub?

Many thanks,
Jeff

Hi @knoxjeffrey, the basic-auth access control is done via a custom header so it’s pretty straightforward to implement. However, with Netlify Identity, you would likely need to implement a lot of that code in your site directly. So, while it is likely possible, a lot of the work will fall to you.

Let me know if you have any other questions.

Do you mean that authentication for previews needs to be custom implemented and is not an option in the site settings?
Either way, please point to any further information that can help me restrict access to previews.

Hi, @bmansheim. The headers in the netlify.toml format might look like this:

[[headers]]
  for = "/*"
  [headers.values]
    Basic-Auth = "someuser:somepassword anotheruser:anotherpassword"

Would you please try that and let us know if there are other questions (or if it doesn’t work for you)?

Ah. So I would have to change the netlify.toml file in the branch and then remove that change before the merge to the public site so that the authentication wouldn’t get applied to the public site. I think I got it. Thanks.