Class: Himari::Decisions::Authorization
- Defined in:
- lib/himari/decisions/authorization.rb
Defined Under Namespace
Classes: Context
Constant Summary collapse
- DEFAULT_ALLOWED_CLAIMS =
%i( sub name nickname preferred_username profile picture website email email_verified )
Instance Attribute Summary collapse
-
#allowed_claims ⇒ Object
readonly
Returns the value of attribute allowed_claims.
-
#claims ⇒ Object
readonly
Returns the value of attribute claims.
-
#lifetime ⇒ Object
Returns the value of attribute lifetime.
Attributes inherited from Base
#effect, #effect_comment, #effect_suggestion, #effect_user_facing_message, #rule_name
Instance Method Summary collapse
- #as_log ⇒ Object
-
#initialize(claims: {}, allowed_claims: DEFAULT_ALLOWED_CLAIMS, lifetime: 3600) ⇒ Authorization
constructor
A new instance of Authorization.
- #output_claims ⇒ Object
- #to_evolve_args ⇒ Object
Methods inherited from Base
#allow!, allow_effects, #continue!, #decide!, #deny!, #evolve, #set_rule_name, #skip!, #to_h, valid_effects
Constructor Details
#initialize(claims: {}, allowed_claims: DEFAULT_ALLOWED_CLAIMS, lifetime: 3600) ⇒ Authorization
Returns a new instance of Authorization.
22 23 24 25 26 27 |
# File 'lib/himari/decisions/authorization.rb', line 22 def initialize(claims: {}, allowed_claims: DEFAULT_ALLOWED_CLAIMS, lifetime: 3600) super() @claims = claims @allowed_claims = allowed_claims @lifetime = lifetime end |
Instance Attribute Details
#allowed_claims ⇒ Object (readonly)
Returns the value of attribute allowed_claims.
29 30 31 |
# File 'lib/himari/decisions/authorization.rb', line 29 def allowed_claims @allowed_claims end |
#claims ⇒ Object (readonly)
Returns the value of attribute claims.
29 30 31 |
# File 'lib/himari/decisions/authorization.rb', line 29 def claims @claims end |
#lifetime ⇒ Object
Returns the value of attribute lifetime.
30 31 32 |
# File 'lib/himari/decisions/authorization.rb', line 30 def lifetime @lifetime end |
Instance Method Details
#as_log ⇒ Object
40 41 42 |
# File 'lib/himari/decisions/authorization.rb', line 40 def as_log to_h.merge(claims: output_claims, lifetime: @lifetime&.to_i) end |
#output_claims ⇒ Object
44 45 46 |
# File 'lib/himari/decisions/authorization.rb', line 44 def output_claims claims.select { |k,_v| allowed_claims.include?(k) } end |
#to_evolve_args ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/himari/decisions/authorization.rb', line 32 def to_evolve_args { claims: @claims.dup, allowed_claims: @allowed_claims.dup, lifetime: @lifetime&.to_i, } end |