Class: GrapeTokenAuth::AuthenticationHeader

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/grape_token_auth/authentication_header.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, start_time) ⇒ AuthenticationHeader

Returns a new instance of AuthenticationHeader.



6
7
8
9
10
# File 'lib/grape_token_auth/authentication_header.rb', line 6

def initialize(data, start_time)
  @resource = data.first_authenticated_resource
  @request_start = start_time
  @data = data
end

Class Method Details

.build_auth_headers(token, uid) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/grape_token_auth/authentication_header.rb', line 17

def self.build_auth_headers(token, uid)
  {
    'access-token' => token.to_s,
    'expiry' => token.expiry.to_s,
    'client' => token.client_id.to_s,
    'token-type' => 'Bearer',
    'uid' => uid.to_s
  }
end

Instance Method Details

#headersObject



12
13
14
15
# File 'lib/grape_token_auth/authentication_header.rb', line 12

def headers
  return {} unless resource && resource.valid? && client_id && !skip_auth_headers
  auth_headers_from_resource
end