Skip to content

Authentication problem if not running on localhost #1474

New issue

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

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

Already on GitHub? # to your account

Closed
kosirm opened this issue Jun 29, 2018 · 35 comments
Closed

Authentication problem if not running on localhost #1474

kosirm opened this issue Jun 29, 2018 · 35 comments
Labels

Comments

@kosirm
Copy link

kosirm commented Jun 29, 2018

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.

@tech4him1
Copy link
Contributor

@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.

@kosirm
Copy link
Author

kosirm commented Jun 30, 2018

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)

@tech4him1
Copy link
Contributor

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

@kosirm
Copy link
Author

kosirm commented Jul 1, 2018

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

@tech4him1
Copy link
Contributor

What is the output of your admin HTML?

@kosirm
Copy link
Author

kosirm commented Jul 2, 2018

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.

@tech4him1
Copy link
Contributor

tech4him1 commented Jul 2, 2018

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.

@kosirm
Copy link
Author

kosirm commented Jul 4, 2018

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?

@tech4him1
Copy link
Contributor

@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? 😄

@kosirm
Copy link
Author

kosirm commented Jul 6, 2018

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.

@Benaiah
Copy link
Contributor

Benaiah commented Jul 6, 2018

@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.

@kosirm
Copy link
Author

kosirm commented Jul 7, 2018

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)

@tech4him1
Copy link
Contributor

tech4him1 commented Jul 7, 2018

@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).

@kosirm
Copy link
Author

kosirm commented Jul 7, 2018

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?

@tech4him1
Copy link
Contributor

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.

@kosirm
Copy link
Author

kosirm commented Jul 8, 2018

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)...

@davidvm2
Copy link

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.

@kosirm
Copy link
Author

kosirm commented Aug 23, 2018

@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.

@hunhejj
Copy link

hunhejj commented Jan 5, 2019

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.

@pandeybk
Copy link

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

@tech4him1
Copy link
Contributor

@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.

@tech4him1
Copy link
Contributor

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

@pandeybk
Copy link

@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.

@Shogoki
Copy link

Shogoki commented Feb 11, 2019

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?

@Shogoki
Copy link

Shogoki commented Feb 11, 2019

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

@erquhart
Copy link
Contributor

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

@bskrypnyk
Copy link

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

@tech4him1
Copy link
Contributor

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. (Authentication problem if not running on localhost #1474 (comment))
  • Using GitLab w/ implicit auth
  • 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).

@tech4him1
Copy link
Contributor

@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.

@bskrypnyk
Copy link

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

@stale
Copy link

stale bot commented Oct 29, 2019

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.

@stale stale bot added the wontfix label Oct 29, 2019
@Berndinox
Copy link

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!

@erezrokah
Copy link
Contributor

@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/

@SKempin
Copy link

SKempin commented Jul 4, 2020

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

@chonz0
Copy link

chonz0 commented Jul 16, 2020

(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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests