cmd/tailscale/cli: synthesize tag:bp//<id> for join's authkey exchange

HookResolveAuthKey requires a non-empty tag set on the OAuth-client-
secret to auth-key exchange (see feature/oauthkey/oauthkey.go), but
"tailscale join" intentionally omits --advertise-tags: the blueprint
owns the node's tag set. The join command therefore hit the hook's
"oauth authkeys require --advertise-tags" rejection before the auth
key was ever requested from the control plane.

Fill the tag in at the join call site from the resolved blueprint id:
the auto-generated tag for blueprint <id> is "tag:bp//<id>" (see
tailcfg.BlueprintTagNamespacePrefix), which is exactly the AuthTag
the paired OAuth client server-side is scoped to. The hook accepts
the request and the existing scope-mismatch validator on the corp
side catches any later drift.

Updates #cleanup

Signed-off-by: Kabir Sikand <[email protected]>
This commit is contained in:
Kabir Sikand committed 2026-05-18 16:46:21 +00:00
1 parent 2d93449efa
commit a3467e680f
1 file changed
+9 -3
+9 -3
View File
@@ -13,6 +13,7 @@ import (
"github.com/peterbourgon/ff/v3/ffcli"
"tailscale.com/internal/client/tailscale"
"tailscale.com/ipn"
"tailscale.com/tailcfg"
"tailscale.com/util/clientmetric"
)
@@ -159,9 +160,14 @@ func runJoin(ctx context.Context, args []string, ja *joinArgsT) (retErr error) {
authKey := ja.authKey
if f, ok := tailscale.HookResolveAuthKey.GetOk(); ok {
// The OAuth-client-secret -> auth-key exchange. The exchange
// itself validates the secret against the blueprint's paired
// client server-side.
authKey, err = f(ctx, ja.authKey, prefs.AdvertiseTags)
// validates the secret against the blueprint's paired client
// server-side, which is itself scoped to "tag:bp//<id>"; we
// synthesize that tag from the blueprint id here so the hook,
// which requires a non-empty tag set, accepts the request
// without --advertise-tags (a flag join intentionally does
// not expose, because the blueprint owns the node's tags).
bpTag := "tag:" + tailcfg.BlueprintTagNamespacePrefix + id
authKey, err = f(ctx, ja.authKey, []string{bpTag})
if err != nil {
return fmt.Errorf("exchanging OAuth client secret for auth key: %w", err)
}