mirror of
https://github.com/wahyd4/loginsrv.git
synced 2026-08-09 04:46:29 +10:00
added caddy configuration demo
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
`
|
||||
@@ -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()
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
demo:$2y$10$B/lwbuYGkYDe6wYE4LpuE.DlFFEnM7mK4V7jXDTGJUVEtGZ2P63DK
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user