Sha256: 53c6c794d8597531442199c0c24da38bd54a095b446b6a2bdab1d48bedce3418

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

module GitWit
  def self.user_for_authentication(username)
    if config.user_for_authentication.respond_to?(:call)
      return config.user_for_authentication.call(username)
    end
    username
  end

  def self.authenticate(user, password)
    if config.authenticate.respond_to?(:call)
      return config.authenticate.call(user, password)
    end
    false
  end

  def self.authorize_write(user, repository)
    authorize :write, user, repository
  end

  def self.authorize_read(user, repository)
    authorize :read, user, repository
  end

  def self.authorize(operation, user, repository)
    cfg = config.send "authorize_#{operation}".to_sym
    cfg.respond_to?(:call) ? cfg.call(user, repository) : false
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_wit-0.0.3 lib/git_wit/auth.rb
git_wit-0.0.2 lib/git_wit/auth.rb
git_wit-0.0.1 lib/git_wit/auth.rb