Skip to main content

Module token

Module token 

Source
Expand description

The per-agent token a harness sends to the gateway in place of a model key, minted the way a container token is (container::credential): kept by digest, valid for one route, attributed to one agent. It lives for this srv launch, as the instance key an agent is launched with does.

Structs§

Grant
What a token was minted for.

Constants§

TOKEN_PREFIX
Prefix that marks a gateway token in logs and bug reports.

Functions§

current_grant_of_replaced
The agent’s current grant for a token that renew_for_account replaced, while the agent still holds one for that route: a message queued during a container agent’s first turn was set up with the token that turn then replaced. The replaced token itself is never accepted (grant_for says none); this only names whose turn it is. Gone with the agent’s token.
grant_for
renew_for_account
A gateway route’s token (the key route or a model route) for a container turn, accepted only from peer when there is one. The agent’s earlier token stops working at once unless it already holds exactly this grant (the same agent, account and address): two panes of one container agent run turns that overlap, and the second must not end the token the first is running on. A container’s token ends with the container (revoke_agent), so a recreated container, a new address or another account is always given a new one.
revoke
Ends the agent’s access to route without touching its environment: the next request is refused.
revoke_agent
Ends every token for route that was made for the agent name names: its definition id or its routing id (slug). A container is named from the agent’s id, so this is what its stop, recreation and removal can say.
revoke_agent_everywhere
revoke_agent for every route: a container’s stop, recreation or removal ends all of its agent’s gateway tokens.
revoke_agent_everywhere_older_than
revoke_agent_older_than for every route: a container’s stop ends all of its agent’s gateway tokens, model routes and the key route alike.
revoke_agent_older_than
revoke_agent for the tokens made at least min_age ago. A container that ended outside AgentMux is only heard of from Docker’s event stream, which can run behind: a token made since (for the container that took its place) is left alone.
token_for
The agent’s token for route: minted on first use and reused after, so a relaunch of the same agent keeps the token a running child still holds.
token_for_account
token_for for the key route: the token also names the account it spends, which the gateway checks against the agent’s link at every request. Asked again with another account, the same token now spends that one.
unknown_token_reason
Why a request that no token matched was refused, in words for the log and the refusal: it carried no credential, or one that is not a gateway token, or a gateway token this srv does not hold (srv started again since it was made, or the agent was moved to another account, relaunched or had its access ended). Nothing of the credential is read but its prefix. A harness shows all of these as a bare “HTTP 401 Not logged in”; this is where the difference is.