Class: Grack::Auth

Inherits:
Rack::Auth::Basic
  • Object
show all
Defined in:
lib/gitlab/backend/grack_auth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject

Returns the value of attribute env


14
15
16
# File 'lib/gitlab/backend/grack_auth.rb', line 14

def env
  @env
end

#project=(value) ⇒ Object

Sets the attribute project

Parameters:

  • value

    the value to set the attribute project to.


14
15
16
# File 'lib/gitlab/backend/grack_auth.rb', line 14

def project=(value)
  @project = value
end

#userObject

Returns the value of attribute user


14
15
16
# File 'lib/gitlab/backend/grack_auth.rb', line 14

def user
  @user
end

Instance Method Details

#call(env) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gitlab/backend/grack_auth.rb', line 16

def call(env)
  @env = env
  @request = Rack::Request.new(env)
  @auth = Request.new(env)

  @ci = false

  # Need this patch due to the rails mount
  # Need this if under RELATIVE_URL_ROOT
  unless Gitlab.config.gitlab.relative_url_root.empty?
    # If website is mounted using relative_url_root need to remove it first
    @env['PATH_INFO'] = @request.path.sub(Gitlab.config.gitlab.relative_url_root,'')
  else
    @env['PATH_INFO'] = @request.path
  end

  @env['SCRIPT_NAME'] = ""

  auth!

  lfs_response = Gitlab::Lfs::Router.new(project, @user, @request).try_call
  return lfs_response unless lfs_response.nil?

  if project && authorized_request?
    # Tell gitlab-workhorse the request is OK, and what the GL_ID is
    render_grack_auth_ok
  elsif @user.nil? && !@ci
    unauthorized
  else
    render_not_found
  end
end