diff --git a/air.toml b/air.toml index d1ed6df9..5de0449c 100644 --- a/air.toml +++ b/air.toml @@ -2,7 +2,7 @@ root = "/tinyauth" tmp_dir = "tmp" [build] -pre_cmd = ["mkdir -p internal/assets/dist", "mkdir -p /data"] # "echo 'backend running' > internal/assets/dist/index.html" +pre_cmd = ["mkdir -p internal/assets/dist", "mkdir -p /data", "echo 'backend running' > internal/assets/dist/index.html"] cmd = "CGO_ENABLED=0 go build -gcflags=\"all=-N -l\" -o tmp/tinyauth ./cmd/tinyauth" bin = "tmp/tinyauth" full_bin = "dlv --listen :4000 --headless=true --api-version=2 --accept-multiclient --log=true exec tmp/tinyauth --continue --check-go-version=false" diff --git a/internal/middleware/context_middleware.go b/internal/middleware/context_middleware.go index 174324ee..f8f9ca8e 100644 --- a/internal/middleware/context_middleware.go +++ b/internal/middleware/context_middleware.go @@ -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, "@") { diff --git a/internal/model/config.go b/internal/model/config.go index 2804b17a..96895196 100644 --- a/internal/model/config.go +++ b/internal/model/config.go @@ -241,6 +241,7 @@ type TailscaleWhoisResponse struct { LoginName string DisplayName string NodeName string + Tags []string } type Apps struct { diff --git a/internal/model/context.go b/internal/model/context.go index b0808568..d85aced6 100644 --- a/internal/model/context.go +++ b/internal/model/context.go @@ -59,6 +59,8 @@ type LDAPContext struct { type TailscaleContext struct { BaseContext UserID string + // for future use + Tags []string } func (c *UserContext) IsAuthenticated() bool { diff --git a/internal/service/tailscale_service.go b/internal/service/tailscale_service.go index 92b56012..57244d0a 100644 --- a/internal/service/tailscale_service.go +++ b/internal/service/tailscale_service.go @@ -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