Implementing Attribute-Based Access Control (ABAC)

1. Understanding ABAC Concepts

ElementDefinition
Subject attrsUser properties (role, department, clearance)
Resource attrsObject properties (owner, classification, tenant)
Action attrsOperation (read, write, delete)
Environment attrsContext (time, IP, MFA strength)
PolicyRule combining attributes → permit/deny

2. Defining Subject Attributes

ExampleSource
roleRBAC store
departmentHR system / IdP claim
clearanceSecurity DB
manager_ofOrg graph
tenant_idJWT claim

3. Defining Resource Attributes

ExampleDetail
owner_idFK to user
classificationpublic / confidential / secret
tenant_idMulti-tenancy isolation
departmentFor department-scoped access
statusdraft / published / archived

4. Defining Environment Attributes

AttributeUse
request_timeBusiness-hours restrictions
client_ip / geoCountry / network restriction
mfa_levelStep-up requirement
device_compliantManaged device check
risk_scoreFrom risk engine

5. Creating Access Policies

Example: OPA Rego policy

package authz

default allow = false

allow if {
  input.action == "read"
  input.resource.owner_id == input.user.id
}

allow if {
  input.action == "read"
  input.user.role == "manager"
  input.user.department == input.resource.department
}

allow if {
  input.user.role == "admin"
  input.environment.mfa_level == "strong"
}

6. Implementing Policy Decision Point

ComponentDetail
Input{subject, resource, action, environment}
Outputpermit / deny + obligations
EngineOPA, Casbin, Cedar (AWS), AuthZForce (XACML)
DeploymentSidecar, library, or central service

7. Implementing Policy Enforcement Point

Example: PEP middleware

async function enforce(req, res, next) {
  const decision = await opaClient.evaluate({
    user: req.user,
    resource: { type: "order", id: req.params.id, ...await loadOrder(req.params.id) },
    action: req.method.toLowerCase(),
    environment: { ip: req.ip, time: new Date(), mfa_level: req.user.amr }
  });
  if (!decision.allow) return res.status(403).end();
  next();
}

8. Using Policy Language

LanguageTool
RegoOpen Policy Agent
CedarAWS Verified Permissions
XACMLIndustry XML standard (verbose)
CELGoogle — embedded in gRPC, Kubernetes
Casbin DSLMulti-language (Go, Node, Java, Python)

9. Implementing Dynamic Authorization

TriggerAction
Resource attr changeRe-evaluate active sessions
Policy updatePush to all PDPs (bundles in OPA)
Risk signalAdapt decision in real time
Time-basedAuto-allow/deny based on schedule

10. Combining ABAC with RBAC

PatternUse
RBAC for coarseRole grants base capability
ABAC for fineAttributes refine per-instance access
ExampleRole "editor" + attribute "owner=self"
Hybrid modelsReBAC (Google Zanzibar) for relationships