Exception: Verifica::AuthorizationError

Inherits:
Error
  • Object
show all
Defined in:
lib/verifica/errors.rb

Overview

Raised when #action on the given #resource isn’t allowed for authorization #subject (e.g. current user)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ AuthorizationError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AuthorizationError.



24
25
26
27
# File 'lib/verifica/errors.rb', line 24

def initialize(result)
  @result = result
  super(result.message)
end

Instance Attribute Details

#resultObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/verifica/errors.rb', line 21

def result
  @result
end

Instance Method Details

#aclAcl

Returns Access Control List returned by ACL provider registered for this #resource_type in Verifica::Authorizer.

Returns:



70
71
72
# File 'lib/verifica/errors.rb', line 70

def acl
  result.acl
end

#actionSymbol

Returns action that #subject attempted to perform on the #resource.

Returns:



65
66
67
# File 'lib/verifica/errors.rb', line 65

def action
  result.action
end

#contextHash

Returns any additional keyword arguments that have been passed to the authorization call.

Returns:

  • (Hash)

    any additional keyword arguments that have been passed to the authorization call

See Also:



75
76
77
# File 'lib/verifica/errors.rb', line 75

def context
  result.context
end

#explainString

Returns detailed, human-readable description of authorization result. Includes subject, resource, resource ACL, and explains the reason why authorization was successful or failed. Extremely useful for debugging.

Returns:

  • (String)

    detailed, human-readable description of authorization result. Includes subject, resource, resource ACL, and explains the reason why authorization was successful or failed. Extremely useful for debugging.



80
81
82
# File 'lib/verifica/errors.rb', line 80

def explain
  result.explain
end

#resourceObject

Returns resource on which #subject attempted to perform #action.

Returns:



50
51
52
# File 'lib/verifica/errors.rb', line 50

def resource
  result.resource
end

#resource_idObject

Returns resource ID returned by resource.resource_id.

Returns:

  • (Object)

    resource ID returned by resource.resource_id



60
61
62
# File 'lib/verifica/errors.rb', line 60

def resource_id
  result.resource_id
end

#resource_typeSymbol

Returns resource type returned by resource#resource_type.

Returns:

  • (Symbol)

    resource type returned by resource#resource_type



55
56
57
# File 'lib/verifica/errors.rb', line 55

def resource_type
  result.resource_type
end

#subjectObject

Returns subject of the authorization (e.g. current user, external service).

Returns:

  • (Object)

    subject of the authorization (e.g. current user, external service)



30
31
32
# File 'lib/verifica/errors.rb', line 30

def subject
  result.subject
end

#subject_idObject

Returns subject ID returned by subject.subject_id.

Returns:

  • (Object)

    subject ID returned by subject.subject_id



40
41
42
# File 'lib/verifica/errors.rb', line 40

def subject_id
  result.subject_id
end

#subject_sidsArray<String>

Returns array of subject Security Identifiers returned by subject.subject_sids.

Returns:

  • (Array<String>)

    array of subject Security Identifiers returned by subject.subject_sids



45
46
47
# File 'lib/verifica/errors.rb', line 45

def subject_sids
  result.subject_sids
end

#subject_typeSymbol?

Returns subject type returned by subject.subject_type.

Returns:

  • (Symbol, nil)

    subject type returned by subject.subject_type



35
36
37
# File 'lib/verifica/errors.rb', line 35

def subject_type
  result.subject_type
end