Class: Steppe::Auth::Bearer::HashTokenStore

Inherits:
Object
  • Object
show all
Defined in:
lib/steppe/auth/bearer.rb

Overview

Simple hash-based token store implementation. Stores tokens in memory with their associated scopes.

Examples:

store = HashTokenStore.new({
  'abc123' => ['read:users', 'write:users'],
  'xyz789' => ['read:posts']
})

Defined Under Namespace

Classes: AccessToken

Constant Summary collapse

Interface =

Interface for hash-based token stores (Hash[String => Array]). Maps token strings to arrays of scope strings.

Types::Hash[String, Types::Array[String]]

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ HashTokenStore

Returns a new instance of HashTokenStore.

Parameters:

  • hash (Hash)

    Hash mapping token strings to scope arrays



56
57
58
# File 'lib/steppe/auth/bearer.rb', line 56

def initialize(hash)
  @lookup = hash.transform_values { |scopes| AccessToken.new(scopes) }
end

Instance Method Details

#get(token) ⇒ AccessToken?

Retrieve an access token by its token string.

Parameters:

  • token (String)

    The token string to look up

Returns:

  • (AccessToken, nil)

    The access token or nil if not found



64
65
66
# File 'lib/steppe/auth/bearer.rb', line 64

def get(token)
  @lookup[token]
end