Class: Cerbos::Input::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/cerbos/input/resource.rb

Overview

A resource on which to check a principal's permissions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, id:, attributes: {}, policy_version: nil, scope: nil) ⇒ Resource

Specify a resource on which to check a principal's permissions.

Parameters:

  • kind (String)

    the type of resource.

  • id (String)

    a unique identifier for the resource.

  • attributes (Attributes, Hash) (defaults to: {})

    application-specific attributes describing the resource.

  • policy_version (String, nil) (defaults to: nil)

    the policy version to use when checking the principal's permissions on the resource (nil to use the Cerbos policy decision point server's configured default version).

  • scope (String, nil) (defaults to: nil)

    the policy scope to use when checking the principal's permissions on the resource.



43
44
45
46
47
48
49
# File 'lib/cerbos/input/resource.rb', line 43

def initialize(kind:, id:, attributes: {}, policy_version: nil, scope: nil)
  @kind = kind
  @id = id
  @attributes = Input.coerce_required(attributes, Attributes)
  @policy_version = policy_version
  @scope = scope
end

Instance Attribute Details

#attributesAttributes (readonly)

Application-specific attributes describing the resource.

Returns:



20
21
22
# File 'lib/cerbos/input/resource.rb', line 20

def attributes
  @attributes
end

#idString (readonly)

A unique identifier for the resource.

Returns:

  • (String)


15
16
17
# File 'lib/cerbos/input/resource.rb', line 15

def id
  @id
end

#kindString (readonly)

The type of resource.

Returns:

  • (String)


10
11
12
# File 'lib/cerbos/input/resource.rb', line 10

def kind
  @kind
end

#policy_versionString? (readonly)

The policy version to use when checking the principal's permissions on the resource.

Returns:

  • (String)
  • (nil)

    if not provided (in which case the Cerbos policy decision point server's configured default version will be used).



26
27
28
# File 'lib/cerbos/input/resource.rb', line 26

def policy_version
  @policy_version
end

#scopeString? (readonly)

The policy scope to use when checking the principal's permissions on the resource.

Returns:

  • (String)
  • (nil)

    if not provided.

See Also:



34
35
36
# File 'lib/cerbos/input/resource.rb', line 34

def scope
  @scope
end