- Do you want to request a feature or report a bug?
Question/Bug
tl;dr: Just please point me to the direction to how I can self-host netlify's identity
- What is the current behavior?
Trying to make a jekyll site using netlify-cms, gotrue and git-gateway work together.
Only made it possible to authenticate via github or netlify, not with self-hosted gotrue and git-gateway.
- If the current behavior is a bug, please provide the steps to reproduce.
My steps to produce it were to clone the 2 projects in separate folders alongside a folder with my jekyll site with netlify-cms, then create a docker-compose like the following:
docker-compose.yml
version: '2'
services:
jekyll:
image: jekyll/jekyll
command: jekyll serve --watch --incremental
ports:
- 4000:4000
volumes:
- ./jekyll:/srv/jekyll
git-gateway:
build: ./git-gateway
env_file:
- ./git-gateway/.env
ports:
- 9999:9999
depends_on:
- gotrue
links:
- gotrue
gotrue:
build: ./gotrue
env_file:
- ./gotrue/.env
ports:
- 8081:8081
depends_on:
- mysql
links:
- mysql
mysql:
image: mysql
ports:
- 3306:3306
environment:
MYSQL_DB: gotrue_development
MYSQL_ROOT_PASSWORD: password
git-gateway/.env
GITGATEWAY_JWT_SECRET="CHANGE-THIS! VERY IMPORTANT!"
GITGATEWAY_DB_DRIVER=sqlite3
DATABASE_URL=gorm.db
GITGATEWAY_API_HOST=localhost
PORT=9999
GITGATEWAY_GITHUB_ACCESS_TOKEN="personal-access-token"
GITGATEWAY_GITHUB_REPO="romdim/jekyll-netlify-cms"
GITGATEWAY_ROLES="admin,cms" # leave blank to allow all roles
gotrue/.env
GOTRUE_JWT_SECRET="CHANGE-THIS! VERY IMPORTANT!"
GOTRUE_JWT_EXP=3600
GOTRUE_JWT_AUD=localhost
GOTRUE_DB_DRIVER=mysql
DATABASE_URL=root:password@tcp(127.0.0.1:3306)/gotrue_development?parseTime=true
GOTRUE_API_HOST=localhost
PORT=8081
#GOTRUE_SITE_URL=https://romdim.github.io/jekyll-netlify-cms/
GOTRUE_SITE_URL=localhost:4000
GOTRUE_SMTP_HOST=smtp.mandrillapp.com
GOTRUE_SMTP_PORT=587
[email protected]
GOTRUE_SMTP_PASS=super-secret-password
[email protected]
GOTRUE_MAILER_SUBJECTS_CONFIRMATION="Welcome to GoTrue!"
GOTRUE_MAILER_SUBJECTS_RECOVERY="Reset your GoTrue password!"
GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI=http://localhost:8081/callback
GOTRUE_LOG_LEVEL=DEBUG
GOTRUE_OPERATOR_TOKEN=super-secret-operator-token
With this configuration, when I go to admin I can see the page to login, but don't have any credentials to do so. I am certain it is not connected to gotrue or git-gateway. I need to signup and store my user through those services.
Also tried as suggested in Gitter to move and rename:
git-gateway folder to jekyll/.netlify/git/github
gotrue folder to jekyll/.netlify/identity/token
Unfortunately it doesn't seem to make any difference.
- What is the expected behavior?
I expect to be able to self-host my identity provider and git proxy in order to make changes to my static site.
- Please mention your CMS, node.js, and operating system version.
CMS version: 1.0.3
node.js and os versions are irrelevant I guess, docker handles them.
- Please link or paste your config.yml below if applicable.
config.yml
backend:
# name: github
# repo: romdim/jekyll-netlify-cms
# branch: gh-pages
name: git-gateway
branch: gh-pages
accept_roles: #optional - accepts all users if left out
- admin
- editor
site_domain: http://localhost:4000/jekyll-netlify-cms/admin/#/
display_url: https://example.com
publish_mode: editorial_workflow
media_folder: "images/uploads" # Media files will be stored in the repo under images/uploads
collections:
- name: "post" # Used in routes, e.g., /admin/collections/blog
label: "Post" # Used in the UI
folder: "_posts" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
fields: # The fields for each document, usually in front matter
- {label: "Layout", name: "layout", widget: "hidden", default: "post"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Categories", name: "categories", widget: "string"}
- {label: "Body", name: "body", widget: "markdown"}
tl;dr: Just please point me to the direction to how I can self-host netlify's identity
cc/ @biilmann @calavera @brycekahle
Bump, 24 days have passed since asking this. Please direct me to the answer and I may be able to document it if you don't have the time. Thanks!
@romdim you need a way to create users. For this red hot second, you can use the gotrue cli for that. It's not documented, but the code makes a good reference: https://github.com/netlify/gotrue/blob/master/cmd/admin_cmd.go
Namely the createuser command looks to be the ticket. With this route you can at least get something going and then figure out live sign ups through the CMS itself if needed.
@romdim Did you manage to get this working?
Nope, got caught up with other stuff and stopped trying
I wrote down my experiences:
https://github.com/hfte/netlify-cms-with-selfhosted-gotrue-and-git-gateway
@hfte awesome!!! We'll probably link to that elsewhere as well - thank you for writing it up!
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.
If someone is trying to set custom identity_url but Netlify CMS stills trying to fetch default {hostname}/.netlify/identity and getting 404, I've fixed with following hack:
const initCms = config => {
const identityUrl = config.backend.identity_url
if (identityUrl && window.netlifyIdentity) {
const fixGotrueApi = () => {
const { api } = window.netlifyIdentity.gotrue
api.apiURL = identityUrl
api._sameOrigin = identityUrl.includes(window.location.host)
}
if (document.readyState !== 'loading') {
fixGotrueApi()
}
document.addEventListener('DOMContentLoaded', fixGotrueApi)
}
window.CMS.init({ config })
}
Ref.: https://stackoverflow.com/questions/52174873/using-netlifys-hosted-identity-service-with-self-hosted-netlify-cms (solution purposed here doesn't work to me because it creates multiple identity iframes and I think there was a problem with overlaps, but was a good starting point :smile: )
Imo it should work just with config fields, not? It's a bug?
Closing as I believe enough information has been provided.
Imo it should work just with config fields, not? It's a bug?
True, see https://github.com/netlify/netlify-cms/issues/3995#issuecomment-655966399
Most helpful comment
I wrote down my experiences:
https://github.com/hfte/netlify-cms-with-selfhosted-gotrue-and-git-gateway