Skip to content

Commit 8b28e0c

Browse files
committed
feat: extract tags from tailscale node
1 parent 8fad270 commit 8b28e0c

5 files changed

Lines changed: 6 additions & 2 deletions

File tree

air.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ root = "/tinyauth"
22
tmp_dir = "tmp"
33

44
[build]
5-
pre_cmd = ["mkdir -p internal/assets/dist", "mkdir -p /data"] # "echo 'backend running' > internal/assets/dist/index.html"
5+
pre_cmd = ["mkdir -p internal/assets/dist", "mkdir -p /data", "echo 'backend running' > internal/assets/dist/index.html"]
66
cmd = "CGO_ENABLED=0 go build -gcflags=\"all=-N -l\" -o tmp/tinyauth ./cmd/tinyauth"
77
bin = "tmp/tinyauth"
88
full_bin = "dlv --listen :4000 --headless=true --api-version=2 --accept-multiclient --log=true exec tmp/tinyauth --continue --check-go-version=false"

internal/middleware/context_middleware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ func (m *ContextMiddleware) cookieAuth(ctx context.Context, uuid string, ip stri
160160
if userContext.Local.Attributes.Email == "" {
161161
userContext.Local.Attributes.Email = utils.CompileUserEmail(user.Username, m.runtime.CookieDomain)
162162
}
163-
// Ensures that the seesion is still coming from Tailscale
164163
case model.ProviderTailscale:
165164
tailscaleContext, err := m.tailscaleWhois(ctx, ip)
166165

@@ -313,6 +312,7 @@ func (m *ContextMiddleware) tailscaleWhois(ctx context.Context, ip string) (*mod
313312
Name: whois.DisplayName,
314313
},
315314
UserID: whois.UserID,
315+
Tags: whois.Tags,
316316
}
317317

318318
if !strings.ContainsAny(uctx.Email, "@") {

internal/model/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ type TailscaleWhoisResponse struct {
241241
LoginName string
242242
DisplayName string
243243
NodeName string
244+
Tags []string
244245
}
245246

246247
type Apps struct {

internal/model/context.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ type LDAPContext struct {
5959
type TailscaleContext struct {
6060
BaseContext
6161
UserID string
62+
// for future use
63+
Tags []string
6264
}
6365

6466
func (c *UserContext) IsAuthenticated() bool {

internal/service/tailscale_service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func (ts *TailscaleService) Whois(ctx context.Context, addr string) (*model.Tail
100100
LoginName: who.UserProfile.LoginName,
101101
DisplayName: who.UserProfile.DisplayName,
102102
NodeName: strings.TrimSuffix(who.Node.Name, "."),
103+
Tags: who.Node.Tags,
103104
}
104105

105106
return &res, nil

0 commit comments

Comments
 (0)