Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netlify CMS doesn't work when hosting on Netlify with access restriction #818

Closed
meh-evry opened this issue Nov 14, 2017 · 24 comments
Closed

Comments

@meh-evry
Copy link


BUG REPORT INFORMATION

Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST
-->

- Do you want to request a feature or report a bug?
Bug

- What is the current behavior?
while hosting on netlify, i have set a password restriction in netlify for visitors while the website is being developed. when i try to access the admin view, the page is empty. if i remove the password from netlify, the cms starts working again.

- If the current behavior is a bug, please provide the steps to reproduce.

  1. follow quick setup guide for netlify cms
  2. in netlify hosting, set password in Access Control section
  3. go to mysite.netlify.com/admin
  4. now the 'login with netlify identity' pops up
  5. click on login button
  6. a dark grey overlay gets added, but nothing else shows up, errors in browser console:
netlify-identity-widget.js:1 GET http://mysite.netlify.com/.netlify/identity/settings 500 (Internal Server Error)

- What is the expected behavior?
at step 6, i expect to see the login widget

- Please mention your CMS, node.js, and operating system version.
Netlify CMS version 0.7.3
node v7.5.0
macOS sierra 10.12.6

@fool
Copy link

fool commented Nov 14, 2017

I believe this is caused by a known issue which we are tracking here internally:

https://github.com/netlify/bitballoon/issues/746

...which is due to netlify's proxying behavior rather than the CMS or Identity specifically.

@fool fool added the kind: bug label Nov 14, 2017
@verythorough
Copy link
Contributor

verythorough commented Nov 14, 2017

It's also worth noting that this issue is particular to the git-gateway backend. You can still use the github backend with password-protected sites.

We're currently restructuring the Authentication & Backend docs (#751), but you can find configuration details for the github backend in this preview:
https://preview-auth-doc--netlify-cms-www.netlify.com/docs/authentication-backends/#github-backend

@meh-evry
Copy link
Author

meh-evry commented Nov 20, 2017 via email

@erquhart
Copy link
Contributor

This is now fixed as of 0.7.6.

@criticalmash
Copy link

Hi, I just tried this in v1.0.2 and v0.7.6 and using git-gateway. Works fine (and v1.0.2 looks nice) while Access Control is off. But collection items disappear from CMS when Access Control is on.

I'd sure like to give clients access to the CMS while sites are in development. Is there anything I can do to make this possible besides sign them up for Github accounts?

@erquhart erquhart reopened this Dec 20, 2017
@erquhart
Copy link
Contributor

erquhart commented Dec 20, 2017

I must have had this mistaken with another issue, as it can't be addressed through the CMS, but my understanding is that it was fixed within the Netlify platform within the last two weeks. Testing now.

@erquhart
Copy link
Contributor

@criticalmash I'm not able to reproduce - accessing the cms prompts for the access control password as expected, but once that's entered, everything works. Can you provide a specific repro case?

@criticalmash
Copy link

Hi @erquhart thanks for looking into this. I setup a publicly accessable test case here: https://happy-hugle-12b322.netlify.com/admin/

And here's the repository: https://github.com/criticalmash/asm-pager-test

I used the password netlifytests under Password / JWT secret in the access control pane, and setup a git-gateway token under Identity without any roles.

The CMS config file is: https://github.com/criticalmash/asm-pager-test/blob/master/admin/config.yml
it contains a markdown file under each collection.

When the Password / JWT secret field is blank, I can see and access the a markdown file under each collection. When a password is set, I get 'No Entries'.

Let me know if there's any more information you need or if I should setup the test case differently.

Thanks and Happy New Year,
John

@erquhart
Copy link
Contributor

erquhart commented Jan 2, 2018

Thanks for the repro case - the response is the HTML for the password protection page. Looks like Netlify's Git Gateway is being blocked when there's a password.

@brycekahle thoughts on this?

@brycekahle
Copy link

Lets loop in @biilmann since he wrote git gateway.

@erquhart
Copy link
Contributor

@brycekahle @biilmann bump

@jcsibon
Copy link

jcsibon commented Mar 13, 2018

Hi @brycekahle, @erquhart and @biilmann, any further thoughts on this issue ?
I guess the problem can be bypassed using Basic-Auth, but i don't now how to apply it only to non admin urls... Something like this :

/*
Basic-Auth: dev:lasagne
/admin
Basic-Auth: public

Any clue ?
Thanks !

@erquhart
Copy link
Contributor

erquhart commented Mar 15, 2018

@jcsibon I don't think this can be fixed from outside of Netlify's platform - that would mean that there's a way to bypass Netlify's password protection.

@brycekahle I don't think this is a git gateway problem. I could be wrong, but it seems this would have to be dealt with at the platform level.

@robsterlini
Copy link

@jcsibon Did you find a way to turn off Basic-Auth for certain paths? I'm stumped by the same thing!

@fool
Copy link

fool commented Apr 26, 2018

There is no "except this path" or "not this path" directive in the headers specifications. there is only "this path and this other path and this path too and we didn't mention this last path so it is not covered"

@verythorough
Copy link
Contributor

There's actually another workaround for this issue - you can run Netlify CMS on a separate site.

To demonstrate, I deployed a site using the Netlify CMS Jekyll starter.

Before adding password protection, I visited the site and added a post in the CMS. I could see the post in the main site as well as in the CMS Collection list.Then I turned on password protection, and confirmed that the post could no longer be found in the CMS UI.

You can try it yourself at https://hidden-site.netlify.com/admin
The site password is I'm hiding
Registrations are open, and I've enabled GitHub login, so you can log in quickly. You'll see that there are no posts in the collection list.

Next, I made a separate site, from the same repo, at https://open-cms.netlify.com
This time, I removed the build command and set the publish directory to admin.
I did not turn on password protection, but did enable Identity and Git Gateway for login to the CMS. The only part of the repo that is published to this site is the CMS.

You can access it at https://open-cms.netlify.com, again using open registration with GitHub.
You'll see there are posts in the collection list, and when you add or edit a post, and it will build on the main site.

I used the Jekyll starter because the CMS setup in /admin is standalone, which made it easy to demo. You could include build tools, though, and you could separate the CMS from the main site in a variety of ways.

With a custom domain setup, you could have the main content site at sitename.com and the admin UI at a subdomain like admin.sitename.com.

@runofthemill
Copy link

Thank you @verythorough for the workaround!

For Gatsby, since I am using the gatsby-plugin-netlify-cms plugin I had to leave the Build command setting to gatsby build, and I set the Publish directory to public/admin

Cheers!

@verythorough
Copy link
Contributor

Awesome, @runofthemill!

@tech4him1
Copy link
Contributor

@verythorough I created a site with password protection myself and I could not reproduce. Once I type in the password, the page reloads and the CMS login works normally. All posts show up. Any other necessary steps to reproduce?

@runofthemill
Copy link

@tech4him1 my use case may be somewhat different, but I believe where it doesn't work is having a subdomain for staging that you want password protected. The option to add a password via the UI doesn't work, as that applies to all domains for a site, even the production domain.

@tech4him1
Copy link
Contributor

@runofthemill Mind walking me through how to reproduce that? How are you adding the password?

@verythorough
Copy link
Contributor

@tech4him1 You're right—looks like the reported issue with password-protected sites has been fixed in the 4 months since I wrote up that workaround. Must have been on the password-protection side of things, since I haven't updated the CMS on my test site.

@erquhart
Copy link
Contributor

@verythorough sounds like we can close this, please reopen if I misunderstood.

@verythorough
Copy link
Contributor

It looks like @runofthemill's question wasn't answered, but as I read it, it sounds like a separate issue with Netlify itself.

@runofthemill, this is out of scope for Netlify CMS, but a short answer for you is that you can create multiple sites from the same repository. You can stop running staging branch deploys on the production site, then add a new site that builds the staging branch only, with password protection on that site. You can assign that site a subdomain of your main domain. If that doesn't address your issue or you have any other questions, you can contact [email protected] for more help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants