Procedure for installing Netlify CMS. I'm assuming all files are current with this forked repo.
To allow people to log into the new CMS with their GitHub accounts, we need to facilitate OAuth transactions. We can do this with a group of Azure App Functions I built for this purpose.
-
Fetch that repo and deploy to Azure as a Function App.
-
After deployment to Azure, take note of the Function App's root URL. We'll be using this.
In the repo for the site, we need to point the CMS to these Azure functions.
-
Open this file: src/cms/config.yml
-
Put your Azure Function App's root URL (from step #2) into the
backend/base_url
field.
-
If needed, change
auth_endpoint
to match how your Azure Function App routes, if different. -
Deploy these changes to the site.
On the GitHub side, we need to set up an OAuth app to allow logins from the CMS.
-
Check out instructions for creating an OAuth app. It's not too complicated.
-
You'll need to enter some values when you get to the "Register a new OAuth application" page.
- Application Name is what internal authors/editors will see when they log in for the first time and accept access. It should look official:
news.alpha.ca.gov Content Management
or something similar. - Homepage url should be
https://news.alpha.ca.gov/cms
. - Application Description can be whatever you want.
- Authorization callback URL is the URL to the Callback function in the Azure Function App.
Example: https://fa-go-alph-blg-001.azurewebsites.net/api/callback
- Do it! When your GitHub OAuth app is created, take note of the Client ID. You'll also need to generate a Client secret. We'll need these two values next.
We need to configure some environment variables in Azure to get our OAuth functions working.
-
Go to the dashboard for our new Azure Function App, as deployed in steps #1 and #2.
-
Click into the Settings/Configuration area.
-
We're going to enter some new Application settings. Save when done.
- Set
REDIRECT_URL
to the same value we entered for the Authorization callback URL on the GitHub OAuth app.
Example: https://fa-go-alph-blg-001.azurewebsites.net/api/callback
- Set
OAUTH_CLIENT_ID
andOAUTH_CLIENT_SECRET
with correponding values from the GitHub OAuth App.
More securely storing the OAUTH_CLIENT_SECRET is left as an exercise for the reader, and probably differs depending upon standards at CDT.
- Go to
https://news.alpha.ca.gov/cms
.
- Editing articles should be done on the live site. When you want to do development on the CMS itself, such as create new content widgets, run the following command (from the site's directory) in a terminal.
npx netlify-cms-proxy-server
(This requires the netlify-cms-proxy-server
from npm.)
Then run the usual serve
command in another terminal at the same time.
npm run serve
Any articles you "publish" with the proxy active will commit to the local git repo, rather than going to GitHub. You could still later push those local commits live if you want.