Class: Cerbos::Input::Principal
- Inherits:
-
Object
- Object
- Cerbos::Input::Principal
- Defined in:
- lib/cerbos/input/principal.rb
Overview
A principal (often a user, but potentially another actor like a service account) to authorize.
Instance Attribute Summary collapse
-
#attr ⇒ Attributes
readonly
Application-specific attributes describing the principal.
-
#id ⇒ String
readonly
A unique identifier for the principal.
-
#policy_version ⇒ String?
readonly
The policy version to use when authorizing the principal.
-
#roles ⇒ Array<String>
readonly
The roles held by the principal.
-
#scope ⇒ String?
readonly
The policy scope to use when authorizing the principal.
Instance Method Summary collapse
-
#attributes ⇒ Attributes
deprecated
Deprecated.
Use #attr instead.
-
#initialize(id:, roles:, attr: {}, attributes: nil, policy_version: nil, scope: nil) ⇒ Principal
constructor
Specify a principal to authorize.
Constructor Details
#initialize(id:, roles:, attr: {}, attributes: nil, policy_version: nil, scope: nil) ⇒ Principal
Specify a principal to authorize.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cerbos/input/principal.rb', line 44 def initialize(id:, roles:, attr: {}, attributes: nil, policy_version: nil, scope: nil) unless attributes.nil? Cerbos.deprecation_warning "The `attributes` keyword argument is deprecated. Use `attr` instead." attr = attributes end @id = id @roles = roles @attr = Input.coerce_required(attr, Attributes) @policy_version = policy_version @scope = scope end |
Instance Attribute Details
#attr ⇒ Attributes (readonly)
Application-specific attributes describing the principal.
20 21 22 |
# File 'lib/cerbos/input/principal.rb', line 20 def attr @attr end |
#id ⇒ String (readonly)
A unique identifier for the principal.
10 11 12 |
# File 'lib/cerbos/input/principal.rb', line 10 def id @id end |
#policy_version ⇒ String? (readonly)
The policy version to use when authorizing the principal.
26 27 28 |
# File 'lib/cerbos/input/principal.rb', line 26 def policy_version @policy_version end |
#roles ⇒ Array<String> (readonly)
The roles held by the principal.
15 16 17 |
# File 'lib/cerbos/input/principal.rb', line 15 def roles @roles end |
#scope ⇒ String? (readonly)
The policy scope to use when authorizing the principal.
34 35 36 |
# File 'lib/cerbos/input/principal.rb', line 34 def scope @scope end |
Instance Method Details
#attributes ⇒ Attributes
Deprecated.
Use #attr instead.
Application-specific attributes describing the principal.
61 62 63 64 |
# File 'lib/cerbos/input/principal.rb', line 61 def attributes Cerbos.deprecation_warning "The `attributes` method is deprecated. Use `attr` instead." attr end |