Class: Rack::Auth::Gitlabapi

Inherits:
Basic
  • Object
show all
Defined in:
lib/rack/auth/gitlabapi.rb

Defined Under Namespace

Classes: Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, config_options = {}) ⇒ Gitlabapi

Returns a new instance of Gitlabapi.



27
28
29
30
# File 'lib/rack/auth/gitlabapi.rb', line 27

def initialize(app, config_options = {})
  super(app)
  @config = Config.new(config_options)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



25
26
27
# File 'lib/rack/auth/gitlabapi.rb', line 25

def config
  @config
end

Instance Method Details

#call(env) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/rack/auth/gitlabapi.rb', line 32

def call(env)
  auth = Gitlabapi::Request.new(env)
  return unauthorized unless auth.provided?
  return bad_request unless auth.basic?
  if valid?(auth)
    env['REMOTE_USER'] = auth.username
    return @app.call(env)
  end
  unauthorized
end