mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-05-12 07:18:11 +00:00
feat: extract tags from tailscale node
This commit is contained in:
@@ -160,7 +160,6 @@ func (m *ContextMiddleware) cookieAuth(ctx context.Context, uuid string, ip stri
|
||||
if userContext.Local.Attributes.Email == "" {
|
||||
userContext.Local.Attributes.Email = utils.CompileUserEmail(user.Username, m.runtime.CookieDomain)
|
||||
}
|
||||
// Ensures that the seesion is still coming from Tailscale
|
||||
case model.ProviderTailscale:
|
||||
tailscaleContext, err := m.tailscaleWhois(ctx, ip)
|
||||
|
||||
@@ -313,6 +312,7 @@ func (m *ContextMiddleware) tailscaleWhois(ctx context.Context, ip string) (*mod
|
||||
Name: whois.DisplayName,
|
||||
},
|
||||
UserID: whois.UserID,
|
||||
Tags: whois.Tags,
|
||||
}
|
||||
|
||||
if !strings.ContainsAny(uctx.Email, "@") {
|
||||
|
||||
@@ -241,6 +241,7 @@ type TailscaleWhoisResponse struct {
|
||||
LoginName string
|
||||
DisplayName string
|
||||
NodeName string
|
||||
Tags []string
|
||||
}
|
||||
|
||||
type Apps struct {
|
||||
|
||||
@@ -59,6 +59,8 @@ type LDAPContext struct {
|
||||
type TailscaleContext struct {
|
||||
BaseContext
|
||||
UserID string
|
||||
// for future use
|
||||
Tags []string
|
||||
}
|
||||
|
||||
func (c *UserContext) IsAuthenticated() bool {
|
||||
|
||||
@@ -100,6 +100,7 @@ func (ts *TailscaleService) Whois(ctx context.Context, addr string) (*model.Tail
|
||||
LoginName: who.UserProfile.LoginName,
|
||||
DisplayName: who.UserProfile.DisplayName,
|
||||
NodeName: strings.TrimSuffix(who.Node.Name, "."),
|
||||
Tags: who.Node.Tags,
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
|
||||
Reference in New Issue
Block a user