Skip to content

garrison/cloudflare-pages-shared-password

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloudflare-pages-shared-password

This repository demonstrates a static site which is hosted on Cloudflare Pages and whose content is "protected" by a shared username/password with HTTP basic access authentication. The real magic is in functions/_middleware.ts, which is based on the Cloudflare Workers example for HTTP basic authentication, repurposed as a middleware to be used with the Functions feature of Cloudflare Pages.

This demonstration site is hosted at https://cloudflare-pages-shared-password.pages.dev/, with admin as both the username and password.

The static site in this repository is built using Hugo, but the middleware can be used with any static site hosted on Cloudflare Pages.

[Non]-Security

I make no guarantees about the security of this code. In particular, a shared password, stored in a repository, should not be expected to provide a meaningful degree of security.

Acknowledgments

Special thanks to CherryJimbo and Isaac McFadyen for responding to my questions on the Cloudflare Discord instance. Their suggestions were essential in getting the first version of this code to work.

About

Demonstration of a static site hosted on Cloudflare Pages with HTTP basic authentication

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published