decaporg / decaporg/decap-cms

Login with github as backend fails if base url contains additional path segment

Open
#3,622 8 comments 1 reaction 0 assignees View on GitHub
pinned status: confirmed type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Describe the bug**
If you use github as backend the following basic setup is required:
- run your own github auth server backend (see https://github.com/vencax/netlify-cms-github-oauth-provider) - https://mygithub-auth-backend.org as an example
-create oauth app in github and configure callback url pointing to your github auth server backend (https://mygithub-auth-backend.org/callback)
- set base_url in config.yml according to your github auth server backend (https://mygithub-auth-backend.org)
--> This works well if the base url does not contain any path segment. This does not work if you use an additional path segment in your github auth server.

Example:
- callback url -> https://mygithub-auth-backend.org/oauth2/callback
- base_url in config.yml: https://mygithub-auth-backend.org/oauth2

The authentication and token creation with github is successfull but the communication between the auth popup and the original page fails.

**To Reproduce**
- setup github auth backend with additional path segment
- adjust base_url in config
- try to login

**Expected behavior**
Login should work

**Applicable Versions:**
- Netlify CMS version: app - 2.12.9, core: 2.24.4, cms: 2.10.45
- Git provider: Github
- OS: windows 10
- Browser version Chrome 80

**Additional context**
It seems that the following check in netlify-auth.js is not working:
`e.origin !== this.base_url`
I think origin is always just the host without any path segment.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.