Conversation
SEA.role.grant(admin, userPub, role, opt) issues a self-contained role
token: the administrator signs { u: userPub, r: role, iat: now, exp }
with their private key. SEA.role.verify(token, adminPub) checks the
signature and expiry, returning the payload; SEA.role.has(token, role,
userPub, adminPub) is the boolean convenience check.
Tokens are verifiable anywhere the admin's public key is known, can be
stored in a 'roles node' (e.g. ~adminPub/roles/{role}) or handed
directly to users, and compose with SEA.certify for write-policy
enforcement. opt.expiry gives absolute expiry; 0/omitted = never
expires. opt.now (testing) allows clock-independent checks.
8 tests: grant/verify roundtrip, has() role+user matching, no-expiry,
wrong administrator, expired, tampered, callback style, missing args.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(sea): add
SEA.role— signed RBAC role tokensAdds a minimal, self-contained RBAC primitive: administrators issue signed role tokens that can be verified anywhere, stored in a roles node, or handed directly to users.
API
Properties
SEA.signenvelope over{ u: userPub, r: role, iat: now, exp: expiry }— unforgeable without the admin's private key.opt.expirygives an absolute expiry timestamp (checked on verify);0/omitted means the token never expires.opt.nowallows clock-independent tests.~adminPub/roles/{role}(a "roles node") for on-graph role discovery; verify before authorizing writes.SEA.certify: grant write policies to users whose role tokens you've verified.undefined.Example (roles node)
Tests
8 new tests in
test/sea/sea.js(grant/verify roundtrip,has()role+user matching, no-expiry, wrong administrator, expired, tampered, callback style, missing args). Full SEA suite: 43 passing / 1 pending / 0 failing.