Class: Steppe::Auth::Basic::SimpleUserPasswordStore

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

Overview

Simple hash-based credentials store implementation. Stores username/password pairs in memory.

Examples:

store = SimpleUserPasswordStore.new({
  'joe' => 'secret123',
  'anna' => 'password456'
})

Constant Summary collapse

HashInterface =

Interface for hash-based credentials stores (Hash[String => String]). Maps username strings to password strings.

Types::Hash[String, String]

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ SimpleUserPasswordStore

Returns a new instance of SimpleUserPasswordStore.

Parameters:

  • hash (Hash)

    Hash mapping usernames to passwords



60
61
62
# File 'lib/steppe/auth/basic.rb', line 60

def initialize(hash)
  @lookup = hash
end

Instance Method Details

#lookup(username) ⇒ String?

Retrieve a password by username.

Parameters:

  • username (String)

    The username to look up

Returns:

  • (String, nil)

    The password or nil if not found



68
# File 'lib/steppe/auth/basic.rb', line 68

def lookup(username) = @lookup[username.strip]