libbe.command.serve

Define the Serve serving BE Storage over HTTP.

See Also

libbe.storage.http : the associated client

class libbe.command.serve.AdminApp(app, users=None, url='^admin/?', *args, **kwargs)

WSGI middleware for managing users (changing passwords, usernames, etc.).

Methods

admin
data_get_boolean
data_get_id
data_get_string
error
is_head
log_request
ok_response
post_data
query_data
admin(environ, start_response)
class libbe.command.serve.AuthenticationApp(app, realm, setting='be-auth', users=None, *args, **kwargs)

WSGI middleware for handling user authentication.

Methods

authenticate
authfunc
error
log_request
authenticate(environ)

Handle user-authentication sent in the “Authorization” header.

This function implements Basic authentication as described in HTTP/1.0 specification [R1] . Do not use this module unless you are using SSL, as it transmits unencrypted passwords.

[R1]http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#BasicAA

Notes

Code based on authkit/authenticate/basic.py (c) 2005 Clark C. Evans. Released under the MIT License: http://www.opensource.org/licenses/mit-license.php

Examples

>>> users = Users()
>>> users.add_user(User('Aladdin', 'Big Al', password='open sesame'))
>>> app = AuthenticationApp(app=None, realm='Dummy Realm', users=users)
>>> app.authenticate({'HTTP_AUTHORIZATION':'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='})
'Aladdin'
>>> app.authenticate({'HTTP_AUTHORIZATION':'Basic AAAAAAAAAAAAAAAAAAAAAAAAAA=='})
authfunc(environ, username, password)
class libbe.command.serve.ExceptionApp(app, *args, **kwargs)

Some servers (e.g. cherrypy) eat app-raised exceptions.

Work around that by logging tracebacks by hand.

Methods

error
log_request
class libbe.command.serve.Serve(*args, **kwargs)

Serve bug directory storage over HTTP.

This allows you to run local be commands interfacing with remote data, transmitting file reads/writes/etc. over the network.

Command wrapper around ServerApp.

Methods

cleanup
complete
help
run
usage
class libbe.command.serve.ServerApp(storage, notify=False, **kwargs)

WSGI server for a BE Storage instance over HTTP.

RESTful WSGI request handler for serving the libbe.storage.http.HTTP backend with GET, POST, and HEAD commands. For more information on authentication and REST, see John Calcote’s Open Sourcery article

This serves files from a connected storage instance, usually a VCS-based repository located on the local machine.

Notes

The GET and HEAD requests are identical except that the HEAD request omits the actual content of the file.

Methods

add
ancestors
changed
check_login
children
commit
data_get_boolean
data_get_id
data_get_string
error
exists
get
is_head
log_request
ok_response
post_data
query_data
remove
revision_id
set
version
add(environ, start_response)
ancestors(environ, start_response)
changed(environ, start_response)
check_login(environ)
children(environ, start_response)
commit(environ, start_response)
exists(environ, start_response)
get(environ, start_response)
remove(environ, start_response)
revision_id(environ, start_response)
set(environ, start_response)
version(environ, start_response)
class libbe.command.serve.UppercaseHeaderApp(app, *args, **kwargs)

WSGI middleware that uppercases incoming HTTP headers.

From PEP 333, The start_response() Callable :

A reminder for server/gateway authors: HTTP header names are case-insensitive, so be sure to take that into consideration when examining application-supplied headers!

Methods

error
log_request
class libbe.command.serve.User(uname=None, name=None, passhash=None, password=None)

Methods

from_string
hash
set_name
set_password
valid_login
from_string(string)
hash(password)
set_name(name)
set_password(password)
valid_login(password)
class libbe.command.serve.Users(filename=None)

Methods

add_user
clear
copy
fromkeys
get
has_key
items
iteritems
iterkeys
itervalues
keys
load
pop
popitem
save
setdefault
update
valid_login
values
viewitems
viewkeys
viewvalues
add_user(user)
load()
save()
valid_login(uname, password)
class libbe.command.serve.WSGI_AppObject(*args, **kwargs)

Useful WSGI utilities for handling data (POST, QUERY) and returning responses.

Methods

data_get_boolean
data_get_id
data_get_string
error
is_head
log_request
ok_response
post_data
query_data
data_get_boolean(data, key, default=False, source='query')
data_get_id(data, key='id', default=<class 'libbe.command.serve._HandlerError'>, source='query')
data_get_string(data, key, default=None, source='query')
is_head(environ)
ok_response(environ, start_response, content, content_type='application/octet-stream', headers=[])
post_data(environ)
query_data(environ)
class libbe.command.serve.WSGI_Object(logger=None, log_level=20, log_format=None)

Utility class for WGSI clients and middleware.

For details on WGSI, see PEP 333

Methods

error
log_request
error(environ, start_response, error, message, headers=[])

Make it easy to call start_response for errors.

log_request(environ, status='-1 OK', bytes=-1)
libbe.command.serve.createCertRequest(pkey, digest='md5', **name)

Create a certificate request.

Returns the certificate request in an X509Req object.

Parameters :

pkey : PKey

The key to associate with the request.

digest : “md5” or ?

Digestion method to use for signing, default is “md5”,

`**name` : :

The name of the subject of the request, possible. Arguments are:

C

Country name

ST

State or province name

L

Locality name

O

Organization name

OU

Organizational unit name

CN

Common name

emailAddress

E-mail address

libbe.command.serve.createCertificate(req, (issuerCert, issuerKey), serial, (notBefore, notAfter), digest='md5')

Generate a certificate given a certificate request.

Returns the signed certificate in an X509 object.

Parameters :

req : :

Certificate reqeust to use

issuerCert : :

The certificate of the issuer

issuerKey : :

The private key of the issuer

serial : :

Serial number for the certificate

notBefore : :

Timestamp (relative to now) when the certificate starts being valid

notAfter : :

Timestamp (relative to now) when the certificate stops being valid

digest : :

Digest method to use for signing, default is md5

libbe.command.serve.createKeyPair(type, bits)

Create a public/private key pair.

Returns the public/private key pair in a PKey object.

Parameters :

type : TYPE_RSA or TYPE_DSA

Key type.

bits : int

Number of bits to use in the key.

libbe.command.serve.get_cert_filenames(server_name, autogenerate=True, logger=None)

Generate private key and certification filenames. get_cert_filenames(server_name) -> (pkey_filename, cert_filename)

libbe.command.serve.make_certs(server_name, logger=None)

Generate private key and certification files.

mk_certs(server_name) -> (pkey_filename, cert_filename)

libbe.command.serve.random_string(length=256)

Table Of Contents

This Page