Class: Amp::Servers::HTTPAuthorizedServer

Inherits:
HTTPServer show all
Defined in:
lib/amp/server/http_server.rb

Overview

HTTPAuthorizedServer

General HTTP Server that has some form of authentication. Implements user-logic methods, as every subclass will have the same interface for adding/removing users. Note: this server only provides methods for dealing with Mercurial clients. It is not a full-blown web server with a web interface to the repository. The users you add to an HTTPAuthorizedServer are the credentials a user must provide when pushing to a repository (for example), or checking out a private repository.

It is worth noting that one may serve many repositories using one server using this class. Spiffy, eh?

Direct Known Subclasses

FancyHTTPServer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.set_authenticationObject

Sets whether to use digest or basic authentication. May only be called once, for now.

Parameters:



71
72
73
74
75
76
77
78
79
# File 'lib/amp/server/http_server.rb', line 71

def self.set_authentication(manner, opts={})
  case manner.to_sym
  when :basic
    helpers Sinatra::BasicAuthorization
  when :digest
    helpers Sinatra::DigestAuthorization
  end
  def self.set_authentication; end
end

.set_permission(style, *args) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/amp/server/http_server.rb', line 55

def self.set_permission(style, *args)
  case style
  when :writer
    set_writer *args
  when :reader
    set_reader *args
  else
    raise ArgumentError.new("Unknown permission level: #{style.to_s.inspect}")
  end
end

.set_storage(*args) ⇒ Object

since you can only set the storage once…



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/amp/server/http_server.rb', line 52

def self.set_storage(manner, opts={})
  manner = manner.to_sym
  
  case manner
  when :sequel
    set :user_db_name, (opts[:user_db_name] || "users")
    extend RepoUserManagement::SequelSQLite3
  when :memory
    extend RepoUserManagement::Memory
  else
    raise "Unknown storage manner #{manner.inspect}"
  end
  
  # since you can only set the storage once...
  def self.set_storage(*args); end # this will redefine this method to do nothing
end

Instance Method Details

#reposObject



83
# File 'lib/amp/server/http_server.rb', line 83

def repos; self.class.repos; end

#usersObject



84
# File 'lib/amp/server/http_server.rb', line 84

def users; self.class.users; end