Module: Jsapi::Controller::Authentication::Credentials

Defined in:
lib/jsapi/controller/authentication/credentials.rb,
lib/jsapi/controller/authentication/credentials/api_key.rb,
lib/jsapi/controller/authentication/credentials/http/base.rb,
lib/jsapi/controller/authentication/credentials/http/basic.rb,
lib/jsapi/controller/authentication/credentials/http/bearer.rb

Overview

Provides classes to pass credentials to an authentication handler.

Defined Under Namespace

Modules: HTTP Classes: APIKey

Class Method Summary collapse

Class Method Details

.create(request, security_scheme) ⇒ Object

Creates credentials from request according to the specified security scheme.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jsapi/controller/authentication/credentials.rb', line 14

def create(request, security_scheme)
  case security_scheme
  when Meta::SecurityScheme::APIKey
    name = security_scheme.name
    APIKey.new(
      case security_scheme.in
      when 'header'
        request.headers[name]
      when 'query'
        request.query_parameters[name]
      end
    )
  when Meta::SecurityScheme::HTTP::Basic
    HTTP::Basic.new(request.authorization)
  when Meta::SecurityScheme::HTTP::Bearer
    HTTP::Bearer.new(request.authorization)
  when Meta::SecurityScheme::HTTP::Other
    HTTP::Base.new(request.authorization)
  end
end