class Rack::Auth::Gitlabapi
Attributes
config[R]
Public Class Methods
new(app, config_options = {})
click to toggle source
Calls superclass method
# File lib/rack/auth/gitlabapi.rb, line 27 def initialize(app, config_options = {}) super(app) @config = Config.new(config_options) end
Public Instance Methods
call(env)
click to toggle source
# 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
Private Instance Methods
user()
click to toggle source
# File lib/rack/auth/gitlabapi.rb, line 63 def user return @user end
valid?(auth)
click to toggle source
# File lib/rack/auth/gitlabapi.rb, line 45 def valid?(auth) Gitlab.configure do |config| config.endpoint = @config.endpoint config.private_token = auth.password end begin @user = Gitlab.user if @user.username == auth.username || @user.email == auth.username return true else return false end rescue return false end end