-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (34 loc) · 878 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"os"
cli "github.com/jawher/mow.cli"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
var (
e = echo.New()
app = cli.App("pamauthd", "Web Authentication with pam.d backend")
)
func main() {
app.Command("serve", "start http server", cmdServe)
app.Run(os.Args)
}
func cmdServe(cmd *cli.Cmd) {
var (
addr = cmd.StringOpt("addr", ":8080", "bind address")
minUID = cmd.IntOpt("minUID", 1000, "skips users below UID limit")
minGID = cmd.IntOpt("minGID", 1000, "skips users below GID limit")
exclude = cmd.StringsOpt("exculeUsers", []string{"root"}, "exclude usernames")
)
cmd.Action = func() {
e.Use(middleware.Recover())
e.Use(middleware.Logger())
e.Use(AuthMiddlewareWithConfig(
PAMAuthConfig{
*minUID, *minGID, *exclude,
},
))
e.Any("*", AnyAuth)
e.Logger.Info(e.Start(*addr))
}
}