Class: NebulaToken::TokenRecord
- Inherits:
-
Object
- Object
- NebulaToken::TokenRecord
- Defined in:
- lib/nebula_token.rb
Overview
One row per issued token ([N-10]).
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#device_id_hash ⇒ Object
readonly
Returns the value of attribute device_id_hash.
-
#family_expires_at ⇒ Object
readonly
Returns the value of attribute family_expires_at.
-
#family_id ⇒ Object
readonly
Returns the value of attribute family_id.
-
#generation ⇒ Object
readonly
Returns the value of attribute generation.
-
#idle_expires_at ⇒ Object
readonly
Returns the value of attribute idle_expires_at.
-
#kid ⇒ Object
readonly
Returns the value of attribute kid.
-
#replaced_by_selector ⇒ Object
Returns the value of attribute replaced_by_selector.
-
#rotated_at ⇒ Object
Returns the value of attribute rotated_at.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
-
#status ⇒ Object
Returns the value of attribute status.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
-
#verifier_hash ⇒ Object
readonly
Returns the value of attribute verifier_hash.
Class Method Summary collapse
-
.integer(value) ⇒ Object
Kernel#Integer alone reads "010" as octal and "0x10" as hex; a database column is always base 10.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #dup_record ⇒ Object
-
#initialize(selector:, verifier_hash:, kid:, family_id:, generation:, user_id:, created_at:, family_expires_at:, idle_expires_at:, device_id_hash: nil, status: STATUS_ACTIVE, rotated_at: nil, replaced_by_selector: nil) ⇒ TokenRecord
constructor
rubocop:disable Metrics/ParameterLists.
-
#inspect ⇒ Object
(also: #to_s)
[N-14]/[N-46]: no secret-derived material in a debug representation.
- #revoked? ⇒ Boolean
- #rotated? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(selector:, verifier_hash:, kid:, family_id:, generation:, user_id:, created_at:, family_expires_at:, idle_expires_at:, device_id_hash: nil, status: STATUS_ACTIVE, rotated_at: nil, replaced_by_selector: nil) ⇒ TokenRecord
rubocop:disable Metrics/ParameterLists
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/nebula_token.rb', line 326 def initialize(selector:, verifier_hash:, kid:, family_id:, generation:, user_id:, created_at:, family_expires_at:, idle_expires_at:, device_id_hash: nil, status: STATUS_ACTIVE, rotated_at: nil, replaced_by_selector: nil) @selector = selector @verifier_hash = verifier_hash @kid = kid @family_id = family_id @user_id = user_id @device_id_hash = device_id_hash @replaced_by_selector = replaced_by_selector # [N-2]: timestamps and the generation counter are integers. A store that # returns them as strings (the pg gem does, by default) must not silently # produce `Integer < String` comparisons deep inside the engine. @generation = TokenRecord.integer(generation) @created_at = TokenRecord.integer(created_at) @family_expires_at = TokenRecord.integer(family_expires_at) @idle_expires_at = TokenRecord.integer(idle_expires_at) @rotated_at = rotated_at.nil? ? nil : TokenRecord.integer(rotated_at) self.status = status end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def created_at @created_at end |
#device_id_hash ⇒ Object (readonly)
Returns the value of attribute device_id_hash.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def device_id_hash @device_id_hash end |
#family_expires_at ⇒ Object (readonly)
Returns the value of attribute family_expires_at.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def family_expires_at @family_expires_at end |
#family_id ⇒ Object (readonly)
Returns the value of attribute family_id.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def family_id @family_id end |
#generation ⇒ Object (readonly)
Returns the value of attribute generation.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def generation @generation end |
#idle_expires_at ⇒ Object (readonly)
Returns the value of attribute idle_expires_at.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def idle_expires_at @idle_expires_at end |
#kid ⇒ Object (readonly)
Returns the value of attribute kid.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def kid @kid end |
#replaced_by_selector ⇒ Object
Returns the value of attribute replaced_by_selector.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def replaced_by_selector @replaced_by_selector end |
#rotated_at ⇒ Object
Returns the value of attribute rotated_at.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def rotated_at @rotated_at end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def selector @selector end |
#status ⇒ Object
Returns the value of attribute status.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def status @status end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def user_id @user_id end |
#verifier_hash ⇒ Object (readonly)
Returns the value of attribute verifier_hash.
321 322 323 |
# File 'lib/nebula_token.rb', line 321 def verifier_hash @verifier_hash end |
Class Method Details
.integer(value) ⇒ Object
Kernel#Integer alone reads "010" as octal and "0x10" as hex; a database column is always base 10.
351 352 353 |
# File 'lib/nebula_token.rb', line 351 def self.integer(value) value.is_a?(String) ? Integer(value, 10) : Integer(value) end |
Instance Method Details
#active? ⇒ Boolean
362 |
# File 'lib/nebula_token.rb', line 362 def active? = @status == STATUS_ACTIVE |
#dup_record ⇒ Object
376 377 378 |
# File 'lib/nebula_token.rb', line 376 def dup_record TokenRecord.new(**to_h) end |
#inspect ⇒ Object Also known as: to_s
[N-14]/[N-46]: no secret-derived material in a debug representation.
381 382 383 384 385 |
# File 'lib/nebula_token.rb', line 381 def inspect "#<NebulaToken::TokenRecord selector=#{@selector.inspect} kid=#{@kid.inspect} " \ "family_id=#{@family_id.inspect} user_id=#{@user_id.inspect} generation=#{@generation} " \ "status=#{@status.inspect} verifier_hash=[REDACTED] device_id_hash=[REDACTED]>" end |
#revoked? ⇒ Boolean
364 |
# File 'lib/nebula_token.rb', line 364 def revoked? = @status == STATUS_REVOKED |
#rotated? ⇒ Boolean
363 |
# File 'lib/nebula_token.rb', line 363 def rotated? = @status == STATUS_ROTATED |
#to_h ⇒ Object
366 367 368 369 370 371 372 373 374 |
# File 'lib/nebula_token.rb', line 366 def to_h { selector: @selector, verifier_hash: @verifier_hash, kid: @kid, family_id: @family_id, generation: @generation, user_id: @user_id, device_id_hash: @device_id_hash, created_at: @created_at, family_expires_at: @family_expires_at, idle_expires_at: @idle_expires_at, status: @status, rotated_at: @rotated_at, replaced_by_selector: @replaced_by_selector } end |