loginsrv

Unnamed repository; edit this file 'description' to name the repository.
git clone git@jamesshield.xyz:repos/loginsrv.git
Log | Files | Refs | README | LICENSE

commit 50e4a46394c122ca03ad5a8e2cc600c738628131
parent 31671ca4572bd30099c0139c059040d98e518ed5
Author: Sebastian Mancke <s.mancke@tarent.de>
Date:   Fri,  5 May 2017 19:59:28 +0200

added caddy configuration demo

Diffstat:
Mcaddy/README.md | 2++
Acaddy/demo/Caddyfile | 20++++++++++++++++++++
Acaddy/demo/README.md | 10++++++++++
Acaddy/demo/main.go | 11+++++++++++
Acaddy/demo/passwords | 1+
Acaddy/demo/webroot/index.html | 34++++++++++++++++++++++++++++++++++
Acaddy/demo/webroot/private.html | 35+++++++++++++++++++++++++++++++++++
7 files changed, 113 insertions(+), 0 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 @@ -0,0 +1 @@ +demo:$2y$10$B/lwbuYGkYDe6wYE4LpuE.DlFFEnM7mK4V7jXDTGJUVEtGZ2P63DK diff --git a/caddy/demo/webroot/index.html b/caddy/demo/webroot/index.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Caddy-login Demo Application</title> + + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> + </head> + <body> + <!-- Static navbar --> + <nav class="navbar navbar-default navbar-static-top"> + <div class="container"> + <div id="navbar" class="navbar-collapse"> + <ul class="nav navbar-nav"> + <li class="active"><a href="/">Start</a></li> + <li><a href="/private">Private</a></li> + </ul> + <ul class="nav navbar-nav navbar-right"> + <li><a href="/login">Login</a></li> + </ul> + </div> + </div> + </nav> + + <div class="container"> + <div class="jumbotron"> + <h3>Caddy Login Demo Application</h3> + Please <a href="/login">login</a> with <code>demo/demo</code>. + </div> + </div> + + </body> +</html> diff --git a/caddy/demo/webroot/private.html b/caddy/demo/webroot/private.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Caddy-login Demo Application</title> + + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> + </head> + <body> + <!-- Static navbar --> + <nav class="navbar navbar-default navbar-static-top"> + <div class="container"> + <div id="navbar" class="navbar-collapse"> + <ul class="nav navbar-nav"> + <li><a href="/">Start</a></li> + <li class="active"><a href="/private">Private</a></li> + </ul> + <ul class="nav navbar-nav navbar-right"> + <li><a href="/login">Login</a></li> + </ul> + </div> + </div> + </nav> + + <div class="container"> + <div class="jumbotron"> + <h1>This is a private Site</h1> + You should only be able to see this, when logged in. + <p>Please <a href="/login?logout=true">Logout</a></p> + </div> + </div> + + </body> +</html>