Delegation, revocation, and context
An SST entity can ask Auth to grant another group access to a resource, withdraw a grant, or evaluate the conditions attached to a key request. These operations answer different questions. A grant changes who may request a key. A context rule determines whether Auth will honor a particular request. Once peers have a key, its lifetime matters to both.
Grant a group access and revoke itโ
The example graph gives group Node0 a communication policy for ResourceA and privileges to grant and revoke access for Node1. It also gives Node1 the privilege to delegate access to Node3. The parent policy must be live when the grant is made. The subjectGroup and objectGroup fields in a graph identify the delegatee and resource groups. The Node.js operation uses the same group names. Example graph
- In a fresh example checkout, generate the credentials and database by running
./generateAll.sh -g configs/privilege.graphfromexamples/. Start Auth101 as described in the Auth guide. - From
entity/node/example_entities/, runnode user.js configs/net1/node0.config --privilege-json. At its prompt enterdelegateAuthority Node1 ResourceA 1*hour 10*min 1*min. Wait for theIOTAUTH_PRIVILEGEreply and checkcommunicationPolicy.actionforDelegationGrant. The example uses a requester with a permanent distribution key. - To exercise the hierarchy, start a second instance with
configs/net1/node1.configand enterdelegateAuthority Node3 ResourceA 30*min 5*min 1*min. Wait for its grant reply. At this point both groups can make a fresh group-key request forResourceA. - At the original
Node0prompt enterrevoke Node1 ResourceA. On success the action isDelegationRevoke. The result names the revoked target and lists descendant policy IDs inrevokedCascadedPolicyIDs. Auth removes the delegated policies, their lineage records, and matching keys in its own cache. A fresh request by either delegatee now requires another applicable policy.
Node.js application interfaceโ
Initialize the accessor before installing handlers. A grant completes asynchronously. In the two calls below, issue the revoke only when the application later decides to withdraw a successful grant.
const SecureCommClient = require('../accessors/SecureCommClient');
const manager = new SecureCommClient('configs/net1/node0.config');
manager.initialize();
manager.setOutputHandler('privilege', ({ communicationPolicy }) => {
console.log(communicationPolicy.action);
});
manager.setOutputHandler('error', (message) => console.error(message));
manager.performPrivilege('DelegationGrant', 'Node1', 'ResourceA',
'1*hour', '10*min', '1*min');
manager.performPrivilege('DelegationRevoke', 'Node1', 'ResourceA', null);
| Grant argument | Meaning |
|---|---|
validity | Requested duration of the new policy. Auth caps its expiration at the earlier of the parent expiration and the deadline allowed by the grantor's privilege. |
absValidity | Positive duration from session-key issuance to its absolute expiry. |
relValidity | Positive duration governing how long the peers can use a key after first use. |
Auth copies the parent's session cryptography specification into the new policy. Policy expiry, key expiry, and application actions have separate lifetimes. Revoking at Auth changes future key availability. A peer that already holds a key can continue according to its local validity checks. An application that requires an up-to-date decision before a physical action must arrange a fresh check at that point. Node.js accessor ยท Auth request handler
Context-Based Authorizationโ
In a separate example checkout, generate the topology with ./generateAll.sh -g configs/context_based.graph from examples/ and start its Auth101. The Clients to Servers communication policy has a Context field containing a JSON-encoded string. A key request supplies a JSON object under the lower-case context member of its purpose. Auth compares every named policy condition with a value in that object. Context example and expected decisions
| Rule in the example policy | Accepted values |
|---|---|
Number of People | An integer at most 3 |
Location | Classroom or Meeting Room |
Time of Day | From 09:00 through 18:00, including both endpoints |
To try the Node.js example, run the generated server and client from entity/node/example_entities/ using node server.js configs/net1/server.config and node client.js configs/net1/client.config in separate terminals. At the client prompt, initComm net1.server selects the next entry in the fixture's contextList. Close an established connection with finComm before the next attempt. For application code, set the accessor's context parameter before asking for a fresh group key.
client.setParameter('context', {
'Number of People': 3, 'Location': 'Classroom', 'Time of Day': '09:00'
});
client.provideInput('serverHostPort', { host: 'localhost', port: 21100 }, 'Servers');
In Python, a monitor can pass the observation directly to Auth using a purpose dictionary. With the generated Node JSON config, run from entity/node/example_entities/ so its relative credential paths resolve.
from iotauth import IoTAuthContext
ctx = IoTAuthContext.from_config("configs/net1/client.config")
observed = {"Number of People": 3, "Location": "Classroom", "Time of Day": "09:00"}
keys = ctx.request_session_keys(purpose={"group": "Servers", "context": observed}, count=1)
The same policy declines a request with four people, or one missing a required observation. A policy with Context: null applies the usual group authorization with no additional context condition. The verifier supports allowlists and inclusive integer or time ranges (HH:mm or HH:mm:ss). Applications choose which component supplies trustworthy, timely observations, including operator input when their policy calls for it. The example uses recorded observations. A changed reading takes effect at the next applicable key request. Verifier