Skip to content

Commit c2ec606

Browse files
author
Christine Dodrill
committed
Add caddyfile parsing for allowing tagged nodes
Signed-off-by: Christine Dodrill <[email protected]>
1 parent a98aa89 commit c2ec606

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

module.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tscaddy
22

33
import (
4+
"fmt"
45
"log"
56
"net"
67
"net/http"
@@ -89,6 +90,8 @@ func getListener(_, addr string) (net.Listener, error) {
8990

9091
type TailscaleAuth struct {
9192
localclient *tailscale.LocalClient
93+
94+
AllowTaggedNodes bool `json:"allow_tagged_nodes"`
9295
}
9396

9497
func (TailscaleAuth) CaddyModule() caddy.ModuleInfo {
@@ -144,9 +147,11 @@ func (ta TailscaleAuth) Authenticate(w http.ResponseWriter, r *http.Request) (ca
144147
return user, false, err
145148
}
146149

147-
if len(info.Node.Tags) != 0 {
150+
if ta.AllowTaggedNodes && len(info.Node.Tags) != 0 {
148151
info.UserProfile.LoginName = strings.Replace(info.Node.Tags[0], ":", "___", -1) + "@tags.in.your.tailnet"
149152
info.UserProfile.DisplayName = "A tagged node with tags: " + strings.Join(info.Node.Tags, ", ")
153+
} else {
154+
return user, false, fmt.Errorf("node %s has tags", info.Node.Hostinfo.Hostname())
150155
}
151156

152157
var tailnet string

0 commit comments

Comments
 (0)