Encrypt Hugo Site using Staticrypt

Hi,
I am working on a project for a client, and they would like me to password protect their site (that I am going to build). I was planning on just using the hugo command and encrypting the html files using Staticrypt (link here). Is there anyway to use a CMS like Netlify CMS, and have it automatically encrypt the html? I am planning on using Netlify, but have not chosen a theme yet. Any information would be greatly appreciated.
Thanks,
Eli

Netlify has the option to password protect iirc. If not them, then simple web server http auth is fine too. Those are different from encryption though.

@RickCogley
Is there anyway to have it automatically run Staticrypt when they make a change on Netlify CMS?

Looks like it, but it’s a question best asked to netlify. https://www.netlify.com/docs/build-settings/

Assuming:

  • You have npm setup and the staticrypt package installed
  • You have a netlify.toml file

Then you could make your netlify build command something like:

hugo && npm install && find . -type f -name "*.html" -exec staticrypt {} mypassword \;

Have you considered Amazon S3 / Cognito / CloudFront?

S3 is encrypted and meets all the compliance like PCI-DSS and HIPPA and has many other advantages.

Right, but S3 still wouldn’t allow me to use a CMS, correct?

Yes it would.

CMS or CDN? :wink:

But on the S3 note, I agree that this is an option. Whatever CMS you use just edits your files stored in GitHub. You can then deploy your site wherever you please.

Do you have to encrypt your site? How about Basic auth?

Password Protection

This feature may not be available on all plans.

Netlify password protection is not a free feature. I recommend you AWS Amplify Console with a small fee. (Password protection, Basic Authentication)

Does AWS Amplify allow me to use Netlify CMS, and does it come with a CDN? Also, is Staticrypt less secure then using AWS Amplifys login page?

CMS

Does AWS Amplify allow me to use Netlify CMS, and does it come with a CDN?

I have no idea to use Netlify CMS on AWS Amplify Console, but you might be able to use forestry as a CMS.

CDN

Please read AWS Amplify Console about CDN.

Globally available

Your app is served via Amazon’s reliable content delivery network with hundreds of points of presence globally.

Security

The following image is the “Access control” page of my project on AWS Amplify Console. We can set ID and Password each branch. On the other hand, Staticrypt can set only Password. I can not say if Amplify Console is safer than Staticrypt, but I think it is easier to control.

1 Like

When I use it, I get an error that netlify.toml file is invalid. Here is a link to deploy logs:https://app.netlify.com/sites/leahsitedemo/deploys/5d04f95c64ce7261587d6b77.

That link is private.

8:57:48 AM: Build ready to start 8:57:51 AM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63 8:57:51 AM: build-image tag: v3.3.2 8:57:51 AM: buildbot version: 75cd99f62ada9e21edea53208e8baf0eab85a045 8:57:51 AM: Fetching cached dependencies 8:57:51 AM: Starting to download cache of 255.0KB 8:57:51 AM: Finished downloading cache in 88.799673ms 8:57:51 AM: Starting to extract cache 8:57:51 AM: Failed to fetch cache, continuing with build 8:57:51 AM: Starting to prepare the repo for build 8:57:51 AM: No cached dependencies found. Cloning fresh repo 8:57:51 AM: git clone https://github.com/edcous/leahdemo 8:57:52 AM: Preparing Git Reference refs/heads/master 8:57:53 AM: Invalid netlify.toml file: Error while decoding file /opt/build/repo/netlify.toml: Near line 3 (last key parsed 'build'): expected a top-level item to end with a newline, comment, or EOF, but got '*' instead 8:57:53 AM: Failing build: Failed to build site 8:57:53 AM: failed during stage 'building site': Error while decoding file /opt/build/repo/netlify.toml: Near line 3 (last key parsed 'build'): expected a top-level item to end with a newline, comment, or EOF, but got '*' instead 8:57:53 AM: Finished processing build request in 2.314855824s 8:57:53 AM: Shutting down logging, 0 messages pending

Also, a link to my repo: https://github.com/edcous/leahdemo

Try escaping the quotes:

command = "hugo && npm install && find . -type f -name \"*.html\" -exec staticrypt {} mypassword \;"

Your command worked (but I had to change the end). I know I’m missing something simple, but now I’m getting this error:
5:38:51 PM: Build ready to start
5:38:56 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
5:38:56 PM: build-image tag: v3.3.2
5:38:56 PM: buildbot version: 75cd99f62ada9e21edea53208e8baf0eab85a045
5:38:56 PM: Fetching cached dependencies
5:38:57 PM: Failed to fetch cache, continuing with build
5:38:57 PM: Starting to prepare the repo for build
5:38:57 PM: No cached dependencies found. Cloning fresh repo
5:38:57 PM: git clone https://github.com/edcous/leahdemo
5:38:58 PM: Preparing Git Reference refs/heads/master
5:38:58 PM: Found netlify.toml. Overriding site configuration
5:38:58 PM: Different build command detected, going to use the one specified in the toml file: 'hugo && npm install && find . -type f -name “.html" -exec staticrypt {} mypassword ’ versus ‘hugo’ in the site
5:38:58 PM: Starting build script
5:38:58 PM: Installing dependencies
5:39:00 PM: Downloading and installing node v10.16.0…
5:39:00 PM: Downloading https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz
5:39:00 PM:
########################
5:39:00 PM: 34.0%
5:39:00 PM:
#########################################################
5:39:00 PM: ############### 100.0%
5:39:00 PM: Computing checksum with sha256sum
5:39:00 PM: Checksums matched!
5:39:03 PM: Now using node v10.16.0 (npm v6.9.0)
5:39:03 PM: Attempting ruby version 2.6.2, read from environment
5:39:04 PM: Using ruby version 2.6.2
5:39:05 PM: Using PHP version 5.6
5:39:05 PM: Installing Hugo 0.55.6
5:39:06 PM: Hugo Static Site Generator v0.55.6-A5D4C82D2/extended linux/amd64 BuildDate: 2019-05-18T08:08:34Z
5:39:06 PM: Started restoring cached go cache
5:39:06 PM: Finished restoring cached go cache
5:39:06 PM: unset GOOS;
5:39:06 PM: unset GOARCH;
5:39:06 PM: export GOROOT=’/opt/buildhome/.gimme/versions/go1.12.linux.amd64’;
5:39:06 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
5:39:06 PM: go version >&2;
5:39:06 PM: export GIMME_ENV=’/opt/buildhome/.gimme/env/go1.12.linux.amd64.env’;
5:39:06 PM: go version go1.12 linux/amd64
5:39:06 PM: Installing missing commands
5:39:06 PM: Verify run directory
5:39:06 PM: Executing user command: hugo && npm install && find . -type f -name "
.html” -exec staticrypt {} mypassword
5:39:06 PM: Error: Unable to find theme Directory: /opt/build/repo/themes/repo
5:39:06 PM: Skipping functions preparation step: no functions directory set
5:39:06 PM: Caching artifacts
5:39:06 PM: Started saving node modules
5:39:06 PM: Finished saving node modules
5:39:06 PM: Started saving pip cache
5:39:06 PM: Finished saving pip cache
5:39:06 PM: Started saving emacs cask dependencies
5:39:06 PM: Finished saving emacs cask dependencies
5:39:06 PM: Started saving maven dependencies
5:39:06 PM: Finished saving maven dependencies
5:39:06 PM: Started saving boot dependencies
5:39:06 PM: Finished saving boot dependencies
5:39:06 PM: Started saving go dependencies
5:39:06 PM: Finished saving go dependencies
5:39:08 PM: Error running command: Build script returned non-zero exit code: 255
5:39:08 PM: Failing build: Failed to build site
5:39:09 PM: failed during stage ‘building site’: Build script returned non-zero exit code: 255
5:39:09 PM: Finished processing build request in 12.411985026s
5:39:09 PM: Shutting down logging, 0 messages pending
And here is my config file:
baseURL = “https://leahdemosite.netlify.com
languageCode = “en-us”
title = “Demo Sites”
themesDir = “themes”
theme = “hugo-hero-theme”
[params]
google_analytics_id=""

[params.homepage_meta_tags]
meta_description = “”
meta_og_title = “Demo Sites”
meta_og_type = “website”
meta_og_url = “https://leahdemosite.netlify.com
meta_og_image = “”
meta_og_description = “”

[[menu.main]]
name = “RSVP”
url = “/rsvp/”
weight = 1

[[menu.main]]
name = “About”
url = “/about/”
weight = 3

[[menu.main]]
name = “Contact”
url = “/contact/”
weight = 4

[permalinks]
post = “/:year/:month/:day/:slug/”
pages = “/:filename/”

Here’s your issue:

5:39:06 PM: Error: Unable to find theme Directory: /opt/build/repo/themes/repo

That could mean a few different things. So, how is your theme currently setup? (1) git clone, (2) git submodule, or (3) download of a zip?

I think I downloaded the zip, but I’m not 100 percent sure.