From 167b7e65890693cf79e4c28a609cae0402e45f67 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Tue, 17 Nov 2026 11:40:59 +0000 Subject: [PATCH] hscontrol/testdata: add raw Tailscale API recordings Cited by the /api/v2 tests that copy or keep apart from Tailscale. --- hscontrol/testdata/tailscale_api/README.md | 25 ++ .../tailscale_api/probe-A-authkey-tags.txt | 11 + .../probe-G-keys-oauth-errors.txt | 43 ++++ .../tailscale_api/probe-J-devices.txt | 27 +++ .../tailscale_api/probe-N-one-exit-prefix.txt | 6 + .../probe-P-one-exit-prefix-peer-view.txt | 28 +++ .../tailscale_api/probe-Q-self-revoke.txt | 10 + .../probe-R-oauth-client-tags.txt | 8 + .../probe-T-keys-oauth-errors.txt | 193 +++++++++++++++ .../probe-U-oauth-token-rules.txt | 144 +++++++++++ .../tailscale_api/probe-V-devices.txt | 224 ++++++++++++++++++ .../probe-W-key-in-use-and-joins.txt | 52 ++++ 12 files changed, 771 insertions(+) create mode 100644 hscontrol/testdata/tailscale_api/README.md create mode 100644 hscontrol/testdata/tailscale_api/probe-A-authkey-tags.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-G-keys-oauth-errors.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-J-devices.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-N-one-exit-prefix.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-P-one-exit-prefix-peer-view.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-Q-self-revoke.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-R-oauth-client-tags.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-T-keys-oauth-errors.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-U-oauth-token-rules.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-V-devices.txt create mode 100644 hscontrol/testdata/tailscale_api/probe-W-key-in-use-and-joins.txt diff --git a/hscontrol/testdata/tailscale_api/README.md b/hscontrol/testdata/tailscale_api/README.md new file mode 100644 index 000000000..e4719981f --- /dev/null +++ b/hscontrol/testdata/tailscale_api/README.md @@ -0,0 +1,25 @@ +# Raw Tailscale API recordings + +Transcripts of calls against the live Tailscale API, made on the tscap test +tailnet with disposable nodes and keys that each probe deleted again. They are +not in tscap's step format and no test reads them; the `/api/v2` tests cite +their row IDs (`probe-U U5k`) in the comments that explain why Headscale +answers as it does. + +Each file states its own time and setup in its first lines. Secrets are cut to +`…-REDACTED`, the public IP to `REDACTED-IP`, and the tailnet owner's login to +`REDACTED-USER`. Keep every file as it is; a new recording is a new file. + +| File | What it records | +| --------- | ---------------------------------------------------------------- | +| `probe-A` | auth keys with tags in and out of the policy, admin API key | +| `probe-G` | key and OAuth client errors, delete and read-after-delete | +| `probe-J` | device calls: tags, authorized, attributes, delete | +| `probe-N` | one exit prefix enabled, as the node sees it | +| `probe-P` | one exit prefix enabled, as a peer sees it | +| `probe-Q` | an OAuth token deleting its own client | +| `probe-R` | tags of a new OAuth client, admin API key | +| `probe-T` | keys, OAuth clients, descriptions, listing with `all=true` | +| `probe-U` | OAuth token rules: tags, scopes, refusals by scope, key listing | +| `probe-V` | devices by token scope; tag writes by tagged tokens | +| `probe-W` | keys in use, joins with ended keys, description characters | diff --git a/hscontrol/testdata/tailscale_api/probe-A-authkey-tags.txt b/hscontrol/testdata/tailscale_api/probe-A-authkey-tags.txt new file mode 100644 index 000000000..196f7aeb1 --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-A-authkey-tags.txt @@ -0,0 +1,11 @@ +### A1: auth key, tag NOT in tagOwners (API key of an admin) +{"message":"requested tags [tag:not-in-policy-probe] are invalid or not permitted"} +HTTP 400 + +### A2: auth key, tag IN tagOwners (tag:server) +{"id":"kWtRcJ6TTH11CNTRL","key":"tskey-auth-kWtRcJ-REDACTED","keyType":"auth","expirySeconds":600,"created":"2026-11-12T18:09:42Z","expires":"2026-11-12T18:19:42Z","capabilities":{"devices":{"create":{"reusable":false,"ephemeral":false,"preauthorized":true,"tags":["tag:server"]}}},"description":"hs probe A2","userId":"uRWUsmwMTZ11CNTRL"} +HTTP 200 + +### A3: auth key, expirySeconds over 90 days (100 days) +{"message":"expirySeconds must be less than or equal to 7776000"} +HTTP 400 diff --git a/hscontrol/testdata/tailscale_api/probe-G-keys-oauth-errors.txt b/hscontrol/testdata/tailscale_api/probe-G-keys-oauth-errors.txt new file mode 100644 index 000000000..b1cb9618b --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-G-keys-oauth-errors.txt @@ -0,0 +1,43 @@ +# G. Keys +G1 no expirySeconds : {"expirySeconds":7776000,"life_days":90,"caps":{"reusable":false,"ephemeral":false,"preauthorized":false},"hasUserId":true} +G2 empty body {} : {"message":"exactly one capability scope must be populated"} HTTP 400 +G3 no capabilities.create : {"id":"knXBWyaxCM11CNTRL","key":"tskey-auth-knXBWy-REDACTED","keyType":"auth","expirySeconds":60,"created":"2026-11-12T18:38:54Z","expires":"2026-11-12T18:39:54Z","capabilities":{"devices":{"cre HTTP 200 +G4 description 51 chars : {"id":"kremE3f1po11CNTRL","key":"tskey-auth-kremE3-REDACTED","keyType":"auth","expirySeconds":60,"created":"2026-11-12T18:38:54Z","expires":"2026-11-12T18:39:54Z","capabilities":{"devices":{"cre HTTP 200 +G5 expirySeconds 0 : {"message":null,"expirySeconds":7776000} +G6 expirySeconds -5 : {"message":"expirySeconds must be greater than or equal to 0"} HTTP 400 +G7 unknown body field : {"id":"kJygcemSr621CNTRL","key":"tskey-auth-kJygce-REDACTED HTTP 200 +G8 bad JSON : {"message":"invalid JSON in request body"} HTTP 400 +G9 tag without tag: prefix : {"message":"requested tags [server] are invalid or not permitted"} HTTP 400 +G10 a key 3s past its expiry : GET {"invalid":true,"revoked":null,"pastExpiry":true} in list: 0 +G11 list shape : {"top":["keys"],"fieldsOfFirst":["created","description","expires","expirySeconds","id","keyType","scopes","userId"]} +G12 keyType api via the API : {"message":"invalid key type, \"api\" is not supported"} HTTP 400 + +# H. OAuth clients +H1 create, read scope, no tags: {"keyType":"client","scopes":["devices:core:read"],"tags":null,"hasKey":true,"expires":null,"hasUserId":true} +H2 scope that needs tags : {"message":"OAuth clients with auth key write scope must specify one or more tags"} HTTP 400 +H3 unknown scope : {"message":"invalid scopes: [\"devices:cor\"]"} HTTP 400 +H4 no scopes : {"message":"scopes cannot be empty, at least one scope is required for OAuth clients"} HTTP 400 +H5 client in list : default 0 all=true 1 +H6 DELETE client : null HTTP 200 +H7 GET client after delete : {"id":"kiJueGvH4521CNTRL","keyType":"client","created":"2026-11-12T18:39:01Z","revoked":"2026-11-12T18:39:02Z","invalid":true,"scopes":["devices:core:read"],"description":"hs probe H1","userId":"uRWUsmwMTZ11CNTRL"} HTTP 200 +H8 DELETE client again : null HTTP 200 + +# I. Errors and strictness +I1 no credential : {"message":"API token invalid"} HTTP 401 +I2 wrong credential : {"message":"API token invalid"} HTTP 401 +I3 unknown device : {"message":"no manageable device matching this ID found"} HTTP 404 +I4 unknown query parameter : HTTP 200 +I5 fields=bogus : {"message":"\"bogus\" is not a valid fields parameter"} HTTP 400 +I6 wrong method (PUT devices) : {"error": "method_not_allowed", "message": "HTTP method not allowed for this endpoint"} HTTP 405 +I7 unknown path : 404 page not found HTTP 404 +I8 other tailnet name : {"message":"tailnet \"example.invalid\" not found"} HTTP 404 +I9 response headers : content-type: application/json;x-tailscale-request-id: REQ-2026111218390292177855af467169;x-tailscale-s: 40; + +# cleanup: only the 7 keys this probe created + DELETE kBk4xUbRuB21CNTRL -> 200 + DELETE kgyM5rwex121CNTRL -> 200 + DELETE kiJueGvH4521CNTRL -> 200 + DELETE kJygcemSr621CNTRL -> 200 + DELETE knXBWyaxCM11CNTRL -> 200 + DELETE kremE3f1po11CNTRL -> 200 + DELETE kz2U2Smfrs11CNTRL -> 200 diff --git a/hscontrol/testdata/tailscale_api/probe-J-devices.txt b/hscontrol/testdata/tailscale_api/probe-J-devices.txt new file mode 100644 index 000000000..70571f8fb --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-J-devices.txt @@ -0,0 +1,27 @@ +# J. Devices (tagged node id=7990515889368926 nodeId=n1LduZJvP521CNTRL, user node id=7968549144901955) +J1 fields, default : ["addresses","authorized","blocksIncomingConnections","clientVersion","connectedToControl","created","expires","hostname","id","isExternal","keyExpiryDisabled","lastSeen","machineKey","name","nodeId","nodeKey","oauthClientId","os","tags","tailnetLockError","tailnetLockKey","updateAvailable","user"] +J1 fields, extra with all : ["advertisedRoutes","clientConnectivity","distro","enabledRoutes","postureStatus","sshEnabled"] +J1 tagged node, some values : {"name":"hs-probe-tag.tail78f774.ts.net","hostname":"hs-probe-tag","user":"REDACTED-USER","tags":["tag:server"],"authorized":true,"isEphemeral":null,"isExternal":false,"blocksIncomingConnections":false,"updateAvailable":true,"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":[],"keyExpiryDisabled":true} +J1 user node, some values : {"name":"hs-probe-usr.tail78f774.ts.net","hostname":"hs-probe-usr","user":"REDACTED-USER","tags":null,"keyExpiryDisabled":false} +J1 used single-use keys now : {"invalid":true,"revoked":"2026-11-12T18:39:44Z"} {"invalid":true,"revoked":"2026-11-12T18:39:45Z"} in list: 0 +J2 GET by nodeId : HTTP 200 +J3 rename user node : null HTTP 200 -> name=hs-probe-renamed. +J4 rename to a taken name : {"message":"name \"hs-probe-tag\" is already taken"} HTTP 400 -> name=hs-probe-renamed. +J5 rename to an invalid name : null HTTP 200 +J6 rename to empty : null HTTP 200 -> name=hs-probe-usr. +J7 tags [] on the tagged node : {"message":"tagged nodes cannot be untagged without reauth"} HTTP 400 -> {"tags":["tag:server"],"user":"REDACTED-USER"} +J8 unknown tag on tagged node : {"message":"requested tags [tag:not-in-policy-probe] are invalid or not permitted"} HTTP 400 +J9 tag the user-owned node : null HTTP 200 -> {"tags":["tag:server"],"user":"REDACTED-USER","keyExpiryDisabled":false} +J10 tags [] on it afterwards : {"message":"tagged nodes cannot be untagged without reauth"} HTTP 400 -> {"tags":["tag:server"],"user":"REDACTED-USER","keyExpiryDisabled":false} +J11 GET routes : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":[]} HTTP 200 +J12 enable one exit prefix : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":["0.0.0.0/0"]} HTTP 200 +J13 enable a route not offered: {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":["192.168.77.0/24"]} HTTP 200 +J14 invalid route text : {"message":"\"not-a-route\" is not a valid IP address or CIDR prefix"} HTTP 400 +J15 routes [] : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":[]} HTTP 200 +J16 attributes : {"attributes":{"ip:country":"NL","ip:publicAddress":{"type":"IpAddr","value":"REDACTED-IP"},"node:os":"linux","node:osVersion":"6.18.59","node:tsAutoUpdate":false,"node:tsReleaseTrack":"unstable","node:tsStateEncrypted":false,"node:tsVer +J17 authorized:false : null HTTP 200 -> authorized=false +J18 unknown field in body : null HTTP 200 +J19 DELETE device : null HTTP 200 +J20 GET deleted device : {"message":"no manageable device matching this ID found"} HTTP 404 +J21 DELETE it again : {"message":"no manageable device matching this ID found"} HTTP 404 +cleanup : device 200, keys 200 200 , devices left: 0 diff --git a/hscontrol/testdata/tailscale_api/probe-N-one-exit-prefix.txt b/hscontrol/testdata/tailscale_api/probe-N-one-exit-prefix.txt new file mode 100644 index 000000000..fc5cd24b4 --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-N-one-exit-prefix.txt @@ -0,0 +1,6 @@ +# N. One exit prefix on Tailscale (node advertises both exit routes) +N1 nothing enabled : api [] node {"AllowedIPs":["100.94.89.122/32","fd7a:115c:a1e0::a128:597b/128"],"ExitNodeOption":false} +N2 only 0.0.0.0/0 enabled : api ["0.0.0.0/0"] node {"AllowedIPs":["100.94.89.122/32","fd7a:115c:a1e0::a128:597b/128","0.0.0.0/0","::/0"],"ExitNodeOption":true} +N3 only ::/0 enabled : api ["::/0"] node {"AllowedIPs":["100.94.89.122/32","fd7a:115c:a1e0::a128:597b/128","::/0"],"ExitNodeOption":false} +N4 both enabled : api ["0.0.0.0/0","::/0"] node {"AllowedIPs":["100.94.89.122/32","fd7a:115c:a1e0::a128:597b/128","0.0.0.0/0","::/0"],"ExitNodeOption":true} +cleanup: device 200 key 200 devices left 0 diff --git a/hscontrol/testdata/tailscale_api/probe-P-one-exit-prefix-peer-view.txt b/hscontrol/testdata/tailscale_api/probe-P-one-exit-prefix-peer-view.txt new file mode 100644 index 000000000..e51e0d3e1 --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-P-one-exit-prefix-peer-view.txt @@ -0,0 +1,28 @@ +policy in the tailnet now has an accept-all rule: [{"action":"accept","dst":["*:*"],"src":["*"]}] +# P. One exit prefix, seen by another node (exit node id 1814056011328633, other node id 1575466652163777) +P1 nothing enabled + api enabledRoutes : [] + exit node itself : {"exitRoutes":[],"ExitNodeOption":false} + the other node : {"exitRoutes":[],"ExitNodeOption":false} + exit-node list : 0 line(s) for the node +P enabled through the API: ["0.0.0.0/0"] + api enabledRoutes : ["0.0.0.0/0"] + exit node itself : {"exitRoutes":["0.0.0.0/0","::/0"],"ExitNodeOption":true} + the other node : {"exitRoutes":[],"ExitNodeOption":false} + exit-node list : 0 line(s) for the node +P enabled through the API: ["::/0"] + api enabledRoutes : ["::/0"] + exit node itself : {"exitRoutes":["::/0"],"ExitNodeOption":false} + the other node : {"exitRoutes":[],"ExitNodeOption":false} + exit-node list : 0 line(s) for the node +P enabled through the API: ["0.0.0.0/0","::/0"] + api enabledRoutes : ["0.0.0.0/0","::/0"] + exit node itself : {"exitRoutes":["0.0.0.0/0","::/0"],"ExitNodeOption":true} + the other node : {"exitRoutes":["0.0.0.0/0","::/0"],"ExitNodeOption":true} + exit-node list : 1 line(s) for the node +P enabled through the API: [] + api enabledRoutes : [] + exit node itself : {"exitRoutes":[],"ExitNodeOption":false} + the other node : {"exitRoutes":[],"ExitNodeOption":false} + exit-node list : 0 line(s) for the node +cleanup: devices 200 200, keys 200 200 diff --git a/hscontrol/testdata/tailscale_api/probe-Q-self-revoke.txt b/hscontrol/testdata/tailscale_api/probe-Q-self-revoke.txt new file mode 100644 index 000000000..bab85f4f2 --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-Q-self-revoke.txt @@ -0,0 +1,10 @@ +# Q. A credential that deletes itself (2026-11-13T13:53Z) +Q1 admin key creates a client : {"id":"kPyuQBqjwn11CNTRL","key":"tskey-client-kPyuQB-REDACTED","keyType":"client","created":"2026-11-13T13:53:05Z","scopes":["oauth_keys"],"description":"hs probe Q self revoke","userId":"uRWUsmwMTZ11CNTRL"} HTTP 200 +Q2 token from the client : {"token_type":"Bearer","expires_in":3600,"scope":"oauth_keys"} HTTP 200 +Q3 token reads its own client : {"id":"kPyuQBqjwn11CNTRL","keyType":"client","created":"2026-11-13T13:53:05Z","scopes":["oauth_keys"],"description":"hs probe Q self revoke","userId":"uRWUsmwMTZ11CNTRL"} HTTP 200 +Q4 token deletes its own client : null HTTP 200 +Q5 token reads its client again : {"message":"API token invalid"} HTTP 401 +Q6 token lists keys after : {"message":"API token invalid"} HTTP 401 +Q7 token deletes it again : {"message":"API token invalid"} HTTP 401 +Q8 admin key reads the client : {"id":"kPyuQBqjwn11CNTRL","keyType":"client","created":"2026-11-13T13:53:05Z","revoked":"2026-11-13T13:53:06Z","invalid":true,"scopes":["oauth_keys"],"description":"hs probe Q self revoke","userId":"uRWUsmwMTZ11CNTRL"} HTTP 200 +cleanup: client kPyuQBqjwn11CNTRL is revoked already; nothing to delete diff --git a/hscontrol/testdata/tailscale_api/probe-R-oauth-client-tags.txt b/hscontrol/testdata/tailscale_api/probe-R-oauth-client-tags.txt new file mode 100644 index 000000000..e642a4f59 --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-R-oauth-client-tags.txt @@ -0,0 +1,8 @@ +# R. Tags of a new OAuth client, made with an admin API key (2026-11-13T16:24Z) +R0 tagOwners in the policy : ["tag:client","tag:db","tag:exit","tag:exit-a","tag:exit-b","tag:fearow","tag:group-a","tag:group-b","tag:ha","tag:ha-a","tag:ha-a1","tag:ha-a2","tag:ha-b","tag:ha-b1","tag:ha-b2","tag:pidgeotto","tag:pidgey","tag:prod","tag:router","tag:router-a","tag:router-b","tag:router-c","tag:server","tag:spearow","tag:web"] +R1 tag that is in the policy : {"id":"kgBwmWZXZ811CNTRL","key":"tskey-client-kgBwmW-REDACTED","keyType":"client","created":"2026-11-13T16:24:31Z","scopes":["auth_keys"],"tags":["tag:server"],"description":"hs probe R1","userId":"uRWUsmwMTZ11CNTRL"} HTTP 200 +R2 tag that is not in the policy : {"message":"requested tags [tag:hsprobe-nopolicy] are invalid or not permitted"} HTTP 400 +R3 one tag in, one tag not : {"message":"requested tags [tag:hsprobe-nopolicy] are invalid or not permitted"} HTTP 400 +R4 read scope, tag not in the policy : {"message":"requested tags [tag:hsprobe-nopolicy] are invalid or not permitted"} HTTP 400 +R5 tag without the tag: prefix : {"message":"requested tags [server] are invalid or not permitted"} HTTP 400 +cleanup DELETE kgBwmWZXZ811CNTRL -> 200 diff --git a/hscontrol/testdata/tailscale_api/probe-T-keys-oauth-errors.txt b/hscontrol/testdata/tailscale_api/probe-T-keys-oauth-errors.txt new file mode 100644 index 000000000..b604a4aac --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-T-keys-oauth-errors.txt @@ -0,0 +1,193 @@ +# T. Keys, OAuth clients, errors, users, policy reads (2026-11-13T17:29:07Z) +# policy tonight: accept-all, tagOwners as the tscap baseline plus tag:hsov-child owned by tag:server + +## T-A. Auth keys, admin API key +A1 tag not in tagOwners : {"message":"requested tags [tag:not-in-policy-probe] are invalid or not permitted"} HTTP 400 +A2 tag in tagOwners : {"id":"kqhhNHsNoQ11CNTRL","key":"SECRET-REDACTED","keyType":"auth","expirySeconds":600,"created":"2026-11-13T17:29:08Z","expires":"2026-11-13T17:39:08Z","capabilities":{"devices":{"create":{"reusable":false,"ephemeral":false,"preauthorized":true,"tags":["tag:server"]}}},"description":"hs ov A2","userId":"uRWUsmwMTZ11CNTRL"} HTTP 200 +A3 expirySeconds 100 days : {"message":"expirySeconds must be less than or equal to 7776000"} HTTP 400 +A4 expirySeconds 7776001 : {"message":"expirySeconds must be less than or equal to 7776000"} HTTP 400 +A5 expirySeconds 7776000 : {"expirySeconds":7776000,"created":"2026-11-13T17:29:09Z","expires":"2027-02-11T17:29:09Z"} HTTP 200 +A6 no expirySeconds : {"expirySeconds":7776000,"caps":{"reusable":false,"ephemeral":false,"preauthorized":false},"hasUserId":true,"fields":["capabilities","created","expires","expirySeconds","id","key","keyType","userId"]} HTTP 200 +A7 expirySeconds 0 : {"expirySeconds":7776000} HTTP 200 +A8 expirySeconds -5 : {"message":"expirySeconds must be greater than or equal to 0"} HTTP 400 +A9 empty body {} : {"message":"exactly one capability scope must be populated"} HTTP 400 +A10 capabilities.devices, no create : {"caps":{"devices":{"create":{"reusable":false,"ephemeral":false,"preauthorized":false}}},"keyType":"auth"} HTTP 200 +A11 description 51 chars : {"descriptionLen":50} HTTP 200 +A12 description 255 chars : {"descriptionLen":50} HTTP 200 +A13 description 2000 chars : {"descriptionLen":50} HTTP 200 +A14 unknown body field : {"id":"kC93Busjie11CNTRL","fields":["capabilities","created","expires","expirySeconds","id","key","keyType","userId"]} HTTP 200 +A15 bad JSON : {"message":"invalid JSON in request body"} HTTP 400 +A16 tag without tag: prefix : {"message":"requested tags [server] are invalid or not permitted"} HTTP 400 +A17 keyType api : {"message":"invalid key type, \"api\" is not supported"} HTTP 400 +A18 keyType nosuch : {"message":"invalid key type, \"nosuch\" is not supported"} HTTP 400 +A19 tags [] (empty list) : {"caps":{"reusable":false,"ephemeral":false,"preauthorized":false}} HTTP 200 +A20 two tags, one not in the policy : {"message":"requested tags [tag:not-in-policy-probe] are invalid or not permitted"} HTTP 400 + +## T-F. How a key ends +F1 a plain key no node used : {"id":"kTniioEFtU11CNTRL","hasKey":true} HTTP 200 +F2 GET it by ID (is the secret there?) : {"hasKey":false,"fields":["capabilities","created","description","expires","expirySeconds","id","keyType","userId"]} HTTP 200 +F3 in the list before : {"inList":true} HTTP 200 +F4 DELETE it : null HTTP 200 +F5 GET by ID after : {"revoked":"2026-11-13T17:29:17Z","invalid":true,"expires":"2026-11-13T17:39:16Z"} HTTP 200 +F6 in the list after : {"inList":false} HTTP 200 +F7 in the list after, all=true : {"inList":false} HTTP 200 +F8 DELETE it again : null HTTP 200 +F9 GET by ID after the second DELETE : {"revoked":"2026-11-13T17:29:17Z","invalid":true} HTTP 200 +F10 GET an unknown key ID : {"message":"not found"} HTTP 404 +F11 DELETE an unknown key ID : {"message":"key not found"} HTTP 404 +F12 a key with expirySeconds 2 : {"id":"k4svmJnkkb11CNTRL","created":"2026-11-13T17:29:20Z","expires":"2026-11-13T17:29:22Z"} HTTP 200 +F13 the same key 5 s later : {"revoked":null,"invalid":true,"expires":"2026-11-13T17:29:22Z"} HTTP 200 +F14 the expired key in the list : {"inList":false} HTTP 200 +F15 the key list, default : {"top":["keys"],"count":11,"types":["api","auth"],"fieldsOfFirst":["created","description","expires","expirySeconds","id","keyType","scopes","userId"]} HTTP 200 +F16 the key list, all=true : {"count":13,"types":{"api":3,"auth":10},"anyRevoked":0,"anyInvalid":0} HTTP 200 +F17 the still valid tagged key A2 by ID : {"keyType":"auth","userId":"uRWUsmwMTZ11CNTRL","revoked":null,"invalid":null,"capabilities":{"devices":{"create":{"reusable":false,"ephemeral":false,"preauthorized":true,"tags":["tag:server"]}}}} HTTP 200 + +## T-H. OAuth clients, admin API key +H1 create, read scope, no tags : {"fields":["created","description","id","key","keyType","scopes","userId"],"keyType":"client","scopes":["devices:core:read"],"expires":"absent","hasUserId":true} HTTP 200 +H2 auth_keys, no tags : {"message":"OAuth clients with auth key write scope must specify one or more tags"} HTTP 400 +H2b devices:core, no tags : {"message":"OAuth clients with devices write scope must specify one or more tags"} HTTP 400 +H2c all, no tags : {"id":"kUZkb7eYA311CNTRL","scopes":["all"],"tags":null} HTTP 200 +H2d auth_keys:read, no tags : {"id":"kFanX8Q7YQ11CNTRL","scopes":["auth_keys:read"],"tags":null} HTTP 200 +H3 unknown scope : {"message":"invalid scopes: [\"devices:cor\"]"} HTTP 400 +H4 no scopes : {"message":"scopes cannot be empty, at least one scope is required for OAuth clients"} HTTP 400 +H4b scopes left out : {"message":"scopes cannot be empty, at least one scope is required for OAuth clients"} HTTP 400 +H4c every scope name Headscale has, one client: {"id":"kKBddZN7Jn11CNTRL","scopes":["all","all:read","auth_keys","auth_keys:read","devices:core","devices:core:read","devices:posture_attributes","devices:posture_attributes:read","devices:routes","devices:routes:read","feature_settings","feature_settings:read","oauth_keys","oauth_keys:read","policy_file","policy_file:read","users","users:read"],"message":null} HTTP 200 +H5 client H1 in the list, default : {"inList":false} HTTP 200 +H5b client H1 in the list, all=true : {"inList":true} HTTP 200 +H5c GET the client by ID (is the secret there?): {"hasKey":false,"fields":["created","description","id","keyType","scopes","userId"]} HTTP 200 +H6 DELETE the client : null HTTP 200 +H7 GET the client after : {"keyType":"client","revoked":"2026-11-13T17:29:33Z","invalid":true,"scopes":["devices:core:read"]} HTTP 200 +H7b the revoked client in the list, all=true: {"inList":false} HTTP 200 +H8 DELETE the client again : null HTTP 200 + +## T-R. Tags of a new OAuth client, admin API key +R1 tag in the policy : {"id":"krmDnUVtBk11CNTRL","scopes":["auth_keys"],"tags":["tag:server"],"userId":"uRWUsmwMTZ11CNTRL"} HTTP 200 +R2 tag not in the policy : {"message":"requested tags [tag:hsprobe-nopolicy] are invalid or not permitted"} HTTP 400 +R3 one tag in, one not : {"message":"requested tags [tag:hsprobe-nopolicy] are invalid or not permitted"} HTTP 400 +R4 read scope, tag not in the policy : {"message":"requested tags [tag:hsprobe-nopolicy] are invalid or not permitted"} HTTP 400 +R5 tag without the tag: prefix : {"message":"requested tags [server] are invalid or not permitted"} HTTP 400 +R6 tag owned by a tag (tag:hsov-child) : {"id":"ko6WQGRhpq11CNTRL","scopes":["auth_keys"],"tags":["tag:hsov-child"]} HTTP 200 + +## T-Q. A credential that deletes itself +Q1 admin key creates a client (oauth_keys) : {"id":"kfDxE7Xyis11CNTRL","scopes":["oauth_keys"]} HTTP 200 +Q2 token from the client : {"token_type":"Bearer","expires_in":3600,"scope":"oauth_keys"} HTTP 200 +Q3 token reads its own client : {"id":"kfDxE7Xyis11CNTRL","revoked":null,"invalid":null} HTTP 200 +Q4 token deletes its own client : null HTTP 200 +Q5 token reads its client again : {"message":"API token invalid"} HTTP 401 +Q6 token lists keys after : {"message":"API token invalid"} HTTP 401 +Q7 token deletes it again : {"message":"API token invalid"} HTTP 401 +Q8 admin key reads the client : {"id":"kfDxE7Xyis11CNTRL","revoked":"2026-11-13T17:29:38Z","invalid":true} HTTP 200 +Q9 a new token from the revoked client : {"message":"API token invalid"} HTTP 401 + +## T-I. Errors and strictness +I1 no credential : {"message":"API token invalid"} HTTP 401 +I2 wrong credential : {"message":"API token invalid"} HTTP 401 +I3 unknown device : {"message":"no manageable device matching this ID found"} HTTP 404 +I3b unknown device, nodeId form : {"message":"no manageable device matching this ID found"} HTTP 404 +I4 unknown query parameter : {"top":["devices"],"count":5} HTTP 200 +I4b devices?pageSize=1&limit=1 : {"top":["devices"],"count":5} HTTP 200 +I5 fields=bogus : {"message":"\"bogus\" is not a valid fields parameter"} HTTP 400 +I6 wrong method (PUT devices) : {"error":"method_not_allowed","message":"HTTP method not allowed for this endpoint"} HTTP 405 +I6 headers: content-type=application/json allow=None +I7 unknown path : {"message":"404 page not found"} HTTP 404 +I7 headers: content-type=application/json +I8 other tailnet name : {"message":"tailnet \"example.invalid\" not found"} HTTP 404 +I9 response headers of a 200: content-type=application/json; x-tailscale-request-id present=True; names=['connection', 'content-type', 'date', 'referrer-policy', 'strict-transport-security', 'transfer-encoding', 'x-tailscale-request-id', 'x-tailscale-s'] +I10 HTTP Basic, API key as the user name : {"top":["devices"],"count":5} HTTP 200 +I11 JSON body sent as text/plain : {"id":"kmZXPkpgxr11CNTRL","message":null} HTTP 200 + +## T-K. Users (read only; other users' values are masked) +K1 list shape : {"top":["users"],"count":3,"fieldsOfFirst":["created","currentlyConnected","deviceCount","displayName","id","lastSeen","loginName","profilePicUrl","role","status","tailnetId","type"]} HTTP 200 +K2 the probe user : {"created":"\u2026","currentlyConnected":true,"deviceCount":3,"displayName":"\u2026","id":"\u2026","lastSeen":"\u2026","loginName":"REDACTED-USER","profilePicUrl":"\u2026","role":"owner","status":"active","tailnetId":"\u2026","type":"member"} HTTP 200 +K3 unknown user : {"message":"404 page not found"} HTTP 404 +K4 type=bogus : {"message":"invalid type \"bogus\""} HTTP 400 +K4b role=bogus : {"message":"invalid role \"bogus\""} HTTP 400 +K4c type=member : {"count":3} HTTP 200 + +## T-L. Policy: reads and validate only. No POST /acl is sent. +L1 GET /acl, default : content-type=application/hujson etag="9710cc1ea50bcd255f101856c61b111e223cec396fae3bde566ffdc95befa888" bytes=1193 HTTP 200 +L2 GET /acl, Accept: json : content-type=application/json etag="9710cc1ea50bcd255f101856c61b111e223cec396fae3bde566ffdc95befa888" HTTP 200 +L3 GET /acl?details=1 : {"top":["acl","errors","warnings"],"aclType":"str","warnings":null,"errors":null} HTTP 200 +L6 validate: the current policy : {} HTTP 200 +L6b validate: HuJSON with a comment and a trailing comma: {} HTTP 200 +L6c the same HuJSON sent as application/json: {} HTTP 200 +L7 validate: bad syntax : {"message":"line 1, column 11: parsing value: unexpected EOF"} HTTP 200 +L8 validate: unknown tag : {"message":"src=tag not found: \"tag:nope\""} HTTP 200 +L9 validate: a failing test : {"message":"src=tag not found: \"tag:client\""} HTTP 200 +L9b validate: unknown top-level key : {"message":"json: unknown field \"nosuchsection\""} HTTP 200 +L10 validate: tests as a JSON list : HTTP 200 +L10b validate: empty body : {"message":"unexpected end of JSON input"} HTTP 400 +L11 policy unchanged : etag="9710cc1ea50bcd255f101856c61b111e223cec396fae3bde566ffdc95befa888" HTTP 200 +M1 settings : {"aclsExternallyManagedOn":false,"devicesApprovalOn":false,"devicesAutoUpdatesOn":false,"devicesKeyDurationDays":180,"usersApprovalOn":false,"usersRoleAllowedToJoinExternalTailnets":"admin","networkFlowLoggingOn":false,"postureIdentityCollectionOn":false,"httpsEnabled":false,"regionalRoutingOn":false,"routeSelection":"active-passive-failover"} HTTP 200 + +## cleanup: only the keys and clients this probe made, by ID; revoked or expired ones are left as they are + DELETE kqhhNHsNoQ11CNTRL (auth) -> 200 + DELETE kkZaz7Hqgu11CNTRL (auth) -> 200 + DELETE kAKbZVxyZB21CNTRL (auth) -> 200 + DELETE kx1gJ2pXBe11CNTRL (auth) -> 200 + DELETE kt2mTKZdZ521CNTRL (auth) -> 200 + DELETE kstLA4RR6X11CNTRL (auth) -> 200 + DELETE kCXWaNA6P121CNTRL (auth) -> 200 + DELETE kV2QreTuH511CNTRL (auth) -> 200 + DELETE kC93Busjie11CNTRL (auth) -> 200 + DELETE kKDSHrsxAH11CNTRL (auth) -> 200 + kTniioEFtU11CNTRL: HTTP 200 revoked=2026-11-13T17:29:17Z invalid=True; left + k4svmJnkkb11CNTRL: HTTP 200 revoked=None invalid=True; left + kDa3udRpGY11CNTRL: HTTP 200 revoked=2026-11-13T17:29:33Z invalid=True; left + DELETE kUZkb7eYA311CNTRL (client) -> 200 + DELETE kFanX8Q7YQ11CNTRL (client) -> 200 + DELETE kKBddZN7Jn11CNTRL (client) -> 200 + DELETE krmDnUVtBk11CNTRL (client) -> 200 + DELETE ko6WQGRhpq11CNTRL (client) -> 200 + kfDxE7Xyis11CNTRL: HTTP 200 revoked=2026-11-13T17:29:38Z invalid=True; left + DELETE kmZXPkpgxr11CNTRL (auth) -> 200 +for the poller: F1 revoked key kTniioEFtU11CNTRL; F12 expired key k4svmJnkkb11CNTRL; H1 revoked client kDa3udRpGY11CNTRL; Q self-revoked client kfDxE7Xyis11CNTRL + +## T-A, second part (2026-11-13T17:31:02Z): what is stored of a long description +A21 description of 50 chars ending in END : {"createAnswer":"abcdefghijabcdefghijabcdefghijabcdefghijabcdefgEND","len":50,"GETbyID":"abcdefghijabcdefghijabcdefghijabcdefghijabcdefgEND","GETlen":50} HTTP 200 +A21 description of 51 chars ending in END : {"createAnswer":"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghEN","len":50,"GETbyID":"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghEN","GETlen":50} HTTP 200 +A21 description of 60 chars ending in END : {"createAnswer":"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij","len":50,"GETbyID":"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij","GETlen":50} HTTP 200 +A22 OAuth client, description of 60 chars : {"createAnswer":"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij","len":50} HTTP 200 + +## T-I, second part: unknown paths +I7a /api/v2/nosuchpath : {"message":"404 page not found"} HTTP 404 + content-type=application/json +I7b /api/v2/tailnet/-/nosuchpath : 404 page not found HTTP 404 + content-type=text/plain; charset=utf-8 +I7c /api/v2/device/1/nosuchpath : 404 page not found HTTP 404 + content-type=text/plain; charset=utf-8 +I7d /api/v3/tailnet/-/devices : {"message":"404 page not found"} HTTP 404 + content-type=application/json +I7e /api/nosuchpath : {"message":"404 page not found"} HTTP 404 + content-type=application/json +I7f /nosuchpath : unknown endpoint HTTP 404 + content-type=text/plain; charset=utf-8 +I6b DELETE /tailnet/-/devices : {"error":"method_not_allowed","message":"HTTP method not allowed for this endpoint"} HTTP 405 +I6c PATCH /tailnet/-/keys : {"error":"method_not_allowed","message":"HTTP method not allowed for this endpoint"} HTTP 405 +I6d PUT /tailnet/-/acl/validate : {"error":"method_not_allowed","message":"HTTP method not allowed for this endpoint"} HTTP 405 + +## T-L, second part: validate with a failing test +L9 validate: a policy whose test fails : {"message":"test(s) failed","data":[{"user":"tag:server","errors":["[acl test error]: address \"tag:server:80\" (protocol \"tcp\"): want: Accept, got: Drop"]}]} HTTP 200 + content-type=application/json content-length=160 +L9c validate: a policy whose test passes : {} HTTP 200 + content-type=application/json content-length=2 +L10 tests as a list, against the stored policy, failing: {"message":"test(s) failed","data":[{"user":"tag:server","errors":["[acl test error]: address \"tag:server:80\" (protocol \"tcp\"): want: Drop, got: Accept"]}]} HTTP 200 + content-type=application/json content-length=160 +L10c tests as a list, against the stored policy, passing: (empty body) HTTP 200 + content-type=None content-length=0 +L9d validate: two errors at once (unknown tag twice): {"message":"src=tag not found: \"tag:nope\""} HTTP 200 + content-type=application/json content-length=45 + +## cleanup of this part, by ID + DELETE kJjTnU4Tw621CNTRL -> 200 + DELETE kwB3bLMc2H11CNTRL -> 200 + DELETE kHNQ6LnuDm11CNTRL -> 200 + DELETE ktH6sNeqeU11CNTRL -> 200 + +## T-F, third part (2026-11-13T17:42:33Z): the fields of a key list entry, by keyType +F18 list, default : {"count":3,"fieldsByType":{"api":["created","description","expires","expirySeconds","id","keyType","scopes","userId"],"auth":["capabilities","created","description","expires","expirySeconds","id","keyType","userId"]},"mine":{"kuDojX6ftJ11CNTRL":["capabilities","created","description","expires","expirySeconds","id","keyType","userId"],"k3upgqneru11CNTRL":["capabilities","created","description","expires","expirySeconds","id","keyType","userId"],"kodeWzTrUy11CNTRL":"not listed"}} HTTP 200 +F18 list, all=true : {"count":6,"fieldsByType":{"api":["created","description","expires","expirySeconds","id","keyType","scopes","userId"],"auth":["capabilities","created","description","expires","expirySeconds","id","keyType","userId"],"client":["created","description","id","keyType","scopes","userId"]},"mine":{"kuDojX6ftJ11CNTRL":["capabilities","created","description","expires","expirySeconds","id","keyType","userId"],"k3upgqneru11CNTRL":["capabilities","created","description","expires","expirySeconds","id","keyType","userId"],"kodeWzTrUy11CNTRL":["created","description","id","keyType","scopes","userId"]}} HTTP 200 +F19 GET a tagged auth key by ID: fields : ["capabilities","created","description","expires","expirySeconds","id","keyType","userId"] HTTP 200 + cleanup DELETE kuDojX6ftJ11CNTRL -> 200 + cleanup DELETE k3upgqneru11CNTRL -> 200 + cleanup DELETE kodeWzTrUy11CNTRL -> 200 diff --git a/hscontrol/testdata/tailscale_api/probe-U-oauth-token-rules.txt b/hscontrol/testdata/tailscale_api/probe-U-oauth-token-rules.txt new file mode 100644 index 000000000..a8828cb5e --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-U-oauth-token-rules.txt @@ -0,0 +1,144 @@ +# U. OAuth token rules on keys and clients (2026-11-13T17:32:00Z) +# the admin API key belongs to user uRWUsmwMTZ11CNTRL +# U. OAuth token rules on keys and clients (2026-11-13T17:32:06Z) +# the admin API key belongs to user uRWUsmwMTZ11CNTRL +setup all+tag:server: scopes ['all'] tags ['tag:server'] : {"client":"kuKtJrbrqK11CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"all","tags":"tag:server"}} HTTP 200 +setup all, no tags: scopes ['all'] tags None : {"client":"ku1tRoAJtZ11CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"all"}} HTTP 200 +setup auth_keys+tag:server: scopes ['auth_keys'] tags ['tag:server']: {"client":"kf3oyBMFTJ11CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"auth_keys","tags":"tag:server"}} HTTP 200 +setup auth_keys:read: scopes ['auth_keys:read'] tags None : {"client":"khwmH9Rkgt11CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"auth_keys:read"}} HTTP 200 +setup oauth_keys: scopes ['oauth_keys'] tags None : {"client":"ktU7zKH9Vy11CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"oauth_keys"}} HTTP 200 +setup oauth_keys:read: scopes ['oauth_keys:read'] tags None : {"client":"khvmCjnqk311CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"oauth_keys:read"}} HTTP 200 +setup auth_keys+oauth_keys+tag:server: scopes ['auth_keys', 'oauth_keys'] tags ['tag:server']: {"client":"ksFSRj21W421CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"auth_keys oauth_keys","tags":"tag:server"}} HTTP 200 +setup devices:core:read: scopes ['devices:core:read'] tags None: {"client":"kK82XJqKW711CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"devices:core:read"}} HTTP 200 +setup users:read: scopes ['users:read'] tags None : {"client":"kMv4nrjXmJ11CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"users:read"}} HTTP 200 +setup policy_file:read: scopes ['policy_file:read'] tags None : {"client":"k7A9u6txRQ11CNTRL","token":{"token_type":"Bearer","expires_in":3600,"scope":"policy_file:read"}} HTTP 200 + +## U1. A token with scope all and tag:server makes OAuth clients +U1a client: scopes [all], NO tags : {"id":"kzdAQH8mrB21CNTRL","keyType":"client","scopes":["all"]} HTTP 200 +U1b client: scopes [all], tags [tag:server] : {"id":"kBWwfvK1qN11CNTRL","keyType":"client","scopes":["all"],"tags":["tag:server"]} HTTP 200 +U1c client: scopes [all], tags [tag:prod] : {"message":"requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +U1d client: scopes [all], tags [tag:hsov-child] : {"id":"kbm7Tu6L7821CNTRL","keyType":"client","scopes":["all"],"tags":["tag:hsov-child"]} HTTP 200 +U1e client: scopes [auth_keys], tags [tag:prod] : {"message":"requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +U1f client: scopes [devices:core:read], no tags : {"id":"k6WxWkFmBT11CNTRL","keyType":"client","scopes":["devices:core:read"]} HTTP 200 +## U1, continued: can the untagged client from U1a reach a tag its maker did not have? +U1g token from the U1a client, no tags asked : {"token_type":"Bearer","expires_in":3600,"scope":"all"} HTTP 200 +U1h token from the U1a client, tags=tag:prod asked : {"token_type":"Bearer","expires_in":3600,"scope":"all","tags":"tag:prod"} HTTP 200 +U1i that token makes an auth key for tag:prod : {"id":"k5XRLVdZ3621CNTRL","keyType":"auth","capTags":["tag:prod"]} HTTP 200 +U1j the U1g token makes an auth key for tag:prod : {"id":"kqX8W5y9n121CNTRL","keyType":"auth","capTags":["tag:prod"]} HTTP 200 +U1k the U1g token makes an auth key with no tags : {"message":"tailnet-owned auth key must have tags set"} HTTP 400 + +## U2. Tokens make auth keys +U2a all+tag:server: key for tag:server : {"id":"kWgrpH9HJf11CNTRL","keyType":"auth","capTags":["tag:server"]} HTTP 200 +U2b all+tag:server: key for tag:prod : {"message":"requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +U2c all+tag:server: key for tag:hsov-child (owned by tag:server) : {"id":"kNDXUomUSs11CNTRL","keyType":"auth","capTags":["tag:hsov-child"]} HTTP 200 +U2d all+tag:server: key with no tags (a user's key) : {"message":"tailnet-owned auth key must have tags set"} HTTP 400 +U2e all, no tags: key with no tags (a user's key) : {"message":"tailnet-owned auth key must have tags set"} HTTP 400 +U2f all, no tags: key for tag:prod : {"id":"k3GfLn5eyz11CNTRL","keyType":"auth","capTags":["tag:prod"]} HTTP 200 +U2g auth_keys+tag:server: key for tag:server : {"id":"kC5kFvFBu111CNTRL","keyType":"auth","capTags":["tag:server"]} HTTP 200 +U2h auth_keys+tag:server: key for tag:prod : {"message":"requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +U2i auth_keys+tag:server: key for tag:hsov-child : {"id":"kh7TmUHMz321CNTRL","keyType":"auth","capTags":["tag:hsov-child"]} HTTP 200 +U2j auth_keys+tag:server: key with no tags : {"message":"tailnet-owned auth key must have tags set"} HTTP 400 +U2k auth_keys+tag:server: key for both tag:server and tag:prod : {"message":"requested tags [tag:server tag:prod] are invalid or not permitted"} HTTP 400 +U2l auth_keys+tag:server: keyType api : {"message":"invalid key type, \"api\" is not supported"} HTTP 400 +U2m all, no tags: keyType api : {"message":"invalid key type, \"api\" is not supported"} HTTP 400 + +## U3. Tokens make OAuth clients: scopes the token lacks +U3a oauth_keys: client with [devices:core:read] : {"message":"actor cannot set scopes: [devices:core:read]"} HTTP 403 +U3b oauth_keys: client with [all] : {"message":"actor cannot set scopes: [all]"} HTTP 403 +U3c oauth_keys: client with [oauth_keys] : {"id":"kGQiDWcGqq11CNTRL","keyType":"client","scopes":["oauth_keys"]} HTTP 200 +U3d oauth_keys: client with [auth_keys] tags [tag:server] : {"message":"actor cannot set scopes: [auth_keys]"} HTTP 403 +U3e parent (ak+ok, tag:server): client [auth_keys] tags [tag:server]: {"id":"kPkF6cXzcR11CNTRL","keyType":"client","scopes":["auth_keys"],"tags":["tag:server"]} HTTP 200 +U3f parent: client [auth_keys] tags [tag:prod] : {"message":"requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +U3g parent: client [devices:core] tags [tag:server] : {"message":"actor cannot set scopes: [devices:core]"} HTTP 403 +U3h parent: client [all] no tags : {"message":"actor cannot set scopes: [all]"} HTTP 403 +U3i oauth_keys:read: client with [oauth_keys:read] : {"message":"calling actor does not have enough permissions to perform this function"} HTTP 403 + +## U4. The token endpoint +U4a devices:core:read client asks for scope devices:core : {"message":"OAuth client cannot grant scopes \"devices:core\""} HTTP 403 +U4b all+tag:server client asks for scope auth_keys : {"token_type":"Bearer","expires_in":3600,"scope":"auth_keys","tags":"tag:server"} HTTP 200 +U4c all+tag:server client asks for tags=tag:prod : {"message":"requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +U4d all+tag:server client asks for tags=tag:hsov-child : {"token_type":"Bearer","expires_in":3600,"scope":"all","tags":"tag:hsov-child"} HTTP 200 +U4e all, no tags client asks for tags=tag:prod : {"token_type":"Bearer","expires_in":3600,"scope":"all","tags":"tag:prod"} HTTP 200 +U4f wrong client secret : {"message":"API token invalid"} HTTP 401 +U4g client secret as HTTP Basic user name, no client_id : {"token_type":"Bearer","expires_in":3600,"scope":"devices:core:read"} HTTP 200 + +## U5. What a token without the scope is answered (403 or 404?) +U5a auth_keys:read: POST a key : {"message":"calling actor does not have enough permissions to perform this function"} HTTP 403 +U5b auth_keys:read: DELETE a key : {"message":"calling actor does not have enough permissions to perform this function"} HTTP 403 +U5c auth_keys:read: GET a key by ID : {"id":"k15ptN59G721CNTRL","keyType":"auth","userId":"uRWUsmwMTZ11CNTRL","capTags":["tag:server"]} HTTP 200 +U5d auth_keys:read: GET an OAuth client by ID : {"message":"not found"} HTTP 404 +U5e auth_keys:read: GET devices : {"message":"not found"} HTTP 404 +U5f auth_keys:read: GET /acl : {"message":"not found"} HTTP 404 +U5g auth_keys:read: GET users : {"message":"not found"} HTTP 404 +U5h auth_keys:read: GET settings : {} HTTP 200 +U5i oauth_keys:read: GET an auth key by ID : {"message":"not found"} HTTP 404 +U5j oauth_keys:read: GET an OAuth client by ID : {"id":"kK82XJqKW711CNTRL","keyType":"client","scopes":["devices:core:read"],"userId":"uRWUsmwMTZ11CNTRL"} HTTP 200 +U5k oauth_keys:read: DELETE an OAuth client : {"message":"calling actor does not have enough permissions to perform this function"} HTTP 403 +U5l auth_keys+tag:server: DELETE an OAuth client : {"message":"not found"} HTTP 404 +U5m devices:core:read: GET keys : {"message":"calling actor does not have enough permissions to perform this function"} HTTP 403 +U5n devices:core:read: POST a key : {"message":"not found"} HTTP 404 +U5o devices:core:read: POST an OAuth client : {"message":"not found"} HTTP 404 +U5p users:read: GET users : {"count":3} HTTP 200 +U5q users:read: GET devices : {"message":"not found"} HTTP 404 +U5r policy_file:read: GET /acl : (policy text) HTTP 200 +U5s policy_file:read: POST /acl/validate {} : {} HTTP 200 +U5t policy_file:read: GET devices : {"message":"not found"} HTTP 404 +U5u auth_keys+tag:server: DELETE an admin-made tag:server key : null HTTP 200 + +## U6. What a token sees in the key list +U6 auth_keys:read: GET keys : {"count":7,"types":{"auth":7}} HTTP 200 +U6 auth_keys:read: GET keys?all=true : {"count":7,"types":{"auth":7}} HTTP 200 +U6 oauth_keys:read: GET keys : {"count":16,"types":{"client":16}} HTTP 200 +U6 oauth_keys:read: GET keys?all=true : {"count":16,"types":{"client":16}} HTTP 200 +U6 auth_keys+tag:server: GET keys : {"count":7,"types":{"auth":7}} HTTP 200 +U6 auth_keys+tag:server: GET keys?all=true : {"count":7,"types":{"auth":7}} HTTP 200 +U6 all+tag:server: GET keys : {"count":23,"types":{"auth":7,"client":16}} HTTP 200 +U6 all+tag:server: GET keys?all=true : {"count":26,"types":{"api":3,"auth":7,"client":16}} HTTP 200 +U6 all, no tags: GET keys : {"count":23,"types":{"auth":7,"client":16}} HTTP 200 +U6 all, no tags: GET keys?all=true : {"count":26,"types":{"api":3,"auth":7,"client":16}} HTTP 200 +U6 the admin API key: GET keys : {"count":1,"types":{"api":1}} HTTP 200 +U6 the admin API key: GET keys?all=true : {"count":26,"types":{"api":3,"auth":7,"client":16}} HTTP 200 + +## cleanup: only what this probe made, by ID + DELETE kuKtJrbrqK11CNTRL (client) -> 200 + DELETE ku1tRoAJtZ11CNTRL (client) -> 200 + DELETE kf3oyBMFTJ11CNTRL (client) -> 200 + DELETE khwmH9Rkgt11CNTRL (client) -> 200 + DELETE ktU7zKH9Vy11CNTRL (client) -> 200 + DELETE khvmCjnqk311CNTRL (client) -> 200 + DELETE ksFSRj21W421CNTRL (client) -> 200 + DELETE kK82XJqKW711CNTRL (client) -> 200 + DELETE kMv4nrjXmJ11CNTRL (client) -> 200 + DELETE k7A9u6txRQ11CNTRL (client) -> 200 + DELETE kzdAQH8mrB21CNTRL (client) -> 200 + DELETE kBWwfvK1qN11CNTRL (client) -> 200 + DELETE kbm7Tu6L7821CNTRL (client) -> 200 + DELETE k6WxWkFmBT11CNTRL (client) -> 200 + DELETE k5XRLVdZ3621CNTRL (auth) -> 200 + DELETE kqX8W5y9n121CNTRL (auth) -> 200 + DELETE kWgrpH9HJf11CNTRL (auth) -> 200 + DELETE kNDXUomUSs11CNTRL (auth) -> 200 + DELETE k3GfLn5eyz11CNTRL (auth) -> 200 + DELETE kC5kFvFBu111CNTRL (auth) -> 200 + DELETE kh7TmUHMz321CNTRL (auth) -> 200 + DELETE kGQiDWcGqq11CNTRL (client) -> 200 + DELETE kPkF6cXzcR11CNTRL (client) -> 200 + k15ptN59G721CNTRL: HTTP 200, revoked or invalid already; left + +## U1, second run (2026-11-13T17:51:29Z), with tag:prod as the token's tag and tag:server as the foreign one +U1' admin makes a client: scopes [all], tags [tag:prod] : {"id":"kizmTP4Lu611CNTRL","keyType":"client","scopes":["all"],"tags":["tag:prod"],"userId":"uRWUsmwMTZ11CNTRL"} HTTP 200 +U1' its token : {"token_type":"Bearer","expires_in":3600,"scope":"all","tags":"tag:prod"} HTTP 200 +U1'b that token: auth key for tag:server : {"message":"requested tags [tag:server] are invalid or not permitted"} HTTP 400 +U1'c the client asks for tags=tag:server : {"message":"requested tags [tag:server] are invalid or not permitted"} HTTP 400 +U1'a that token: client with scopes [all], NO tags : {"id":"kB77qEVuW411CNTRL","keyType":"client","scopes":["all"]} HTTP 200 +U1'h the child client asks for tags=tag:server : {"token_type":"Bearer","expires_in":3600,"scope":"all","tags":"tag:server"} HTTP 200 +U1'i that token: auth key for tag:server : {"id":"kWyVunmet211CNTRL","keyType":"auth","capTags":["tag:server"]} HTTP 200 +U1'x the child client, read by the admin key : {"id":"kB77qEVuW411CNTRL","keyType":"client","scopes":["all"]} HTTP 200 +## cleanup of the second run, by ID (devices: see probe-V) + device 6629546248399217 (va): DELETE -> 200 + device 6940095435769730 (vb): DELETE -> 200 + DELETE kizmTP4Lu611CNTRL (client) -> 200 + DELETE kB77qEVuW411CNTRL (client) -> 200 + DELETE kWyVunmet211CNTRL (auth) -> 200 + kxAtBBrapw11CNTRL: revoked or invalid already; left + kDjSeu2T9h11CNTRL: revoked or invalid already; left diff --git a/hscontrol/testdata/tailscale_api/probe-V-devices.txt b/hscontrol/testdata/tailscale_api/probe-V-devices.txt new file mode 100644 index 000000000..5ee38a8d7 --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-V-devices.txt @@ -0,0 +1,224 @@ +# V. Devices (2026-11-13T17:35:08Z) +joined vt = hs-ov-vt device 5137834464279452 tags ['tag:server'] +joined vp = hs-ov-vp device 5634160180376393 tags ['tag:prod'] +joined vu = hs-ov-vu device 4923444444017101 tags None +joined vw = hs-ov-vw device 4376300691662747 tags None + +## V-J. Device rows, admin API key +J1 fields, default : ["addresses", "authorized", "blocksIncomingConnections", "clientVersion", "connectedToControl", "created", "expires", "hostname", "id", "isExternal", "keyExpiryDisabled", "lastSeen", "machineKey", "name", "nodeId", "nodeKey", "oauthClientId", "os", "tags", "tailnetLockError", "tailnetLockKey", "updateAvailable", "user"] +J1 fields, extra with fields=all : ["advertisedRoutes", "clientConnectivity", "distro", "enabledRoutes", "postureStatus", "sshEnabled"] +J1 tagged node vt : {"name":"hs-ov-vt.tail78f774.ts.net","hostname":"hs-ov-vt","user":"REDACTED-USER","tags":["tag:server"],"authorized":true,"isEphemeral":"absent","isExternal":false,"blocksIncomingConnections":false,"updateAvailable":true,"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":[],"keyExpiryDisabled":true,"expires":"2027-05-12T17:35:09Z","created":"2026-11-13T17:35:09Z","clientVersion":"1.105.0-ERR-BuildInfo","os":"linux"} HTTP 200 +J1 user node vu : {"name":"hs-ov-vu.tail78f774.ts.net","hostname":"hs-ov-vu","user":"REDACTED-USER","tags":"absent","keyExpiryDisabled":false,"expires":"2027-05-12T17:35:12Z","created":"2026-11-13T17:35:12Z"} HTTP 200 +J1 vt: what is in clientConnectivity and postureStatus : {"clientConnectivity":["clientSupports","endpoints","latency","mappingVariesByDestIP"],"endpointsCount":4,"postureStatus":{}} HTTP 200 +J2 GET by nodeId : {"id":"5137834464279452","nodeId":"nMbQvYCw7h11CNTRL","hostname":"hs-ov-vt"} HTTP 200 +J3 rename vu to hs-ov-renamed : null HTTP 200 + stored name : hs-ov-renamed.tail78f774.ts.net +J4 rename vu to the name of vt : {"message":"name \"hs-ov-vt\" is already taken"} HTTP 400 + stored name : hs-ov-renamed.tail78f774.ts.net +J5 rename vu to 'Bad Name!' : {"answer":null,"storedName":"bad-name.tail78f774.ts.net"} HTTP 200 +J5 rename vu to 'UPPER-Case' : {"answer":null,"storedName":"upper-case.tail78f774.ts.net"} HTTP 200 +J5 rename vu to 'under_score' : {"answer":null,"storedName":"under-score.tail78f774.ts.net"} HTTP 200 +J5 rename vu to 'trailing-' : {"answer":null,"storedName":"trailing.tail78f774.ts.net"} HTTP 200 +J5 rename vu to '-leading' : {"answer":null,"storedName":"leading.tail78f774.ts.net"} HTTP 200 +J5 rename vu to 'dot.ted' : {"answer":null,"storedName":"dot-ted.tail78f774.ts.net"} HTTP 200 +J5 rename vu to 'ax64' : {"answer":null,"storedName":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.tail78f774.ts.net"} HTTP 200 +J5 rename vu to 'ax63' : {"answer":null,"storedName":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.tail78f774.ts.net"} HTTP 200 +J5 rename vu to 'ünïcode' : {"answer":null,"storedName":"ncode.tail78f774.ts.net"} HTTP 200 +J5 rename vu to ' spaced ' : {"answer":null,"storedName":"spaced.tail78f774.ts.net"} HTTP 200 +J5 rename vu to '!!!' : {"answer":{"message":"empty DNS label"},"storedName":"spaced.tail78f774.ts.net"} HTTP 500 +J5 rename vu to 'hs-ov-vt.tail78f774.ts.net' : {"answer":{"message":"name \"hs-ov-vt\" is already taken"},"storedName":"spaced.tail78f774.ts.net"} HTTP 400 +J5 rename vu to 'hs-ov-full.tail78f774.ts.net' : {"answer":null,"storedName":"hs-ov-full.tail78f774.ts.net"} HTTP 200 +J6 rename vu to "" : null HTTP 200 + stored name : hs-ov-vu.tail78f774.ts.net +J6b name endpoint, body {} : null HTTP 200 +J18 rename with an unknown field in the body : null HTTP 200 + stored name : hs-ov-vu.tail78f774.ts.net +J7 tags [] on the tagged node vt : {"message":"tagged nodes cannot be untagged without reauth"} HTTP 400 +J7b tags null on vt : {"message":"tagged nodes cannot be untagged without reauth"} HTTP 400 +J7c body {} on vt : {"message":"tagged nodes cannot be untagged without reauth"} HTTP 400 + vt afterwards : {"tags":["tag:server"],"user":"REDACTED-USER","keyExpiryDisabled":true,"expires":"2027-05-12T17:35:09Z"} HTTP 200 +J8 a tag that is not in the policy, on vt : {"message":"requested tags [tag:not-in-policy-probe] are invalid or not permitted"} HTTP 400 + vu before it is tagged : {"tags":"absent","user":"REDACTED-USER","keyExpiryDisabled":false,"expires":"2027-05-12T17:35:12Z"} HTTP 200 +J9 tag the user-owned node vu with tag:server : null HTTP 200 + vu afterwards : {"tags":["tag:server"],"user":"REDACTED-USER","keyExpiryDisabled":false,"expires":"2027-05-12T17:35:12Z"} HTTP 200 + vu, the node itself : {"Tags": ["tag:server"], "KeyExpiry": "2027-05-12T17:35:12Z", "UserID is the tagged-devices user": 4923444444017101} +J10 tags [] on vu afterwards : {"message":"tagged nodes cannot be untagged without reauth"} HTTP 400 + vu afterwards : {"tags":["tag:server"],"user":"REDACTED-USER","keyExpiryDisabled":false,"expires":"2027-05-12T17:35:12Z"} HTTP 200 +J11 GET routes of vt : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":[]} HTTP 200 +J12 enable one exit prefix, 0.0.0.0/0 : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":["0.0.0.0/0"]} HTTP 200 +J13 enable a route vt does not offer, 192.168.77.0/24 : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":["192.168.77.0/24"]} HTTP 200 +J14 a route that is not a prefix : {"message":"\"not-a-route\" is not a valid IP address or CIDR prefix"} HTTP 400 +J14b a bare address, 10.99.0.1 : {"message":"\"10.99.0.1\" is not a valid IP address or CIDR prefix"} HTTP 400 +J14c a prefix with host bits, 10.99.0.1/24 : {"message":"10.99.0.1/24 has non-address bits set; expected 10.99.0.0/24"} HTTP 400 +J15 routes [] : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":[]} HTTP 200 +J15b body {} : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","::/0"],"enabledRoutes":[]} HTTP 200 +J16 attributes of vt (ip: values masked) : {"ip:country":"(str)","ip:publicAddress":"{type: IpAddr, value: \u2026}","node:os":"linux","node:osVersion":"6.18.59","node:tsAutoUpdate":false,"node:tsReleaseTrack":"unstable","node:tsStateEncrypted":false,"node:tsVersion":"1.105.0"} HTTP 200 + top-level keys of the answer : ['attributes'] + +## V-A. authorized, key, update-client +J17 authorized:false on vw (device approval is off) : null HTTP 200 + vw in the API : {"authorized":false,"connectedToControl":true,"keyExpiryDisabled":false} HTTP 200 + vw, the node itself : {"BackendState": "NeedsMachineAuth", "AuthURL": "", "KeyExpiry": "2027-05-12T17:35:13Z", "Online": true, "Expired": null, "Health": []} + vw as vp sees it : null +J17b authorized:true on vw : null HTTP 200 + vw in the API : {"authorized":true,"connectedToControl":true} HTTP 200 + vw, the node itself : {"BackendState": "Running", "AuthURL": "", "KeyExpiry": "2027-05-12T17:35:13Z", "Online": true, "Expired": null, "Health": []} + vw as vp sees it : {"Online": true, "KeyExpiry": "2027-05-12T17:35:13Z", "Expired": null, "Active": false, "ExitNodeOption": false, "AllowedIPs": ["100.99.201.10/32", "fd7a:115c:a1e0::1728:c90b/128"], "Tags": null} +J22 key endpoint, body {} : null HTTP 200 +J22b key endpoint, keyExpiryDisabled:"yes" : {"message":"invalid JSON in request body"} HTTP 400 +J22c key endpoint, keyExpiryDisabled:true : null HTTP 200 + vw in the API : {"keyExpiryDisabled":true,"expires":"2027-05-12T17:35:13Z"} HTTP 200 +J22d key endpoint, keyExpiryDisabled:false : null HTTP 200 + vw in the API : {"keyExpiryDisabled":false,"expires":"2027-05-12T17:35:13Z"} HTTP 200 +J23 POST /device/{id}/update-client, no body (vt, connected): {"message":"not found"} HTTP 404 +J23b the same with body {} : {"message":"not found"} HTTP 404 +J23c GET /device/{id}/update-client : {"message":"not found"} HTTP 404 +J23d GET /device/{id}/update-status : {"message":"not found"} HTTP 404 +J23e POST update-client, unknown device : {"message":"no manageable device matching this ID found"} HTTP 404 +J23f GET update-status, unknown device : {"message":"no manageable device matching this ID found"} HTTP 404 + vt after the update calls : {"clientVersion":"1.105.0-ERR-BuildInfo","updateAvailable":true,"connectedToControl":true} HTTP 200 + vt, the node itself : {"BackendState": "Running", "AuthURL": "", "KeyExpiry": null, "Online": true, "Expired": null, "Health": []} + +## V-P. One exit prefix: the API, the exit node itself, and the peer vp (accept-all policy) +P1 nothing enabled : {"apiEnabled":[],"apiAdvertised":["0.0.0.0/0","10.99.0.0/24","::/0"],"ownAllowedIPs(routes)":[],"peerAllowedIPs(routes)":[],"peerExitNodeOption":false,"peerExitNodeListLines":0} +P enabled through the API: ["0.0.0.0/0"] (HTTP 200) : {"apiEnabled":["0.0.0.0/0"],"apiAdvertised":["0.0.0.0/0","10.99.0.0/24","::/0"],"ownAllowedIPs(routes)":["0.0.0.0/0","::/0"],"peerAllowedIPs(routes)":[],"peerExitNodeOption":false,"peerExitNodeListLines":0} +P enabled through the API: ["::/0"] (HTTP 200) : {"apiEnabled":["::/0"],"apiAdvertised":["0.0.0.0/0","10.99.0.0/24","::/0"],"ownAllowedIPs(routes)":["::/0"],"peerAllowedIPs(routes)":[],"peerExitNodeOption":false,"peerExitNodeListLines":0} +P enabled through the API: ["0.0.0.0/0", "::/0"] (HTTP 200) : {"apiEnabled":["0.0.0.0/0","::/0"],"apiAdvertised":["0.0.0.0/0","10.99.0.0/24","::/0"],"ownAllowedIPs(routes)":["0.0.0.0/0","::/0"],"peerAllowedIPs(routes)":["0.0.0.0/0","::/0"],"peerExitNodeOption":true,"peerExitNodeListLines":1} +P enabled through the API: [] (HTTP 200) : {"apiEnabled":[],"apiAdvertised":["0.0.0.0/0","10.99.0.0/24","::/0"],"ownAllowedIPs(routes)":[],"peerAllowedIPs(routes)":[],"peerExitNodeOption":false,"peerExitNodeListLines":0} +## V-P. A route that is enabled before the node offers it +P6 192.168.77.0/24 enabled, not offered (HTTP 200) : {"apiEnabled":["192.168.77.0/24"],"apiAdvertised":["0.0.0.0/0","10.99.0.0/24","::/0"],"ownAllowedIPs(routes)":[],"peerAllowedIPs(routes)":[],"peerExitNodeOption":false,"peerExitNodeListLines":0} +P7 vt now offers 192.168.77.0/24 too (set rc=0) : {"apiEnabled":["192.168.77.0/24"],"apiAdvertised":["0.0.0.0/0","10.99.0.0/24","192.168.77.0/24","::/0"],"ownAllowedIPs(routes)":["192.168.77.0/24"],"peerAllowedIPs(routes)":["192.168.77.0/24"],"peerExitNodeOption":false,"peerExitNodeListLines":0} + +## V-AA. autoApprovers: routes with one exit prefix, exitNode, and a subnet route +joined ve = hs-ov-ve device 6480010133651139 tags ['tag:exit'] +joined vea = hs-ov-vea device 3608002295240475 tags ['tag:exit-a'] +joined vr = hs-ov-vr device 4255599410298843 tags ['tag:router'] +AA1 ve: tag:exit, autoApprovers.routes {0.0.0.0/0: [tag:exit]}: {"apiEnabled":[],"apiAdvertised":["0.0.0.0/0","::/0"],"ownAllowedIPs(routes)":[],"peerAllowedIPs(routes)":[],"peerExitNodeOption":false,"peerExitNodeListLines":1} +AA2 vea: tag:exit-a, autoApprovers.exitNode [tag:exit-a] : {"apiEnabled":["0.0.0.0/0","::/0"],"apiAdvertised":["0.0.0.0/0","::/0"],"ownAllowedIPs(routes)":["0.0.0.0/0","::/0"],"peerAllowedIPs(routes)":["0.0.0.0/0","::/0"],"peerExitNodeOption":true,"peerExitNodeListLines":1} +AA3 vr: tag:router, autoApprovers.routes {10.77.0.0/24: [tag:router]}: {"apiEnabled":["10.77.0.0/24"],"apiAdvertised":["10.77.0.0/24","10.78.0.0/24"],"ownAllowedIPs(routes)":["10.77.0.0/24"],"peerAllowedIPs(routes)":["10.77.0.0/24"],"peerExitNodeOption":false,"peerExitNodeListLines":0} + +## V-Y. What an OAuth token may read and change on a device +setup core: scopes ['devices:core'] tags ['tag:server'] : {"token_type":"Bearer","expires_in":3600,"scope":"devices:core","tags":"tag:server"} HTTP 200 +setup coreread: scopes ['devices:core:read'] tags None : {"token_type":"Bearer","expires_in":3600,"scope":"devices:core:read"} HTTP 200 +setup routes: scopes ['devices:routes'] tags ['tag:server'] : {"token_type":"Bearer","expires_in":3600,"scope":"devices:routes"} HTTP 200 +setup routesread: scopes ['devices:routes:read'] tags None : {"token_type":"Bearer","expires_in":3600,"scope":"devices:routes:read"} HTTP 200 +setup posture: scopes ['devices:posture_attributes'] tags ['tag:server']: {"token_type":"Bearer","expires_in":3600,"scope":"devices:posture_attributes"} HTTP 200 +setup postureread: scopes ['devices:posture_attributes:read'] tags None: {"token_type":"Bearer","expires_in":3600,"scope":"devices:posture_attributes:read"} HTTP 200 +setup authkeys: scopes ['auth_keys'] tags ['tag:server'] : {"token_type":"Bearer","expires_in":3600,"scope":"auth_keys","tags":"tag:server"} HTTP 200 +setup: devices:routes with no tags : {"id":"kXb7RmTowu11CNTRL","scopes":["devices:routes"],"tags":"absent","message":"absent"} HTTP 200 +setup: devices:posture_attributes with no tags : {"id":"k1mFepEeTK11CNTRL","scopes":["devices:posture_attributes"],"tags":"absent","message":"absent"} HTTP 200 +Y1 coreread: GET device : {"fieldCount":23,"has":["nodeKey","machineKey","user","tags","addresses","tailnetLockKey"],"endpoints":0} HTTP 200 +Y1 coreread: GET device?fields=all : {"fieldCount":29,"has":["advertisedRoutes","enabledRoutes","clientConnectivity","nodeKey","machineKey","user","tags","postureStatus","addresses","tailnetLockKey"],"endpoints":4} HTTP 200 +Y1 coreread: GET device list?fields=all : {"count":12,"first":{"fieldCount":28,"has":["advertisedRoutes","enabledRoutes","clientConnectivity","nodeKey","machineKey","user","postureStatus","addresses","tailnetLockKey"],"endpoints":4}} HTTP 200 +Y1 coreread: GET routes : {"message":"not found"} HTTP 404 +Y1 coreread: GET attributes : {"message":"not found"} HTTP 404 +Y1 core: GET device : {"fieldCount":23,"has":["nodeKey","machineKey","user","tags","addresses","tailnetLockKey"],"endpoints":0} HTTP 200 +Y1 core: GET device?fields=all : {"fieldCount":29,"has":["advertisedRoutes","enabledRoutes","clientConnectivity","nodeKey","machineKey","user","tags","postureStatus","addresses","tailnetLockKey"],"endpoints":4} HTTP 200 +Y1 core: GET device list?fields=all : {"count":12,"first":{"fieldCount":28,"has":["advertisedRoutes","enabledRoutes","clientConnectivity","nodeKey","machineKey","user","postureStatus","addresses","tailnetLockKey"],"endpoints":4}} HTTP 200 +Y1 core: GET routes : {"message":"not found"} HTTP 404 +Y1 core: GET attributes : {"message":"not found"} HTTP 404 +Y1 routesread: GET device : {"message":"not found"} HTTP 404 +Y1 routesread: GET device?fields=all : {"message":"not found"} HTTP 404 +Y1 routesread: GET device list?fields=all : {"message":"not found"} HTTP 404 +Y1 routesread: GET routes : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","192.168.77.0/24","::/0"],"enabledRoutes":[]} HTTP 200 +Y1 routesread: GET attributes : {"message":"not found"} HTTP 404 +Y1 routes: GET device : {"message":"not found"} HTTP 404 +Y1 routes: GET device?fields=all : {"message":"not found"} HTTP 404 +Y1 routes: GET device list?fields=all : {"message":"not found"} HTTP 404 +Y1 routes: GET routes : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","192.168.77.0/24","::/0"],"enabledRoutes":[]} HTTP 200 +Y1 routes: GET attributes : {"message":"not found"} HTTP 404 +Y1 postureread: GET device : {"message":"not found"} HTTP 404 +Y1 postureread: GET device?fields=all : {"message":"not found"} HTTP 404 +Y1 postureread: GET device list?fields=all : {"message":"not found"} HTTP 404 +Y1 postureread: GET routes : {"message":"not found"} HTTP 404 +Y1 postureread: GET attributes : {"attributes":["ip:country","ip:publicAddress","node:os","node:osVersion","node:tsAutoUpdate","node:tsReleaseTrack","node:tsStateEncrypted","node:tsVersion"]} HTTP 200 +Y1 posture: GET device : {"message":"not found"} HTTP 404 +Y1 posture: GET device?fields=all : {"message":"not found"} HTTP 404 +Y1 posture: GET device list?fields=all : {"message":"not found"} HTTP 404 +Y1 posture: GET routes : {"message":"not found"} HTTP 404 +Y1 posture: GET attributes : {"attributes":["ip:country","ip:publicAddress","node:os","node:osVersion","node:tsAutoUpdate","node:tsReleaseTrack","node:tsStateEncrypted","node:tsVersion"]} HTTP 200 +## V-Y. Writes +Y2 routes: POST routes [10.99.0.0/24] on vt : {"advertisedRoutes":["0.0.0.0/0","10.99.0.0/24","192.168.77.0/24","::/0"],"enabledRoutes":["10.99.0.0/24"]} HTTP 200 +Y2 routesread: POST routes [10.99.0.0/24] on vt : {"message":"calling actor does not have enough permissions to perform this function"} HTTP 403 +Y2 core: POST routes [10.99.0.0/24] on vt : {"message":"not found"} HTTP 404 +Y2 coreread: POST routes [10.99.0.0/24] on vt : {"message":"not found"} HTTP 404 +Y2 routes: rename vt to hs-ov-vt : {"message":"not found"} HTTP 404 +Y2 coreread: rename vt to hs-ov-vt : {"message":"calling actor does not have enough permissions to perform this function"} HTTP 403 +Y2 core: rename vt to hs-ov-vt : null HTTP 200 +## V-Y. A token with devices:core and tag:server changes tags +Y3a vt (tag:server) -> [tag:prod] : {"message":"requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +Y3b vt (tag:server) -> [tag:server, tag:prod] : {"message":"requested tags [tag:server tag:prod] are invalid or not permitted"} HTTP 400 +Y3c vp (tag:prod) -> [tag:server] : {"message":"cannot remove current tags: requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +Y3d vp (tag:prod) -> [tag:server, tag:prod] : {"message":"cannot remove current tags: requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +Y3e vp (tag:prod) -> [tag:prod] (no change) : null HTTP 200 +Y3f vt (tag:server) -> [tag:hsov-child] (owned by tag:server): null HTTP 200 + vt afterwards : {"tags":["tag:hsov-child"],"user":"REDACTED-USER","keyExpiryDisabled":true,"expires":"2027-05-12T17:35:09Z"} HTTP 200 +Y3g vt (tag:hsov-child) -> [tag:server] : null HTTP 200 + vt afterwards : {"tags":["tag:server"],"user":"REDACTED-USER","keyExpiryDisabled":true,"expires":"2027-05-12T17:35:09Z"} HTTP 200 +Y3h vt -> [] : {"message":"tagged nodes cannot be untagged without reauth"} HTTP 400 +Y3i vw (user-owned) -> [tag:prod] : {"message":"requested tags [tag:prod] are invalid or not permitted"} HTTP 400 +Y3j vw (user-owned) -> [tag:server] : null HTTP 200 + vw afterwards : {"tags":["tag:server"],"user":"REDACTED-USER","keyExpiryDisabled":false,"expires":"2027-05-12T17:35:13Z"} HTTP 200 +## V-Y. Does the tag of the token limit other writes? (vp has tag:prod, the token has tag:server) +Y4a rename vp : null HTTP 200 + stored name : hs-ov-vp-renamed.tail78f774.ts.net +Y4b key expiry of vp : null HTTP 200 +Y4c authorized:true on vp : null HTTP 200 +Y4d update-client on vt : {"message":"not found"} HTTP 404 +Y4e coreread: update-client on vt : {"message":"not found"} HTTP 404 +Y4f coreread: key expiry of vt : {"message":"calling actor does not have enough permissions to perform this function"} HTTP 403 +Y4g coreread: DELETE vr : {"message":"calling actor does not have enough permissions to perform this function"} HTTP 403 +## V-Y. A node that joins with a key an OAuth token made +Y5a token (auth_keys, tag:server) makes a tag:server key : {"id":"kUCDxmr2H111CNTRL","userId":"absent","keyType":"auth"} HTTP 200 +joined vk = hs-ov-vk device 2026072860829947 tags ['tag:server'] +Y5b vk in the API : {"hostname":"hs-ov-vk","user":"","tags":["tag:server"],"keyExpiryDisabled":true,"oauthClientId":"kArR4GMbWK11CNTRL"} HTTP 200 +Y5c vt (admin-made key) for comparison : {"hostname":"hs-ov-vt","user":"REDACTED-USER","tags":["tag:server"],"keyExpiryDisabled":true,"oauthClientId":"kRtixQb2nq11CNTRL"} HTTP 200 + +## V-D. Delete, and lastSeen of a device that is gone +D1 vr, 45 s after its tailscaled was stopped : {"connectedToControl":false,"lastSeen":"2026-11-13T17:37:50Z","now":"2026-11-13T17:38:20Z"} HTTP 200 +J19a token (devices:core, tag:server): DELETE vp (tag:prod) : null HTTP 200 +J19 DELETE vu : null HTTP 200 +J20 GET the deleted device : {"message":"no manageable device matching this ID found"} HTTP 404 +J21 DELETE it again : {"message":"no manageable device matching this ID found"} HTTP 404 + vu, the node itself, 10 s after the delete : {"BackendState": "NeedsLogin", "AuthURL": "", "KeyExpiry": "2027-05-12T17:35:12Z", "Online": false, "Expired": null, "Health": ["This device has been removed from the tailnet. Log in again to reconnect.", "Tailscale could not connect to the 'Amsterdam' relay server. Your Internet connection might be down, or the server might be temporarily unavailable.", "Some peers are advertising routes but --accept-routes is false"]} +D2 vr, 85 s after its tailscaled was stopped : {"connectedToControl":false,"lastSeen":"2026-11-13T17:37:50Z","now":"2026-11-13T17:39:02Z"} HTTP 200 + +## cleanup: only what this probe made, by ID + device 5137834464279452 (hs-ov-vt): DELETE -> 200 + device 5634160180376393 (hs-ov-vp): HTTP 404, gone already + device 4923444444017101 (hs-ov-vu): HTTP 404, gone already + device 4376300691662747 (hs-ov-vw): DELETE -> 200 + device 6480010133651139 (hs-ov-ve): DELETE -> 200 + device 3608002295240475 (hs-ov-vea): DELETE -> 200 + device 4255599410298843 (hs-ov-vr): DELETE -> 200 + device 2026072860829947 (hs-ov-vk): DELETE -> 200 + kRtixQb2nq11CNTRL: HTTP 200, revoked or invalid already; left + kM87kBsZfg11CNTRL: HTTP 200, revoked or invalid already; left + k5SMGfXpt921CNTRL: HTTP 200, revoked or invalid already; left + kK3GxfMEN421CNTRL: HTTP 200, revoked or invalid already; left + kBnZzUQD3L11CNTRL: HTTP 200, revoked or invalid already; left + kVLw4Kb4o811CNTRL: HTTP 200, revoked or invalid already; left + k489QJViMT11CNTRL: HTTP 200, revoked or invalid already; left + DELETE k5o7zCHDwt11CNTRL (client) -> 200 + DELETE ka41Hk6dAf11CNTRL (client) -> 200 + DELETE koS4u4Xs2v11CNTRL (client) -> 200 + DELETE k4jZmEyRsq11CNTRL (client) -> 200 + DELETE k1fa2UW4zf11CNTRL (client) -> 200 + DELETE kBnqrQ6dFY11CNTRL (client) -> 200 + DELETE kArR4GMbWK11CNTRL (client) -> 200 + DELETE kXb7RmTowu11CNTRL (client) -> 200 + DELETE k1mFepEeTK11CNTRL (client) -> 200 + kUCDxmr2H111CNTRL: HTTP 200, revoked or invalid already; left +done 2026-11-13T17:39:20Z + +## notes added after the run +- AA1 "peerExitNodeListLines":1 is not ve: the count matched the hostname as a substring, and "hs-ov-ve" is inside "hs-ov-vea", the exit node of AA2. For ve, the readings that count are apiEnabled [], peerAllowedIPs [] and peerExitNodeOption false. +- Y5b/Y5c "oauthClientId": for vt it is the ID of the admin-made auth key it joined with; for vk it is the ID of the OAuth client whose token made the auth key (see created-objects.tsv). + +## second run of two rows that rested on one run (2026-11-13T17:51:32Z) +Y5' va joined with an admin-made key : {"user":"REDACTED-USER","oauthClientId":"kDjSeu2T9h11CNTRL","theAuthKey":"kDjSeu2T9h11CNTRL"} HTTP 200 +Y5' vb joined with a token-made key : {"user":"","oauthClientId":"kB77qEVuW411CNTRL","theAuthKey":"kxAtBBrapw11CNTRL","theClientOfTheToken":"kB77qEVuW411CNTRL"} HTTP 200 +J5' rename va to '!!!' : {"answer":{"message":"empty DNS label"},"storedName":"hs-ov-va.tail78f774.ts.net"} HTTP 500 +J5' rename va to '---' : {"answer":{"message":"empty DNS label"},"storedName":"hs-ov-va.tail78f774.ts.net"} HTTP 500 +J5' rename va to 'é' : {"answer":{"message":"empty DNS label"},"storedName":"hs-ov-va.tail78f774.ts.net"} HTTP 500 +J5' rename va to 'a!' : {"answer":null,"storedName":"a.tail78f774.ts.net"} HTTP 200 diff --git a/hscontrol/testdata/tailscale_api/probe-W-key-in-use-and-joins.txt b/hscontrol/testdata/tailscale_api/probe-W-key-in-use-and-joins.txt new file mode 100644 index 000000000..d65065dc9 --- /dev/null +++ b/hscontrol/testdata/tailscale_api/probe-W-key-in-use-and-joins.txt @@ -0,0 +1,52 @@ +# W. Keys in use, and joins with keys that ended (2026-11-13T17:39:48Z) +## W-E. An ephemeral, reusable, tagged auth key; one node joined with it; the key is deleted +E1 the key : {"id":"krczVbN4pV11CNTRL","revoked":null,"invalid":null,"capabilities":{"devices":{"create":{"reusable":true,"ephemeral":true,"preauthorized":true,"tags":["tag:server"]}}}} HTTP 200 +E2 the device : {"hostname":"hs-ov-we","isEphemeral":true,"tags":["tag:server"],"connectedToControl":true,"keyExpiryDisabled":true} HTTP 200 +E3 DELETE the key while the node is connected : null HTTP 200 +E4 GET the key after : {"revoked":"2026-11-13T17:39:56Z","invalid":true,"expires":"2026-11-13T17:49:49Z"} HTTP 200 +E5 the device 10 s after : {"hostname":"hs-ov-we","isEphemeral":true,"tags":["tag:server"],"connectedToControl":true,"keyExpiryDisabled":true} HTTP 200 +E6 the node itself : {"BackendState": "Running", "AuthURL": "", "KeyExpiry": null, "Online": true, "Expired": null, "Health": []} +E7 the node after a restart of tailscaled : {"BackendState": "Running", "AuthURL": "", "KeyExpiry": null, "Online": true, "Expired": null, "Health": []} +E8 the device after the restart : {"hostname":"hs-ov-we","isEphemeral":true,"tags":["tag:server"],"connectedToControl":true,"keyExpiryDisabled":true} HTTP 200 +E9 DELETE the key again : null HTTP 200 +E10 a second node tries to join with the deleted key : {"upExit": 1, "upSays": "backend error: invalid key: API key krczVbN4pV11CNTRL not valid", "node": "NeedsLogin", "deviceMade": false} + +## W-S. Joins with a spent single-use key and with an expired key +S1 a single-use key after a node used it : {"created":"2026-11-13T17:40:34Z","revoked":"2026-11-13T17:40:35Z","invalid":true,"expires":"2026-11-13T17:50:34Z"} HTTP 200 +S2 the device that used it : {"created":"2026-11-13T17:40:35Z","hostname":"hs-ov-ws"} HTTP 200 +S3 a second node tries to join with the spent key : {"upExit": 1, "upSays": "backend error: invalid key: API key kgjZd2wqfb11CNTRL not valid", "node": "NeedsLogin", "deviceMade": false} +S4 a key 6 s after create, expirySeconds 3 : {"created":"2026-11-13T17:40:43Z","revoked":null,"invalid":true,"expires":"2026-11-13T17:40:46Z"} HTTP 200 +S5 a node tries to join with the expired key : {"upExit": 1, "upSays": "backend error: invalid key: API key kyWr6a82KM11CNTRL not valid", "node": "NeedsLogin", "deviceMade": false} +S6 DELETE the expired key : null HTTP 200 +S7 GET it after : {"revoked":"2026-11-13T17:40:53Z","invalid":true,"expires":"2026-11-13T17:40:46Z"} HTTP 200 + +## W-D. Which description texts are refused (auth key, expirySeconds 30) +D description 'plain text 123' : {"stored":"plain text 123"} HTTP 200 +D description 'a-b' : {"stored":"a-b"} HTTP 200 +D description 'a_b' : {"stored":"a_b"} HTTP 200 +D description 'a.b' : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'a:b' : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'a+b' : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'a,b' : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'a/b' : {"message":"keys: description had invalid characters"} HTTP 400 +D description "a'b" : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'a@b' : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'a(b)' : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'a=b' : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'a#b' : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'ünï' : {"message":"keys: description had invalid characters"} HTTP 400 +D description 'a\tb' : {"stored":"a\tb"} HTTP 200 +D description '' : {"stored":"absent"} HTTP 200 + +## cleanup: only what this probe made, by ID + device 8799678617885445: DELETE -> 200 + device 5729389185110159: DELETE -> 200 + krczVbN4pV11CNTRL: HTTP 200, revoked or invalid already; left + kgjZd2wqfb11CNTRL: HTTP 200, revoked or invalid already; left + kyWr6a82KM11CNTRL: HTTP 200, revoked or invalid already; left + DELETE kN3zQdqvLT11CNTRL -> 200 + DELETE k4HzJqzUDS11CNTRL -> 200 + DELETE kJmKBQS3g711CNTRL -> 200 + DELETE kLyxVGUka521CNTRL -> 200 + DELETE kDLMk3nYcy11CNTRL -> 200 +done 2026-11-13T17:41:09Z