Module: NebulaToken::RefreshTokenStore

Included in:
MemoryRefreshTokenStore
Defined in:
lib/nebula_token.rb

Overview

The six-method storage contract ([N-16]). Ruby stores are duck-typed, so including this module is optional; it documents the contract and turns a forgotten method into a clear NotImplementedError instead of NoMethodError.

Two failure channels ([N-20]): protocol outcomes are the return values below; infrastructure failures (connection lost, timeout, constraint violation) MUST be raised. An exception propagates out of the engine and is never converted into a RefreshResult, so the caller always fails closed.

Instance Method Summary collapse

Instance Method Details

#find_by_selector(_selector) ⇒ Object

Raises:

  • (NotImplementedError)


361
362
363
# File 'lib/nebula_token.rb', line 361

def find_by_selector(_selector)
  raise NotImplementedError, 'find_by_selector(selector) -> TokenRecord | nil'
end

#insert(_record) ⇒ Object

Raises:

  • (NotImplementedError)


365
366
367
# File 'lib/nebula_token.rb', line 365

def insert(_record)
  raise NotImplementedError, 'insert(record) -> void'
end

#mark_rotated(_selector, _from_status, _rotated_at, _replaced_by_selector) ⇒ Object

Compare-and-set ([N-17]). Apply the rotation write only if the stored record's status is still from_status, and return whether it was applied:

UPDATE … SET status='rotated', rotated_at=$2, replaced_by_selector=$3
WHERE selector=$1 AND status=$4   -- and return cmd_tuples == 1

Returning true unconditionally is non-conforming: it re-opens the race in which two concurrent refreshes both mint a successor and fork the family.

Raises:

  • (NotImplementedError)


377
378
379
# File 'lib/nebula_token.rb', line 377

def mark_rotated(_selector, _from_status, _rotated_at, _replaced_by_selector)
  raise NotImplementedError, 'mark_rotated(selector, from_status, rotated_at, replaced_by_selector) -> bool'
end

#revoke_family(_family_id) ⇒ Object

Revoke every record of the family; return how many changed ([N-19]).

Raises:

  • (NotImplementedError)


387
388
389
# File 'lib/nebula_token.rb', line 387

def revoke_family(_family_id)
  raise NotImplementedError, 'revoke_family(family_id) -> Integer'
end

#revoke_if_active(_selector) ⇒ Object

Compare-and-set ([N-18]): revoke only if still active; return whether it did.

Raises:

  • (NotImplementedError)


382
383
384
# File 'lib/nebula_token.rb', line 382

def revoke_if_active(_selector)
  raise NotImplementedError, 'revoke_if_active(selector) -> bool'
end

#revoke_user(_user_id) ⇒ Object

Revoke every record of the user; return how many changed ([N-19]).

Raises:

  • (NotImplementedError)


392
393
394
# File 'lib/nebula_token.rb', line 392

def revoke_user(_user_id)
  raise NotImplementedError, 'revoke_user(user_id) -> Integer'
end