Permissions & Roles
Control access with permission lemmas
/
Permission System
Lemma supports fine-grained permissions through "permission lemmas" - credentials that grant specific access levels.
Permission Types
| Permission | Description | Use Case |
|---|---|---|
customer_access |
Standard authenticated user access | Regular users |
admin_access |
Administrative access | Site administrators |
permission_level |
Human-readable role level (for example admin) |
Site owners, API access |
Checking Permissions
JavaScript
// Get all permission credentials for this site
const permissions = await wallet.getCredentials('permission');
// Check a specific permission against current site
const hasAdmin = await wallet.hasPermission(window.location.hostname, 'admin_access');
// Read canonical permission fields from claims
for (const cred of permissions) {
const claims = cred.claims || cred.credentialSubject || {};
console.log({
permissionId: claims.permissionId,
permissionLevel: claims.permission_level,
scope: claims.scope || []
});
}