2025-03-09 5:10PM
I’m revamping this template. One new feature that I thought would set it apart was an integration with a git1-based content management system (AKA – a “CMS”).
In the past, I’ve used Netlify CMS, which recently has been rebranded to “Decap CMS.” A rose by any other name still posts as sweet. It was pretty nifty before, so I decided to re-use it again.
Setting up this CMS so far has been a piece of cake. It seems to integrate really well into pandoc’s default HTML5 template, which are configurable by embedded YAML blocks. It turns out I can easily set “Decap collections” to write to these metadata blocks, and thus make it really easy to add and edit webpages! (Well, I haven’t gotten this working all the way, but that’s the hope.) The current missing piece for me is to get authentication set up, which requires some webservice (i.e. a tiny dynamic component of this otherwise static website).
Getting authentication and authorization is a serious matter. I want to make sure that only the people I allow to can edit this website (“authorization”). To that end, I need to make sure that the person with access is really who they say they are (“authentication”). I wouldn’t want an adversary to be able to edit or delete a webpage that was valuable to me.
Luckily, I don’t have to write a significant amount of code to accomplish this, thanks to the OAuth standard. To get up-and-running fast, I’ve decided to use GitHub – who hosts this website and manages its source code – to be my OAuth provider.
Here’s what I did — and you can, too — to get auth set up.
Pre-requisites: You need to have domain names managed in Cloudflare. This requires setting up an account and either purchasing or transferring domains over there. This is beyond the scope of this post.
npm
in a while, so I had to update
to the latest long-time-support version via nvm
. If these
are strange acronyms to you, but you want to follow along and are
willing to copy & paste stuff into your computer’s terminal
(it’s generally not recommended to run code you read about on the
internet! Viewer discretion is advised!), first you need to
download Node.JS: nodejs.org/en/download/.
After you have node set up locally (“Node” is just “Javascript” that
runs outside your web browser), you can follow the Decap proxy
instructions to call the Cloudflare function-as-a-service command-line
tool, known as “wrangler.” When you run npx wranger login
,
it tells your local terminal (and computer) to log into Cloudflare. When
you run npx wrangler deploy
inside of the root directory of
the source code you downloaded in step (1), it will deploy that code
(with the proper configuration) to Cloudflare.config.yml
file in the admin/
directory of this template to use “https://auth.merose.com” as a
base_url
for the Decap
backend.And that is it! From here, I plan to contribute this feature to my template. As of writing I’m not sure if this works, but my hope is that with a little tweaking, the next post of this blog will be written from the web!
git is a piece of software to manage versions of documents or code in a decentralized manner.↩︎