tailcfg,ipn/ipnlocal: report authenticated funnel posture to control

Add Hostinfo.FunnelAuthEnabled so a node reports whether any of its
funnel-enabled endpoints require visitors to authenticate with Login With
Tailscale. Control (corp) reads this to show each funnel's posture
(authenticated vs. public) in the admin console; it is the only node→control
addition for authenticated Funnel, and it rides the existing Hostinfo
channel next to IngressEnabled.

The node computes it from the serve config (ServeConfig.HasFunnelAuth: any
funnel-on web handler with Auth set, including foreground sessions) and
sends it from maybeUpdateHostinfoFunnelLocked alongside IngressEnabled.
Bump CurrentCapabilityVersion to 144 to mark that clients send this field.

Updates tailscale/corp#38806

Change-Id: I86c5f04dd3beb71bef7cfe41fb6ef85728d364b6
Signed-off-by: Kabir Sikand <[email protected]>
This commit is contained in:
Kabir Sikand committed 2026-07-27 19:48:16 +00:00
1 parent 7a7fa2c230
commit 732f32dad4
9 files changed
+238 -87

No files matched your search

+22
View File
@@ -7782,6 +7782,7 @@ func TestUpdateIngressAndServiceHashLocked(t *testing.T) {
sc *ipn.ServeConfig
wantIngress bool
wantWireIngress bool
wantFunnelAuth bool
wantControlUpdate bool
}{
{
@@ -7804,6 +7805,24 @@ func TestUpdateIngressAndServiceHashLocked(t *testing.T) {
wantWireIngress: false, // implied by wantIngress
wantControlUpdate: true,
},
{
name: "empty_hostinfo_funnel_auth_enabled",
hi: &tailcfg.Hostinfo{},
sc: &ipn.ServeConfig{
AllowFunnel: map[ipn.HostPort]bool{
"tailnet.xyz:443": true,
},
Web: map[ipn.HostPort]*ipn.WebServerConfig{
"tailnet.xyz:443": {Handlers: map[string]*ipn.HTTPHandler{
"/": {Proxy: "http://127.0.0.1:3000", Auth: &ipn.FunnelAuth{Provider: "tailscale"}},
}},
},
},
wantIngress: true,
wantWireIngress: false, // implied by wantIngress
wantFunnelAuth: true,
wantControlUpdate: true,
},
{
name: "empty_hostinfo_service_configured",
hi: &tailcfg.Hostinfo{},
@@ -7956,6 +7975,9 @@ func TestUpdateIngressAndServiceHashLocked(t *testing.T) {
if tt.hi.WireIngress != tt.wantWireIngress {
t.Errorf("WireIngress = %v, want %v", tt.hi.WireIngress, tt.wantWireIngress)
}
if tt.hi.FunnelAuthEnabled != tt.wantFunnelAuth {
t.Errorf("FunnelAuthEnabled = %v, want %v", tt.hi.FunnelAuthEnabled, tt.wantFunnelAuth)
}
b.mu.Lock()
svcHash := vipServiceHash(b.logf, b.vipServicesFromPrefsLocked(prefs))
b.mu.Unlock()
+16
View File
@@ -1631,6 +1631,14 @@ func (b *LocalBackend) hasIngressEnabledLocked() bool {
return b.serveConfig.Valid() && b.serveConfig.IsFunnelOn()
}
// hasFunnelAuthEnabledLocked reports whether any funnel-enabled endpoint
// requires authentication. This bool is sent to control (in
// Hostinfo.FunnelAuthEnabled) so the admin console can show each funnel's
// posture (authenticated vs. public).
func (b *LocalBackend) hasFunnelAuthEnabledLocked() bool {
return b.serveConfig.Valid() && b.serveConfig.HasFunnelAuth()
}
// shouldWireInactiveIngressLocked reports whether the node is in a state where funnel is not actively enabled, but it
// seems that it is intended to be used with funnel.
func (b *LocalBackend) shouldWireInactiveIngressLocked() bool {
@@ -1771,6 +1779,14 @@ func maybeUpdateHostinfoFunnelLocked(b *LocalBackend, hi *tailcfg.Hostinfo, pref
hi.IngressEnabled = ie
changed = true
}
// The Hostinfo.FunnelAuthEnabled field tells control whether any funnel
// endpoint requires authentication, so the admin console can show the
// funnel's posture (authenticated vs. public).
if fa := b.hasFunnelAuthEnabledLocked(); hi.FunnelAuthEnabled != fa {
b.logf("Hostinfo.FunnelAuthEnabled changed to %v", fa)
hi.FunnelAuthEnabled = fa
changed = true
}
// The Hostinfo.WireIngress field tells control whether the user intends
// to use funnel with this node even though it is not currently enabled.
// This is an optimization to control- Funnel requires creation of DNS
+1
View File
@@ -27,6 +27,7 @@ func (b *LocalBackend) DeleteForegroundSession(sessionID string) error {
type funnelFlow = struct{}
func (*LocalBackend) hasIngressEnabledLocked() bool { return false }
func (*LocalBackend) hasFunnelAuthEnabledLocked() bool { return false }
func (*LocalBackend) shouldWireInactiveIngressLocked() bool { return false }
func (*LocalBackend) HasFunnelForHostPort(host string, port uint16) bool {
return false
+34
View File
@@ -661,6 +661,40 @@ func (sc *ServeConfig) IsFunnelOn() bool {
return false
}
// HasFunnelAuth reports whether any funnel-enabled web handler on this node
// requires visitors to authenticate with Login With Tailscale (HTTPHandler.Auth
// is set). It is used to report the node's authenticated-Funnel posture to
// control (Hostinfo.FunnelAuthEnabled).
func (v ServeConfigView) HasFunnelAuth() bool { return v.ж.HasFunnelAuth() }
// HasFunnelAuth reports whether any funnel-enabled web handler requires
// authentication. See [ServeConfigView.HasFunnelAuth].
func (sc *ServeConfig) HasFunnelAuth() bool {
if sc == nil {
return false
}
for hp, on := range sc.AllowFunnel {
if !on {
continue
}
wsc, ok := sc.Web[hp]
if !ok {
continue
}
for _, h := range wsc.Handlers {
if h != nil && h.Auth != nil {
return true
}
}
}
for _, conf := range sc.Foreground {
if conf.HasFunnelAuth() {
return true
}
}
return false
}
// CheckFunnelAccess checks whether Funnel access is allowed for the given node
// and port.
// It checks:
+60
View File
@@ -66,6 +66,66 @@ func TestFunnelAuthJSONRoundTrip(t *testing.T) {
}
}
func TestHasFunnelAuth(t *testing.T) {
authed := func() *HTTPHandler {
return &HTTPHandler{Proxy: "http://127.0.0.1:3000", Auth: &FunnelAuth{Provider: "tailscale"}}
}
tests := []struct {
name string
sc *ServeConfig
want bool
}{
{name: "nil", sc: nil, want: false},
{name: "empty", sc: &ServeConfig{}, want: false},
{
name: "funnel on but no auth",
sc: &ServeConfig{
AllowFunnel: map[HostPort]bool{"h:443": true},
Web: map[HostPort]*WebServerConfig{"h:443": {Handlers: map[string]*HTTPHandler{"/": {Proxy: "http://127.0.0.1:3000"}}}},
},
want: false,
},
{
name: "auth but funnel off",
sc: &ServeConfig{
AllowFunnel: map[HostPort]bool{"h:443": false},
Web: map[HostPort]*WebServerConfig{"h:443": {Handlers: map[string]*HTTPHandler{"/": authed()}}},
},
want: false,
},
{
name: "auth and funnel on",
sc: &ServeConfig{
AllowFunnel: map[HostPort]bool{"h:443": true},
Web: map[HostPort]*WebServerConfig{"h:443": {Handlers: map[string]*HTTPHandler{"/": authed()}}},
},
want: true,
},
{
name: "auth in foreground config",
sc: &ServeConfig{
Foreground: map[string]*ServeConfig{
"sess": {
AllowFunnel: map[HostPort]bool{"h:443": true},
Web: map[HostPort]*WebServerConfig{"h:443": {Handlers: map[string]*HTTPHandler{"/": authed()}}},
},
},
},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.sc.HasFunnelAuth(); got != tt.want {
t.Errorf("HasFunnelAuth() = %v; want %v", got, tt.want)
}
if got := tt.sc.View().HasFunnelAuth(); got != tt.want {
t.Errorf("View().HasFunnelAuth() = %v; want %v", got, tt.want)
}
})
}
}
func TestCheckFunnelAccess(t *testing.T) {
caps := func(c ...tailcfg.NodeCapability) []tailcfg.NodeCapability { return c }
const portAttr tailcfg.NodeCapability = "https://tailscale.com/cap/funnel-ports?ports=443,8080-8090,8443,"
+9 -1
View File
@@ -190,7 +190,8 @@ type CapabilityVersion int
// - 141: 2026-05-28: Client understands [NodeAttrNeverGSOEqualTail]
// - 142: 2026-07-06: Client understands c2n /remoteapi/localapi/* proxy
// - 143: 2026-07-22: Client correctly ignores conn25 node attributes when not enabled by environment variable
const CurrentCapabilityVersion CapabilityVersion = 143
// - 144: 2026-07-27: Client sends Hostinfo.FunnelAuthEnabled to report authenticated Funnel posture (tailscale/corp#38806)
const CurrentCapabilityVersion CapabilityVersion = 144
// ID is an integer ID for a user, node, or login allocated by the
// control plane.
@@ -917,6 +918,13 @@ type Hostinfo struct {
WireIngress bool `json:",omitzero"`
IngressEnabled bool `json:",omitzero"` // if the node has any funnel endpoint enabled
// FunnelAuthEnabled reports whether the node has any Funnel endpoint that
// requires visitors to authenticate with Login With Tailscale
// (ipn.HTTPHandler.Auth). It is sent to control so the admin console can
// show each funnel's posture (authenticated vs. public). It is only
// meaningful when IngressEnabled is true.
FunnelAuthEnabled bool `json:",omitzero"`
// AllowsUpdate reports that the node has opted in to
// admin-console-driven remote updates and that the running binary
// includes client update support (the feature/clientupdate package,
+44 -43
View File
@@ -148,49 +148,50 @@ func (src *Hostinfo) Clone() *Hostinfo {
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _HostinfoCloneNeedsRegeneration = Hostinfo(struct {
IPNVersion string
FrontendLogID string
BackendLogID string
OS string
OSVersion string
Container opt.Bool
Env string
Distro string
DistroVersion string
DistroCodeName string
App string
Desktop opt.Bool
Package string
DeviceModel string
PushDeviceToken string
Hostname string
ShieldsUp bool
ShareeNode bool
NoLogsNoSupport bool
RemoteConfig bool
WireIngress bool
IngressEnabled bool
AllowsUpdate bool
Machine string
GoArch string
GoArchVar string
GoVersion string
RoutableIPs []netip.Prefix
RequestTags []string
WoLMACs []string
Services []Service
NetInfo *NetInfo
SSH_HostKeys []string
Cloud string
Userspace opt.Bool
UserspaceRouter opt.Bool
AppConnector opt.Bool
ServicesHash string
PeerRelay bool
ExitNodeID StableNodeID
Location *Location
TPM *TPMInfo
StateEncrypted opt.Bool
IPNVersion string
FrontendLogID string
BackendLogID string
OS string
OSVersion string
Container opt.Bool
Env string
Distro string
DistroVersion string
DistroCodeName string
App string
Desktop opt.Bool
Package string
DeviceModel string
PushDeviceToken string
Hostname string
ShieldsUp bool
ShareeNode bool
NoLogsNoSupport bool
RemoteConfig bool
WireIngress bool
IngressEnabled bool
FunnelAuthEnabled bool
AllowsUpdate bool
Machine string
GoArch string
GoArchVar string
GoVersion string
RoutableIPs []netip.Prefix
RequestTags []string
WoLMACs []string
Services []Service
NetInfo *NetInfo
SSH_HostKeys []string
Cloud string
Userspace opt.Bool
UserspaceRouter opt.Bool
AppConnector opt.Bool
ServicesHash string
PeerRelay bool
ExitNodeID StableNodeID
Location *Location
TPM *TPMInfo
StateEncrypted opt.Bool
}{})
// Clone makes a deep copy of NetInfo.
+1
View File
@@ -54,6 +54,7 @@ func TestHostinfoEqual(t *testing.T) {
"RemoteConfig",
"WireIngress",
"IngressEnabled",
"FunnelAuthEnabled",
"AllowsUpdate",
"Machine",
"GoArch",
+51 -43
View File
@@ -570,6 +570,13 @@ func (v HostinfoView) WireIngress() bool { return v.ж.WireIngress }
// if the node has any funnel endpoint enabled
func (v HostinfoView) IngressEnabled() bool { return v.ж.IngressEnabled }
// FunnelAuthEnabled reports whether the node has any Funnel endpoint that
// requires visitors to authenticate with Login With Tailscale
// (ipn.HTTPHandler.Auth). It is sent to control so the admin console can
// show each funnel's posture (authenticated vs. public). It is only
// meaningful when IngressEnabled is true.
func (v HostinfoView) FunnelAuthEnabled() bool { return v.ж.FunnelAuthEnabled }
// AllowsUpdate reports that the node has opted in to
// admin-console-driven remote updates and that the running binary
// includes client update support (the feature/clientupdate package,
@@ -641,49 +648,50 @@ func (v HostinfoView) Equal(v2 HostinfoView) bool { return v.ж.Equal(v2.ж) }
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _HostinfoViewNeedsRegeneration = Hostinfo(struct {
IPNVersion string
FrontendLogID string
BackendLogID string
OS string
OSVersion string
Container opt.Bool
Env string
Distro string
DistroVersion string
DistroCodeName string
App string
Desktop opt.Bool
Package string
DeviceModel string
PushDeviceToken string
Hostname string
ShieldsUp bool
ShareeNode bool
NoLogsNoSupport bool
RemoteConfig bool
WireIngress bool
IngressEnabled bool
AllowsUpdate bool
Machine string
GoArch string
GoArchVar string
GoVersion string
RoutableIPs []netip.Prefix
RequestTags []string
WoLMACs []string
Services []Service
NetInfo *NetInfo
SSH_HostKeys []string
Cloud string
Userspace opt.Bool
UserspaceRouter opt.Bool
AppConnector opt.Bool
ServicesHash string
PeerRelay bool
ExitNodeID StableNodeID
Location *Location
TPM *TPMInfo
StateEncrypted opt.Bool
IPNVersion string
FrontendLogID string
BackendLogID string
OS string
OSVersion string
Container opt.Bool
Env string
Distro string
DistroVersion string
DistroCodeName string
App string
Desktop opt.Bool
Package string
DeviceModel string
PushDeviceToken string
Hostname string
ShieldsUp bool
ShareeNode bool
NoLogsNoSupport bool
RemoteConfig bool
WireIngress bool
IngressEnabled bool
FunnelAuthEnabled bool
AllowsUpdate bool
Machine string
GoArch string
GoArchVar string
GoVersion string
RoutableIPs []netip.Prefix
RequestTags []string
WoLMACs []string
Services []Service
NetInfo *NetInfo
SSH_HostKeys []string
Cloud string
Userspace opt.Bool
UserspaceRouter opt.Bool
AppConnector opt.Bool
ServicesHash string
PeerRelay bool
ExitNodeID StableNodeID
Location *Location
TPM *TPMInfo
StateEncrypted opt.Bool
}{})
// View returns a read-only view of NetInfo.