Skip to content

Commit 940ba6d

Browse files
committed
fix: don't allow tagged devices in tailscale integration
1 parent faee58c commit 940ba6d

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

internal/middleware/context_middleware.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,6 @@ func (m *ContextMiddleware) tailscaleWhois(ctx context.Context, ip string) (*mod
326326
Name: whois.DisplayName,
327327
},
328328
UserID: whois.UserID,
329-
Tags: whois.Tags,
330-
}
331-
332-
if !strings.ContainsAny(uctx.Email, "@") {
333-
uctx.Email = utils.CompileUserEmail(uctx.Email+"-tailscale", m.runtime.CookieDomain)
334329
}
335330

336331
return &uctx, nil

internal/model/context.go

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

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

internal/service/tailscale_service.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ type TailscaleWhoisResponse struct {
2121
LoginName string
2222
DisplayName string
2323
NodeName string
24-
Tags []string
2524
}
2625

2726
type TailscaleService struct {
@@ -115,14 +114,22 @@ func (ts *TailscaleService) Whois(ctx context.Context, addr string) (*TailscaleW
115114
return nil, fmt.Errorf("failed to get client whois: %w", err)
116115
}
117116

117+
if who.Node.IsTagged() {
118+
ts.log.App.Debug().Msgf("Skipping whois for tagged node %s", who.Node.Name)
119+
return nil, nil
120+
}
121+
122+
uid := strings.TrimPrefix(who.UserProfile.ID.String(), "userid:")
123+
118124
res := TailscaleWhoisResponse{
119-
UserID: who.UserProfile.ID.String(),
125+
UserID: uid,
120126
LoginName: who.UserProfile.LoginName,
121127
DisplayName: who.UserProfile.DisplayName,
122128
NodeName: strings.TrimSuffix(who.Node.Name, "."),
123-
Tags: who.Node.Tags,
124129
}
125130

131+
ts.log.App.Debug().Interface("res", res).Msg("tailscale")
132+
126133
return &res, nil
127134
}
128135

0 commit comments

Comments
 (0)