Module: WP::HMAC

Defined in:
lib/wp/hmac.rb,
lib/wp/hmac/client.rb,
lib/wp/hmac/server.rb,
lib/wp/hmac/key_cabinet.rb

Defined Under Namespace

Classes: Client, KeyCabinet, MissingConfiguration, Server

Class Method Summary collapse

Class Method Details

.add_hmac_enabled_route(route_regex) ⇒ Object



24
25
26
# File 'lib/wp/hmac.rb', line 24

def self.add_hmac_enabled_route(route_regex)
  Server.hmac_enabled_routes << route_regex
end

.add_key(id:, auth_key:) ⇒ Object



20
21
22
# File 'lib/wp/hmac.rb', line 20

def self.add_key(id:, auth_key:)
  KeyCabinet.add_key(id: id, auth_key: auth_key)
end

.auth_idObject



32
33
34
35
36
# File 'lib/wp/hmac.rb', line 32

def self.auth_id
  msg = 'Set get_auth_id_for_request in the initializer'
  fail MissingConfiguration, msg unless @callable
  @callable.call
end

.configure(&block) ⇒ Object



16
17
18
# File 'lib/wp/hmac.rb', line 16

def self.configure(&block)
  instance_eval(&block)
end

.get_auth_id_for_request(callable) ⇒ Object



28
29
30
# File 'lib/wp/hmac.rb', line 28

def self.get_auth_id_for_request(callable)
  @callable = callable
end

.lookup_auth_key_with(&block) ⇒ Object



38
39
40
# File 'lib/wp/hmac.rb', line 38

def self.lookup_auth_key_with(&block)
  KeyCabinet.lookup_block = block
end

.resetObject



42
43
44
45
46
# File 'lib/wp/hmac.rb', line 42

def self.reset
  KeyCabinet.keys = {}
  KeyCabinet.lookup_block = nil
  Server.hmac_enabled_routes = []
end