Sha256: 9ea97d6a066608e4b5443bd8aec03e21441aff9879d0eca666afdbd2fef15c46

Contents?: true

Size: 809 Bytes

Versions: 8

Compression:

Stored size: 809 Bytes

Contents

require 'rack/auth/basic'
require 'rack/auth/abstract/handler'
require 'rack/auth/abstract/request'

module Grack
  class Auth < Rack::Auth::Basic
    def call(env)
      @env = env
      @request = Rack::Request.new(env)
      @auth = Request.new(env)

      if not @auth.provided?
        unauthorized
      elsif not @auth.basic?
        bad_request
      else
        result = if (access = valid? and access == true)
          @env['REMOTE_USER'] = @auth.username
          @app.call(env)
        else
          if access == '404'
            render_not_found
          elsif access == '403'
            render_no_access
          else
            unauthorized
          end
        end
        result
      end
    end# method call

    def valid?
      false
    end
  end# class Auth
end# module Grack

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gitlab-grack-2.0.2 lib/grack/auth.rb
gitlab-grack-2.0.1 lib/grack/auth.rb
gitlab-grack-2.0.0 lib/grack/auth.rb
gitlab-grack-2.0.0.rc2 lib/grack/auth.rb
gitlab-grack-2.0.0.pre lib/grack/auth.rb
gitlab-grack-1.1.0 lib/grack/auth.rb
gitlab-grack-1.0.1 lib/grack/auth.rb
gitlab-grack-1.0.0 lib/grack/auth.rb