Exception: CurrentScope::AccessDenied

Inherits:
StandardError
  • Object
show all
Defined in:
lib/current_scope.rb

Overview

Raised when the resolver denies an action gated by Guard (or when the management UI is accessed without a full-access role). Accessors:

#permission — denied key (stable API for branded 403s). Defaults to the
            positional message when permission: is omitted so legacy
            raise sites still populate it. Prefer this over #message.
#message    — StandardError message (positional arg). Gem raise sites pass
            the key as both message and permission; they can diverge if
            a caller passes an explicit permission: keyword.
#reason     — machine-readable cause (also on X-Current-Scope-Reason)
#record     — the record under decision when the gate had one; nil for
            collection / impersonation-gate denials
#subject    — effective subject when known; nil if none was in scope

Reasons surfaced by current_scope_denied:

:sod_veto           

Every denial in the gem raises this and lands in current_scope_denied, so a denial cannot exist that forgets its reason. (:sod_bypassed is the one audited ALLOW, so it is set by the Guard rather than raised here.)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, reason: nil, permission: nil, record: nil, subject: nil) ⇒ AccessDenied



54
55
56
57
58
59
60
61
62
# File 'lib/current_scope.rb', line 54

def initialize(message = nil, reason: nil, permission: nil, record: nil, subject: nil)
  super(message)
  @reason = reason
  # permission defaults to message so older raise sites and branded-403
  # recipes that only pass the key positionally still populate #permission.
  @permission = permission || message
  @record = record
  @subject = subject
end

Instance Attribute Details

#permissionObject (readonly)

Returns the value of attribute permission.



52
53
54
# File 'lib/current_scope.rb', line 52

def permission
  @permission
end

#reasonObject (readonly)

Returns the value of attribute reason.



52
53
54
# File 'lib/current_scope.rb', line 52

def reason
  @reason
end

#recordObject (readonly)

Returns the value of attribute record.



52
53
54
# File 'lib/current_scope.rb', line 52

def record
  @record
end

#subjectObject (readonly)

Returns the value of attribute subject.



52
53
54
# File 'lib/current_scope.rb', line 52

def subject
  @subject
end