Netlify-cms: Authentication problem if not running on localhost

Created on 29 Jun 2018  路  35Comments  路  Source: netlify/netlify-cms

Hi, it would be great if we could use/develop NetlifyCMS sites on some Web IDE (Cloud 9, Codenvy, etc),
Currently, it is possible to use NetlifyCMS admin only on localhost, but it would be nice to show some love for Chromebook/Tablet/Convertible/etc. users...
The main problem is authentication.
I personally run NetlifyCMS on Cloud 9 with GitLab backend like described in docs, but can't access admin - there is always the same message in the popup: Failed to load settings from /.netlify/identity, and 404 error in console: GET http://my-site.c9users.io:8080/.netlify/identity/settings 404 (Not Found).
I use latest NetlifyCMS (1.9.2), latest Chrome on Windows.
If somebody knows for a working workarround I would be grateful for any info.

wontfix

Most helpful comment

I have the same issue with GitHub backend.

backend:
  name: github
  repo: hunhejj/my_cms_project

I can access the content manager just normal when running on localhost, but not when accessing through github with baseurl (e.g. username.github.io/my_cms_project/admin).

I get the following message when clicking on "Login with GitHub":

No Auth Provider Found

Make sure you've configured the API credentials for Github from the Access part of your Netlify site dashboard.

All 35 comments

@kosirm Have you tried using GitLab implicit grant for login? You can see our docs here: https://www.netlifycms.org/docs/authentication-backends/#gitlab-backend.

Thanks, @tech4him1 that's exactly the document I was following, maybe I'm doing something wrong, I don't know. I tried this and that... (Web Application Flow, Client-Side Implicit Grant)

Do you have the identity widget script left on your CMS page? It needs to be removed if you use implicit grant.

I don't know how to do this. Any detailed information highly appreciated.

What is the output of your admin HTML?

Thanks, @tech4him1 for an intelligent answer 馃槃 I commented赂out Netlify identity widget in site/static/admin/index.html and in site/static/partials/head.html . Now I get a login screen (username, password, login). If I try to log in with my Gitlab username/password, I get an error response in the console: POST http://my-site.c9users.io:8080/.netlify/identity/token 404 (Not Found). It's a step forward, but I still have no idea, what to do.

Alright, what is the backend section in your CMS config.yml? Make sure it matches the docs for implicit authentication. The backend name should be gitlab, not git-gateway.

According to documentation, I added gitlab to my site/config.toml.
So this is content of my config.toml:
baseurl = "/"
languageCode = "en-us"
title = "Homepage"
[backend]
name = "gitlab"
repo = "kosirm/rehobot-hugo-cms"
auth_type = "implicit"
app_id ="asdfadsfasdfasdfasdfasdfdsafaf3424522452352345234523452345324532"

Should I do something else?

@kosirm Your Hugo config.toml is completly seperate from your CMS admin. They are seperate files in separate locations:

+--- archetypes/
+--- content/
+--- static/
|      +--- admin/
|       |      +--- index.html <======== This is the CMS admin page.
|       |      +--- config.yml <======== This is the CMS config.
+--- layouts/
+--- themes/
+--- config.toml <============== This is your Hugo config.toml.

Your CMS settings should go in your CMS config.yml, which sits beside your CMS admin HTML page, and your Hugo settings should go in your Hugo config.toml, in the root of your repository. The GitLab authentication is part of the CMS, not Hugo, so it goes in your CMS configuration file.

Does that make sense? 馃槃

Thank you so much for your time @tech4him1 !!! Stupid me. Ok, I found config.yml 馃槃 Finally I get gitlab login screen, I get gitlab login redirect, I login, but I don't get redirect back. Instead, I finish on Gitlab User settings page with error message:
An error has occurred
Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.

This can be seen also in address bar: https://gitlab.com/oauth/authorize?client_id=undefined&redirect_uri=https%3A%2F%2Frehofly-infocube.c9users.io%3A8080%2Fadmin%2F&response_type=token&scope=api&state=5a80344a81a2d794eb37abacb94ee2554d2282ef03c095e3c50844ee521acf02
According to documentation I created Gitlab application with my cloud 9 address as redirect address.

@kosirm have you set the app_id referenced here: https://www.netlifycms.org/docs/authentication-backends/#client-side-implicit-grant? It's undefined in the URL you pasted - if that _is_ in the config.yml, it's probably a bug with the CMS.

Thanks @Benaiah, yes I referenced it like described. So client_id for Gitlab is the same as app_id? If so, I don't know...
This is on the beginning of my site/static/admin/config.yml:
backend:
name: gitlab
repo: kosirm/rehobot-hugo-cms
auth_type: implicit
app_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx....

App id is what I get from Gitlab when I created application:

Application Id | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx....
Secret: | yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy....
Callback url | https://rehofly-infocube.c9users.io:8080
Scopes | api聽(Access the authenticated user's API)

@kosirm The app_id setting is the correct location. However, it looks like you are running Netlify CMS v1.8.0 -- it will need updated to at least v1.9.1 to work with GitLab implicit authentication (that's where the bug was fixed).

Thank you much for help again @tech4him1
You are right... I just used one-click installation assumed that it is the latest build. In my package json I changed "netlify-cms": "netlify/netlify-cms#gitlab-build" to "netlify-cms": "1.9.3"
Now I get Gitlab error The redirect URI included is not valid.
My Gitlab redirect URI is https://rehofly-infocube.c9users.io:8080/admin
Is this outside of netlifycms scope?

I believe I've had that problem before -- the Callback URL in GitLab must be the exact admin URL. It should include the /admin part at the end.

I tried both (with and without /admin), it doesn't make difference for me. Maybe port number in the address could be a problem for Gitlab (???), I don't know... I will try with AWS Cloud 9 (I'm still using old Cloud 9), I think there is no port number required, because you are working on your "own" virtual box...
However, for me this is not so important anymore, because this month I will become proud owner of Dell Inspiron 7773 - Intel i7-8550U 4.0GHz / 17.3" Full HD Touch / 16GB RAM / SSD 512GB / nVidia MX150-2GB / Windows 10 Home, so I will be able to develop on my localhost on laptop.
Anyway, I believe that there are many developers around the world in my current situation (and mobile computing is getting more and more popular)...

Hey @kosirm, don't you get access to the NetlifyCMS admin when you deploy your site to Netlify? Or is that something different than the admin you get on local? Or are you not deploying to Netlify? Am I missing something? Thanks.

@davidvm2 it should be the same thing if it could be opened 馃槃 The only problem is that netlify-cms authentication scripts are configured to work on a real localhost and I was using cloud 9 at that time.

I have the same issue with GitHub backend.

backend:
  name: github
  repo: hunhejj/my_cms_project

I can access the content manager just normal when running on localhost, but not when accessing through github with baseurl (e.g. username.github.io/my_cms_project/admin).

I get the following message when clicking on "Login with GitHub":

No Auth Provider Found

Make sure you've configured the API credentials for Github from the Access part of your Netlify site dashboard.

I am also seeing same problem with github, here is my configuration. (This is real production configuration). Site is hosted on s3 bucket and I am using aws cloudfront.

backend:
  name: github
  repo: user/repo-home-page
  branch: master
  base_url: https://api.netlify.com
  site_domain: company.goglides.com
  auth_endpoint: auth
  api_root: https://api.github.com

I am seeing following error when trying to browse https://company.goglides.com/admin

No Auth Provider Found
Make sure you've configured the API credentials for Github from the Access part of your Netlify site dashboard

If i replaced site_domain with site_domain: cms.netlify.com, its says authorized but doing nothing.

screen shot 2019-01-27 at 11 46 05 am

@hunhejj If you are not hosting on Netlify, you will need to run your own authentication server to use GitHub authentication: https://www.netlifycms.org/docs/authentication-backends/#github-backend.

@pandeybk Do you have a Netlify site with domain "company.goglides.com" set up, and the API credentials configured?

@tech4him1 you answered my question when you replied @hunhejj. I am not running on netlify, site is hosted on s3 bucket and I am using aws cloudfront. Looks like we need to update Netlify documents though, its not clear from documentation that we need to host on netlify to make it work. Anyways, thank you for your response. I will take a look on custom authentication server.

Hey guys, I am getting the same error message like @pandeybk.
I am running with the following backend settings:

backend:
  name: github
  repo: Shogoki/myRepo # Path to your GitHub repository

I already have my own authentication server running (as is required and statet out by @tech4him1). If i server my site locally i can navigate to /admin and click on "Login with GitHub" and it麓s logging me in. But when i deploy the whole site to GH pages I am getting the "No Auth Provider Found" message.
Anybody has an idea about that?

Okay, just forget about my last post. It was all my fault:
When using my own oauth server, I have to specify it in the config of course:

backend:
  name: github
  repo: Shogoki/myRepo # Path to your GitHub repository
  base_url: https://my-oauth.example.org/

After adding this, it is working :-)
I麓m just curious how it worked without that setting, when serving on localhost

When running Netlify CMS on localhost, a freebie auth server provided by Netlify (cms.netlify.com) is used by default:

https://github.com/netlify/netlify-cms/blob/bb84c793f59f9e8ef6ad141d86a3304fe215b349/packages/netlify-cms-lib-auth/src/netlify-auth.js#L84

I am seeing the same "No Auth Provider Found" message when trying to login via Github while being hosted on Netlify... Works when on localhost.

backend:
name: github
repo: xxx/yyy

Isn't this supposed to work from Netlify? I am running 2.3.3 version of Netlify CMS.

no-auth-provider-found

This issue seems to have become a "meta-issue" for a bunch of unrelated things that give very similar error messages. Let's try to classify these a bit so we can move forward:

  • Using Netlify Identity + Git Gateway:

    • When used on localhost, Identity will open a message box asking for your live domain URL so that you can authenticate. Some users will be using alternative URLs for development, so they need some way to specify their live Netlify URL. There may be more depth to this problem. (https://github.com/netlify/netlify-cms/issues/1474#issue-337130897)

  • Using GitLab w/ implicit auth

    • Weird issues connecting from some domains: (https://github.com/netlify/netlify-cms/issues/1474#issuecomment-403227927)

  • Using GitHub

    • Having the Netlify auth server work magically on localhost but not anywhere else is confusing. We either need to document this really well or find some way to make it not appear so magic. (pretty much the entire rest of discussion).

@bskrypnyk Looks like you missed one of the steps in our GitHub backend setup docs:

  1. Follow the authentication provider setup steps in the Netlify docs.

@tech4him1 - Thank you, that worked! I did miss that.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sorry to come in here, but it's still unclear in the documentation.... may it's me.

netlifycms config:

backend:
  name: github
  repo: Berndinox/klausonl
  branch: master
  site_domain: klaus.onl
  base_url: https://api.netlify.com
  auth_endpoint: auth
  api_root: https://api.github.com

@tech4him1
the 2nd link:

When you complete the registration, you'll be given a Client ID and a Client Secret for the app. You'll need to add these to your Netlify site:

From your site dashboard, go to Settings > Access control > OAuth.
Under Authentication Providers, click Install Provider.
Select GitHub and enter the Client ID and Client Secret, then save.

Well i have no side on netlify, thats why i choose the github provider.
Where i have to insert my tokens from github?

thanks!

@Berndinox, these are the docs to follow:
https://www.netlifycms.org/docs/github-backend/
If not hosting on Netlify you'll need to set up an external OAuth client:
https://www.netlifycms.org/docs/external-oauth-clients/

Solved by following this (not clearly linked in docs):
https://docs.netlify.com/visitor-access/oauth-provider-tokens/#setup-and-settings

(not clearly linked in docs)

Indeed! I've read the docs and a lot of issues and was only able to solve it by following the step you've referenced. Thank you _a lot_

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zebapy picture zebapy  路  3Comments

marcojakob picture marcojakob  路  3Comments

chriskirknielsen picture chriskirknielsen  路  3Comments

TomPichaud picture TomPichaud  路  3Comments

ghost picture ghost  路  3Comments