Class: RestCore::Oauth2Header
- Inherits:
-
Object
- Object
- RestCore::Oauth2Header
show all
- Includes:
- Middleware
- Defined in:
- lib/rest-core/middleware/oauth2_header.rb
Overview
Constant Summary
Constants included
from Middleware
Middleware::UNRESERVED
Constants included
from RestCore
ASYNC, CLIENT, DRY, FAIL, HIJACK, LOG, PROMISE, REQUEST_HEADERS, REQUEST_METHOD, REQUEST_PATH, REQUEST_PAYLOAD, REQUEST_QUERY, REQUEST_URI, RESPONSE_BODY, RESPONSE_HEADERS, RESPONSE_KEY, RESPONSE_SOCKET, RESPONSE_STATUS, Simple, TIMER, Universal, VERSION
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Middleware
contain_binary?, #contain_binary?, escape, #escape, #fail, #id, included, #log, merge_hash, #merge_hash, #percent_encode, percent_encode, request_uri, #request_uri, #run, #string_keys, string_keys
Methods included from RestCore
eagerload, id
Class Method Details
.members ⇒ Object
6
|
# File 'lib/rest-core/middleware/oauth2_header.rb', line 6
def self.members; [:access_token_type, :access_token]; end
|
Instance Method Details
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/rest-core/middleware/oauth2_header.rb', line 19
def env
auth = case token = access_token(env)
when String
token
when Hash
token.map{ |(k, v)| "#{k}=\"#{v}\"" }.join(', ')
end
if auth
{'Authorization' => "#{access_token_type(env)} #{auth}"}
else
{}
end.merge(env[REQUEST_HEADERS])
end
|
#call(env, &k) ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/rest-core/middleware/oauth2_header.rb', line 9
def call env, &k
start_time = Time.now
= (env)
auth = ['Authorization']
event = Event::WithHeader.new(Time.now - start_time,
"Authorization: #{auth}") if auth
app.call(log(env.merge(REQUEST_HEADERS => ), event), &k)
end
|