Access tokens on S2 already let you scope what a client can do: what basins and streams they have access to, what operations are allowed, and for how long.
Now you can also enforce where a token can be used from with network policies, significantly reducing the blast radius of a token getting into the wrong hands.
You can also now see where each token was recently used from, and whether those requests were accepted or denied, in the dashboard or through the metrics API.
Network policies
By default, an access token works from any network. A network policy is an allow-list you attach to a token when you issue it. Entries can be:
- IP ranges in CIDR notation (IPv4 or IPv6), for requests over the public internet
- AWS PrivateLink endpoint IDs, for requests over private networking
For example, this policy allows two public ranges and one VPC endpoint:
{
"public_net": { "cidrs": ["203.0.113.0/24", "2001:db8:1234::/48"] },
"private_net": { "aws": { "vpce_ids": ["vpce-0a1b2c3d4e5f67890"] } }
}Requests made with a bound token from anywhere else are rejected, so a token that leaks out of your infrastructure is no longer usable from outside it.
Try it
Requires CLI s2 >= 0.47, or use the dashboard under Access Tokens → Network Policies.
Create a policy, then issue a token bound to it:
$ s2 network-policy create home \
--cidr 2600:1700:a412:1260:912c:cbf0:b9ec:c676/128
$ s2 access-token issue home-laptop-001 \
--preset full-access \
--network-policy homeOr in the dashboard, where you pick the policy when issuing a token:
Policies are immutable and can be shared by many tokens. A token issued by a restricted token inherits its policy, so a restricted service can't mint itself an unrestricted one.
In this example, the home policy allows exactly one address: my laptop's IPv6 address (a /128). So the token only works from there.
Now if I try that token from somewhere else, like a cloud VM:
Over the API, the same denial is a 403:
{
"code": "network_policy_denied",
"message": "Request from 44.213.17.82 is not permitted by the token's network policy"
}See where each token was used
Every access token now records its most recent uses, whether or not it has a network policy: the source address, whether the request was accepted or denied (and why), and the user agent.
In the dashboard, the Last seen column on the access tokens page flags tokens with recent denials, and opens the details for each token:
The same data is available from the metrics API as the token-activity metric set, and from the CLI:
$ s2 get-account-metrics token-activity home-laptop-001This is handy for checking that a new policy covers all your clients before you roll it out, or for spotting a token being used from somewhere it shouldn't be.
AWS PrivateLink
If your workloads run in AWS, you can reach your basins over AWS PrivateLink and keep traffic off the public internet. Reads over private networking cost half as much as reads over the internet.
We've rewritten the setup guide, including how to send account requests over PrivateLink too. It works well as instructions for your coding agent: point it at the guide and let it set up the endpoint. Combine it with a network policy that only allows your VPC endpoint, and your tokens can't be used from anywhere else.
Network policies and token activity are available today to all S2 accounts. See the network policies docs to get started.
