Esempio n. 1
0
        ('GET', '/whoami', 'whoami', 'get_user_details', {'auth': True})]


controllers = {
    'whoami':  WhoamiController
}


class WhoamiAuthentication(Authentication):
    """Authentication wrapper to automatically load 'syncNode' property.

    This is a quick monkey-patch to force the baseapp authentication machinery
    into always loading the 'syncNode' attribute of a user, even if we're not
    doing full-on node checking.
    """

    def __init__(self, config):
        super(WhoamiAuthentication, self).__init__(config)
        self._orig_authenticate_user = self.backend.authenticate_user
        self.backend.authenticate_user = self._authenticate_user

    def _authenticate_user(self, user, credentials, attrs=None):
        if not attrs:
            attrs = ['syncNode']
        else:
            attrs = list(attrs) + ['syncNode']
        return self._orig_authenticate_user(user, credentials, attrs)


make_app = set_app(urls, controllers, auth_class=WhoamiAuthentication)
Esempio n. 2
0
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
"""
Application entry point.
"""
from services.baseapp import set_app
from services.wsgiauth import Authentication
from syncserver.controllers import MainController

# XXX alternatively we should use Paste composite feature here
from syncreg.wsgiapp import urls as reg_urls, controllers as reg_controllers
from syncstorage.wsgiapp import (StorageServerApp, controllers as
                                 storage_controllers, urls as storage_urls)

urls = [('GET', '/weave-delete-account', 'main', 'delete_account_form'),
        ('POST', '/weave-delete-account', 'main', 'do_delete_account')]

urls = urls + reg_urls + storage_urls
reg_controllers.update(storage_controllers)
reg_controllers['main'] = MainController

make_app = set_app(urls,
                   reg_controllers,
                   klass=StorageServerApp,
                   auth_class=Authentication)
Esempio n. 3
0
                              ('_USERNAME_', '{username:[a-zA-Z0-9._-]+}')):
        url = url.replace(pattern, replacer)
    return url


urls = [
    ('GET', _url('/user/_API_/_USERNAME_'), 'user', 'user_exists'),
    ('PUT', _url('/user/_API_/_USERNAME_'), 'user', 'create_user'),
    ('DELETE', _url('/user/_API_/_USERNAME_'), 'user', 'delete_user', _EXTRAS),
    ('GET', _url('/user/_API_/_USERNAME_/node/weave'), 'user', 'user_node'),
    ('GET', _url('/user/_API_/_USERNAME_/password_reset'), 'user',
     'password_reset'),
    ('DELETE', _url('/user/_API_/_USERNAME_/password_reset'), 'user',
     'delete_password_reset', _EXTRAS),
    ('POST', _url('/user/_API_/_USERNAME_/email'), 'user', 'change_email',
     _EXTRAS),
    ('POST', _url('/user/_API_/_USERNAME_/password'), 'user',
     'change_password'),

    # UI
    ('GET', '/weave-password-reset', 'user', 'password_reset_form'),
    ('POST', '/weave-password-reset', 'user', 'do_password_reset'),
    (('GET', 'POST'), _url('/misc/_API_/captcha_html'), 'user',
     'captcha_form'),
    # media   XXX served by Apache in real production
    ('GET', '/media/{filename}', 'static', 'get_file')
]

controllers = {'user': UserController, 'static': StaticController}
make_app = set_app(urls, controllers, auth_class=Authentication)
Esempio n. 4
0
        if request.method == "GET":
            if match.get("collection") == "meta":
                if match.get("item") == "fxa_credentials":
                    self.logger.incr(CTR_EOL_SENTINEL_READ)
        elif request.method in ("PUT", "POST"):
            if match.get("collection") == "meta":
                if match.get("item") == "fxa_credentials":
                    self.logger.incr(CTR_EOL_SENTINEL_WRITE)
        elif request.method == "DELETE":
            if should_see_eol_headers:
                self.logger.incr(CTR_EOL_CLIENT_DELETE)

        # Continue with request dispatch, ensuring that we set the appropriate
        # headers on both success and failure responses.

        supercls = super(StorageServerApp, self)
        try:
            response = supercls._dispatch_request_with_match(request, match)
        except HTTPException, response:
            if should_see_eol_headers:
                response.headers['X-Weave-Alert'] = self.eol_header_value
            raise
        else:
            if should_see_eol_headers:
                response.headers['X-Weave-Alert'] = self.eol_header_value
            return response


make_app = set_app(urls, controllers, klass=StorageServerApp,
                   auth_class=WhoAuthentication)
Esempio n. 5
0
                                'auth', 'login'),
                        ('GET', '/%s/logged_in' % VERSION,
                                'auth', 'logged_in'),
                        # Log the user out of the system
                        (('GET', 'POST'), '/%s/logout' % VERSION,
                                'auth', 'logout'),
                        #(('POST'), '/%s/verify' % VERSION,
                        #        'auth', 'verify'),
                        ('GET', '/{user:[@\w\.\-\+]+}',
                                'user', 'get_user_info'),
                        ('GET', '/%s/register' % VERSION,
                                'auth', 'registered_emails')
                        ]
                # copy the admin_urls into the standard urls.
                map(urls.append, admin_urls)
        """ Main storage """
        self.storage = get_storage(config, 'oidstorage')
        super(OIDApp, self).__init__(urls, controllers, config, auth_class)
        # __heartbeat__ is provided via the SyncServerApp base class
        # __debug__ is provided via global.debug_page in config.


def _wrap(app, config = {}, **kw):
    # Beaker session config are defined in production.ini[default].
    # Pull the config settings from oidApp.config.
    # Defining custom config here summons dragons.
    return SessionMiddleware(app, config = config)

make_app = set_app(urls, controllers, klass=OIDApp, wrapper=_wrap,
                   auth_class=OIDAuthentication)
Esempio n. 6
0
    def __init__(self, urls, controllers, config, auth_class):
        """ Main storage """
        super(NotificationServerApp, self).__init__(urls = urls,
                                                    controllers = controllers,
                                                    config = config,
                                                    auth_class =auth_class)
        # __heartbeat__ is provided via the SyncServerApp base class
        # __debug__ is provided via global.debug_page in config.

    def _get_params(self, request):
        """ monkeypatch since uStrings are returned. """
        result = {}
        if request.method in ('GET', 'DELETE'):
            dic = dict(request.GET)
            for key in dic.keys():
                result[str(key)] = str(dic[key])
        return result


def _wrap(app, config = {}, **kw):
    # Beaker session config are defined in production.ini[default].
    return SessionMiddleware(app, config = config)


make_app = set_app(urls,
                   controllers,
                   klass=NotificationServerApp,
                   wrapper=_wrap,
                   auth_class=Authentication)
Esempio n. 7
0
Application entry point.
"""
from services.baseapp import set_app, SyncServerApp

from linkdrop.controllers.docs import DocsController
from linkdrop.controllers.send import SendController
from linkdrop.controllers.account import AccountController
from linkdrop.controllers.contacts import ContactsController

urls = [('GET', '/docs', 'docs', "index"), ('POST', '/send', 'send', "send"),
        ('GET', '/account/get', 'account', "get"),
        ('GET', '/contacts/{domain}', 'contacts', "get")]

controllers = {
    'docs': DocsController,
    'send': SendController,
    'account': AccountController,
    'contacts': ContactsController
}


class SharedAuth(object):
    def __init__(self, config):
        pass

    def check(self, request, match):
        pass


make_app = set_app(urls, controllers, auth_class=SharedAuth)
Esempio n. 8
0
Application entry point.
"""
from hubsyncer.controllers import HubSyncController
from hubsyncer.controllers import hubsyncer_egg
from pkg_resources import resource_filename
from services.baseapp import set_app, SyncServerApp
import os.path

urls = [
    ('POST', '/', 'hubsync', 'sync'),
    ]

controllers = {'hubsync': HubSyncController}


class HubSyncerApp(SyncServerApp):
    """HubSyncer WSGI application"""
    def __init__(self, urls, controllers, config, auth_class=None,
                 *args, **kwargs):
        if auth_class is not None:
            raise ValueError("A HubSyncerApp's ``auth_class`` must be None.")
        # make sure var folder exists
        var_path = resource_filename(hubsyncer_egg, 'var')
        if not os.path.isdir(var_path):
            os.mkdir(var_path)
        super(HubSyncerApp, self).__init__(urls, controllers, config,
                                           auth_class, *args, **kwargs)


make_app = set_app(urls, controllers, klass=HubSyncerApp, auth_class=None)
Esempio n. 9
0
from linkdrop.controllers.docs import DocsController
from linkdrop.controllers.send import SendController
from linkdrop.controllers.account import AccountController
from linkdrop.controllers.contacts import ContactsController


urls = [
    ('GET', '/docs', 'docs', "index"),
    ('POST', '/send', 'send', "send"),
    ('GET', '/account/get', 'account', "get"),
    ('GET', '/contacts/{domain}', 'contacts', "get")]



controllers = {'docs': DocsController,
               'send': SendController,
               'account': AccountController,
               'contacts': ContactsController}


class SharedAuth(object):
    def __init__(self, config):
        pass

    def check(self, request, match):
        pass


make_app = set_app(urls, controllers,
                   auth_class=SharedAuth)