Let machines join with a trusted issuer
A trusted issuer lets a machine join a Guard network with a short-lived token that its own platform signed. No person signs in and no secret is stored on the machine. Any platform that issues OpenID Connect tokens to its workloads can be a trusted issuer: a Kubernetes cluster, a cloud’s workload identity, or a CI system.
Use an enrollment key when the machine has no such token.
Before you begin
Section titled “Before you begin”- Guard control plane 0.33.1 or later.
- Guard client 0.24.0 or later on the machines that join, on Linux.
awctl0.45.1 or later, the console, or Terraform provider resourcesauthwise_guard_trusted_issuerandauthwise_guard_trusted_issuer_rule.- A
tenantAdminornetworkAdminrole on the Guard network, and a second factor on your account.
How a join is decided
Section titled “How a join is decided”- The machine presents a token to Guard and names the network it joins.
- Guard finds the network’s trusted issuers whose address equals the
token’s
issclaim. If two issuers share an address, the token’s key id (kid) picks the one whose keys hold it. - The token’s signature must verify with that issuer’s keys. Guard accepts tokens signed with RS256 or ES256.
- The token must be current, allowing 60 seconds of clock skew, and must live no longer than one hour from issue to expiry.
- The token’s
audclaim must contain the network’s audience,guard:tenants/TENANT/networks/NETWORK. Guard shows the exact value on the trusted issuer. - A rule of that issuer must name the token’s
subclaim exactly. The rule decides the node’s name, its node group and whether it’s ephemeral, and it stops admitting at its maximum nodes.
A token that fails any step is refused. The machine is told only that the join was refused. The network’s activity says which check failed.
A machine whose key is already a node of the network rejoins as that node. Nothing new is created.
Add a trusted issuer
Section titled “Add a trusted issuer”awctl guard context set --tenant TENANT --network NETWORKawctl guard trusted-issuers create --display-name build-system \ --issuer https://issuer.example.com --discoverawctl guard trusted-issuers describe build-systemThe issuer’s keys come from one of three places:
| Source | Use it when | Flag |
|---|---|---|
| Discover | The issuer is at a public https address that the Guard control plane can reach. Guard reads the issuer’s OpenID Connect discovery document and follows key rotations by itself: a new key is picked up at the first join that uses it, or within five minutes. | --discover |
| Upload | The control plane can’t reach the issuer. Upload the issuer’s JWKS document, and upload it again when the keys rotate. At most 16 keys and 64 KiB. Each key needs a key id and must be RSA of 2048 bits or more, or EC P-256. | --keys-file jwks.json |
| A key-source node | The control plane can’t reach the issuer, and a node of the network runs where the issuer is. The node reports the keys when they change. | --key-source-node NODE |
An issuer’s address never changes. A trusted issuer is revoked, never deleted:
awctl guard trusted-issuers revoke build-systemRevoking stops new joins. Nodes that have joined stay until you remove them. A revoked issuer can’t be changed or restored, and it keeps its name. Create a new one under a different name.
Add rules
Section titled “Add rules”Nothing joins until a rule admits its subject.
awctl guard trusted-issuers rules create build-system \ --subject ci-runner \ --node-name-prefix ci \ --node-group ci \ --ephemeralawctl guard trusted-issuers rules list build-system| Setting | Meaning |
|---|---|
| Subject | The token’s sub claim, matched exactly. There are no patterns, so a rule admits one identity. |
| Node name prefix | A DNS label of up to 32 characters. Nodes are named PREFIX-NAME, where the machine supplies NAME. Without a prefix, the trusted issuer’s display name is used. If the name is taken, Guard adds a number. |
| Node group | Every node the rule admits joins this group. The group’s grants decide what the node can reach, and the resources the group serves are served by the node. |
| Ephemeral | The node is removed when the client leaves at a clean stop, or after about an hour offline. Use it for machines that come and go. The same machine can join again afterwards. A node keeps the setting its rule had when it joined. |
| Maximum nodes | How many nodes the rule may hold at once, from 1 to 1000. The default is 100. A join past it is refused until a node is removed or you raise the maximum. |
A rule’s subject never changes. Its other settings apply to joins from then on: changing a rule’s node group doesn’t move nodes that have already joined. Deleting a rule stops new joins and leaves the nodes that joined.
Join from a machine
Section titled “Join from a machine”Token joins use awguard run, the foreground form of the client, on
Linux as root. The platform writes the machine’s token to a file:
sudo awguard run --address guard.example.com \ --network tenants/TENANT/networks/NETWORK \ --identity-token-file /var/run/secrets/tokens/guard--network is required with a token, because a token names no network.
Run the command under systemd or another supervisor. Unlike awguard up,
it doesn’t install a service.
The client reads the token once, to join, when it starts with no node
state. After that the node keeps itself joined with its own credential,
so the token only has to be valid when the machine first joins. Keep the
state directory, /var/lib/awguard: a machine that loses it joins again
with whatever token is in the file then.
Add --leave-on-stop for a machine that comes and goes, so that its
ephemeral node is removed at a clean stop.
On Kubernetes, the Guard operator does all of this for a labelled pod.
A key-source node
Section titled “A key-source node”Name a node of the same network that runs beside the issuer. The node must be persistent, and it must not have joined through this issuer. A node that joined with an enrollment key that isn’t ephemeral qualifies. An issuer that uses discover can’t have a key source.
awctl guard trusted-issuers update build-system --key-source-node NODENODE is the node’s name or its id.
Only that node’s reports are accepted, and only for the issuers that name it as their key source. A report from any other node is refused and recorded in the network’s activity. So is a report of a key id that another issuer at the same address already holds.
Guard holds a report that would remove every key the issuer has. Joins
continue with the stored keys, and describe shows the held keys. Accept
them once you know the change is real:
awctl guard trusted-issuers update build-system --adopt-held-keysUploading keys, or changing the key source, discards a held report. To
stop using a key source, set it to nothing: --key-source-node "".
Changes that need a second factor
Section titled “Changes that need a second factor”On every production install, these changes ask you to sign in again with a second factor first:
- creating, changing or revoking a trusted issuer, including its key source;
- creating, changing or deleting a rule;
- creating or revoking an enrollment key;
- issuing a join code for a node, or registering a server node without its public key.
The console asks at the moment you make the change and returns you to it.
awctl stops with STEP_UP_REQUIRED and prints the sign-in to run:
awctl auth login --acr-values "urn:authwise:acr:2 phr phrh"If you normally sign in with --issuer and --client-id, add the same
two flags here.
Reading never needs it. A service account, such as the one Terraform uses, is exempt. Approving a person’s own device isn’t in this list.
When to use an enrollment key instead
Section titled “When to use an enrollment key instead”An enrollment key is a secret that admits machines with no token of their own: a fleet image, an autoscaling group, or the Guard operator’s connectors.
awctl guard enrollment-keys create --description "web tier" \ --max-uses 20 --ttl 30d --node-group web --out web.key| Trusted issuer | Enrollment key | |
|---|---|---|
| What the machine holds | A token its platform renews | A secret you distribute |
| Who may join | One identity per rule | Anyone holding the key, up to its uses |
| Lifetime | Until you revoke the issuer or delete the rule | 1 to 90 days |
| To rotate | Nothing | Create a new key and replace it everywhere |
The key’s secret is shown once. Give it to machines in a file or the
environment, never on a command line. A key is never changed. revoke
stops further joins and leaves the nodes that joined.