Alter 5 files
Delete `module.go` Add `caddyfile.go` Update `go.mod` Update `go.sum` Add `tailscaleAuth.go`
This commit is contained in:
parent
37075cbeb9
commit
828abff8d2
5 changed files with 227 additions and 82 deletions
28
caddyfile.go
Normal file
28
caddyfile.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package caddy_tailscale
|
||||
|
||||
import (
|
||||
"github.com/caddyserver/caddy/v2"
|
||||
"github.com/caddyserver/caddy/v2/caddyconfig"
|
||||
"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
|
||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp/caddyauth"
|
||||
)
|
||||
|
||||
func init() {
|
||||
httpcaddyfile.RegisterHandlerDirective("tailscale_auth", parseCaddyfile)
|
||||
}
|
||||
|
||||
// parseCaddyfile sets up the handler from Caddyfile tokens. Syntax:
|
||||
//
|
||||
// tailscale_auth
|
||||
//
|
||||
// See also for further examples: https://github.com/caddyserver/caddy/blob/master/modules/caddyhttp/caddyauth/caddyfile.go
|
||||
func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
|
||||
h.Next() // consume directive name
|
||||
ta := new(TailscaleAuth)
|
||||
return caddyauth.Authentication{
|
||||
ProvidersRaw: caddy.ModuleMap{
|
||||
"tailscale": caddyconfig.JSON(ta, nil),
|
||||
},
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue