diff --git a/caddy/README.md b/caddy/README.md index 5ea63de..1c95f9d 100644 --- a/caddy/README.md +++ b/caddy/README.md @@ -6,6 +6,8 @@ This middleware is designed to play together with the [caddy-jwt](https://github For a full documentation of loginsrv configuration and usage, visit the [loginsrv README.md](https://github.com/tarent/loginsrv). +A small demo can also be found in the [./demo](https://github.com/tarent/loginsrv/tree/master/caddy/demo) directory. + ## Configuration To be compatible with caddy-jwt, the jwt secret is taken from the enviroment variable `JWT_SECRET` if such a variable is set. Otherwise, a random token is generated and set as enviroment variable JWT_SECRET, diff --git a/caddy/demo/Caddyfile b/caddy/demo/Caddyfile new file mode 100644 index 0000000..18abd50 --- /dev/null +++ b/caddy/demo/Caddyfile @@ -0,0 +1,20 @@ + +http://localhost:8080 { + + log stdout + root {$PWD}/webroot + ext .html + header /private Cache-Control "no-cache, no-store, must-revalidate" + + jwt { + path /private + redirect /login + allow sub demo + } + + login { + success_url /private + htpasswd file=passwords + } + +} diff --git a/caddy/demo/README.md b/caddy/demo/README.md new file mode 100644 index 0000000..31b637a --- /dev/null +++ b/caddy/demo/README.md @@ -0,0 +1,10 @@ +# Caddy login demo + +This directory contains a small demo on how to secure a +directory or file by loginsrv and caddy. + +Please start it from this directory with + +` +go run main.go +` diff --git a/caddy/demo/main.go b/caddy/demo/main.go new file mode 100644 index 0000000..63d334f --- /dev/null +++ b/caddy/demo/main.go @@ -0,0 +1,11 @@ +package main + +import ( + _ "github.com/BTBurke/caddy-jwt" + "github.com/mholt/caddy/caddy/caddymain" + _ "github.com/tarent/loginsrv/caddy" +) + +func main() { + caddymain.Run() +} diff --git a/caddy/demo/passwords b/caddy/demo/passwords new file mode 100644 index 0000000..f9c20a7 --- /dev/null +++ b/caddy/demo/passwords @@ -0,0 +1 @@ +demo:$2y$10$B/lwbuYGkYDe6wYE4LpuE.DlFFEnM7mK4V7jXDTGJUVEtGZ2P63DK diff --git a/caddy/demo/webroot/index.html b/caddy/demo/webroot/index.html new file mode 100644 index 0000000..174ae33 --- /dev/null +++ b/caddy/demo/webroot/index.html @@ -0,0 +1,34 @@ + + +
+ + +Please Logout
+