Class: Gitlab::APIAuthentication::TokenLocator

Inherits:
Object
  • Object
show all
Includes:
ActionController::HttpAuthentication::Basic, ActiveModel::Validations
Defined in:
lib/gitlab/api_authentication/token_locator.rb

Defined Under Namespace

Classes: UsernameAndPassword

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location) ⇒ TokenLocator

Returns a new instance of TokenLocator.


25
26
27
28
# File 'lib/gitlab/api_authentication/token_locator.rb', line 25

def initialize(location)
  @location = location
  validate!
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.


11
12
13
# File 'lib/gitlab/api_authentication/token_locator.rb', line 11

def location
  @location
end

Instance Method Details

#extract(request) ⇒ Object


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gitlab/api_authentication/token_locator.rb', line 30

def extract(request)
  case @location
  when :http_basic_auth
    extract_from_http_basic_auth request
  when :http_token
    extract_from_http_token request
  when :http_bearer_token
    extract_from_http_bearer_token request
  when :http_deploy_token_header
    extract_from_http_deploy_token_header request
  when :http_job_token_header
    extract_from_http_job_token_header request
  when :http_private_token_header
    extract_from_http_private_token_header request
  when :token_param
    extract_from_token_param request
  end
end