Class: JSONRPC2::BasicAuth

Inherits:
HttpAuth show all
Defined in:
lib/jsonrpc2/auth.rb

Overview

HTTP Basic authentication implementation

Instance Method Summary collapse

Methods inherited from Auth

#inspect

Constructor Details

#initialize(users = nil) {|user, pass| ... } ⇒ BasicAuth

Create a BasicAuth object

Yields:

  • (user, pass)

    Username and password to authenticate

Yield Returns:

  • (Boolean)

    True if credentials are approved



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

def initialize(users=nil, &block)
  @users, @lookup = users, block
end

Instance Method Details

#browser_check(env) ⇒ true

Checks that the browser is authorised to access the API (used by HTML API introspection)



73
74
75
# File 'lib/jsonrpc2/auth.rb', line 73

def browser_check(env)
  valid?(env) or throw_401
end

#client_check(env, rpc) ⇒ true

Checks that the client is authorised to access the API



65
66
67
# File 'lib/jsonrpc2/auth.rb', line 65

def client_check(env, rpc)
  browser_check(env)
end