class GitLfsS3::Application

Attributes

auth_callback[R]

Public Class Methods

authentication_enabled?() click to toggle source
# File lib/git-lfs-s3/application.rb, line 12
def authentication_enabled?
  !auth_callback.nil?
end
on_authenticate(&block) click to toggle source
# File lib/git-lfs-s3/application.rb, line 8
def on_authenticate(&block)
  @auth_callback = block
end
perform_authentication(username, password) click to toggle source
# File lib/git-lfs-s3/application.rb, line 16
def perform_authentication(username, password)
  auth_callback.call(username, password)
end

Public Instance Methods

authorized?() click to toggle source
# File lib/git-lfs-s3/application.rb, line 32
def authorized?
  @auth ||=  Rack::Auth::Basic::Request.new(request.env)
  @auth.provided? && @auth.basic? && @auth.credentials && self.class.auth_callback.call(
    @auth.credentials[0], @auth.credentials[1]
  )
end
logger() click to toggle source
# File lib/git-lfs-s3/application.rb, line 27
def logger
  settings.logger
end
protected!() click to toggle source
# File lib/git-lfs-s3/application.rb, line 39
def protected!
  unless authorized?
    response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
    throw(:halt, [401, "Invalid username or password"])
  end
end