An access request asks a reviewer for a role (optionally on one object, for a time) or for approval of one operation. A check that answers allow_with_approval passes once you send the approved request's id as approval:.
decision = scute.authz.check(user_id: user_id, action: "void", resource: "invoice:INV-7")if decision.needs_approval? request = scute.authz.create_request(user_id, action: "void", resource: "invoice:INV-7", reason: "Duplicate charge")end# after a reviewer approved itdecision = scute.authz.check(user_id: user_id, action: "void", resource: "invoice:INV-7", approval: request["id"])decision.allowed? # true, reason "approved"An approval is spent by the allow it produces. A second check with the same id answers allow_with_approval again, with decision.approval["error"] set to approval_not_usable. A denied request never makes a check pass.
File a request#
create_request(user_id, role: nil, action: nil, resource: nil, duration: nil, reason: nil) calls POST /v1/apps/:app_id/authz/requests.
scute.authz.create_request(user_id, role: "viewer", reason: "Reads invoices")# { "id" => "...", "kind" => "role", "status" => "pending", "role" => "viewer", ... }List requests#
requests(status: nil, user_id: nil) returns an Array from GET /v1/apps/:app_id/authz/requests.
scute.authz.requests(status: "pending")scute.authz.requests(status: "pending", user_id: user_id)Approve or deny#
decide_request(id, verdict, reviewer_id: nil, note: nil) calls POST /v1/apps/:app_id/authz/requests/:id/approve or .../deny. verdict is :approve or :deny; anything else raises ArgumentError before any call.
scute.authz.decide_request(request["id"], :approve, note: "Checked with finance")# { "status" => "approved", "decision_note" => "Checked with finance", ... }scute.authz.decide_request(request["id"], :deny, note: "No")Pass reviewer_id: (an app user id) when a person decides through your own UI. Approving a role request grants the role.