Sha256: 9ae962e0598e0e9febeb58334dc39366ed32d1213a66c972cc2964d935aeec3b

Contents?: true

Size: 737 Bytes

Versions: 5

Compression:

Stored size: 737 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
    config.authenticate
  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) : cfg
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git_wit-0.0.6 lib/git_wit/auth.rb
git_wit-0.0.6.pre lib/git_wit/auth.rb
git_wit-0.0.5 lib/git_wit/auth.rb
git_wit-0.0.4.pre2 lib/git_wit/auth.rb
git_wit-0.0.4.pre lib/git_wit/auth.rb