コード例 #1
0
ファイル: security.py プロジェクト: AnneGilles/cone.app
def groups_callback(name, request):
    """Collect and return roles and groups for user.
    
    XXX: request caching via decorator
    """
    roles = request.environ.get('cone.app.user.roles')
    if roles:
        return roles
    roles = list()
    for impl in app_config().auth:
        try:
            user = impl.users.get(name)
        except Exception, e:
            logger.error(str(e))
            continue
        if not user:
            continue
        aggregated = set()
        for role in user.roles:
            aggregated.add('role:%s' % role)
        for group in user.groups:
            aggregated.add('group:%s' % group.name)
            for role in group.roles:
                aggregated.add('role:%s' % role)
        roles = list(aggregated)
        break
コード例 #2
0
def node_icon(request, node):
    if node.properties.icon:
        return node.properties.icon
    info = node.nodeinfo
    if not info.icon:
        return app_config().default_node_icon
    return info.icon
コード例 #3
0
ファイル: utils.py プロジェクト: bluedynamics/cone.app
def node_icon(node):
    if node.properties.icon:
        return node.properties.icon
    info = node.nodeinfo
    if not info.icon:
        return app_config().default_node_icon
    return info.icon
コード例 #4
0
ファイル: utils.py プロジェクト: AnneGilles/cone.app
def node_icon_url(request, node):
    if node.properties.icon:
        return make_url(request, resource=node.properties.icon)
    info = node.nodeinfo
    if not info.icon:
        return make_url(request, resource=app_config().default_node_icon)
    return make_url(request, resource=info.icon)
コード例 #5
0
 def nodeinfo(self):
     info = get_node_info(self.node_info_name)
     if not info:
         info = NodeInfo()
         info.title = str(self.__class__)
         info.node = self.__class__
         info.icon = app_config().default_node_icon
     return info
コード例 #6
0
 def nodeinfo(self):
     info = get_node_info(self.node_info_name)
     if not info:
         info = NodeInfo()
         info.title = str(self.__class__)
         info.node = self.__class__
         info.icon = app_config().default_node_icon
     return info
コード例 #7
0
ファイル: security.py プロジェクト: AnneGilles/cone.app
def authenticate(request, login, password):
    for impl in app_config().auth:
        try:
            if impl.users.authenticate(login, password):
                return remember(request, login)
        except Exception, e:
            msg = u"Authentication plugin %s raised an Exception while " + \
                  u"trying to authenticate: %s"
            msg = msg % (str(impl.__class__), str(e))
            logger.warning(msg)
コード例 #8
0
def search_for_principals(term):
    ret = list()
    criteria = {
        'id': term,
    }
    ugm = app_config().auth
    for user in ugm.users.search(criteria=criteria, or_search=True):
        ret.append(user)
    for group in ugm.groups.search(criteria=criteria, or_search=True):
        ret.append('group:%s' % group)
    return ret
コード例 #9
0
def principal_by_id(principal_id):
    ugm = app_config().auth
    try:
        if principal_id.startswith('group:'):
            principal = ugm.groups.get(principal_id[6:])
        else:
            principal = ugm.users.get(principal_id)
        if not principal:
            return None
        return principal
    except Exception:
        return None
コード例 #10
0
def authenticate(request, login, password):
    if ADMIN_USER and ADMIN_PASSWORD:
        if login == ADMIN_USER and password == ADMIN_PASSWORD:
            return remember(request, login)
    ugm = app_config().auth
    try:
        if ugm.users.authenticate(login, password):
            id = ugm.users.id_for_login(login)
            return remember(request, id)
    except Exception, e:
        msg = u"Authentication plugin %s raised an Exception while " + \
              u"trying to authenticate: %s"
        msg = msg % (str(ugm.__class__), str(e))
        logger.warning(msg)
コード例 #11
0
 def make_item(self, info_name, info):
     model = self.model
     request = self.request
     props = Properties()
     query = make_query(factory=info_name)
     url = make_url(request, node=model, resource='add', query=query)
     props.url = url
     target = make_url(request, node=model, query=query)
     props.target = target
     props.title = info.title
     icon = info.icon
     if not icon:
         icon = app_config().default_node_icon
     props.icon = icon
     return props
コード例 #12
0
ファイル: authoring.py プロジェクト: bluedynamics/cone.app
 def make_item(self, info_name, info):
     model = self.model
     request = self.request
     props = Properties()
     query = make_query(factory=info_name)
     url = make_url(request, node=model, resource='add', query=query)
     props.url = url
     target = make_url(request, node=model, query=query)
     props.target = target
     props.title = info.title
     icon = info.icon
     if not icon:
         icon = app_config().default_node_icon
     props.icon = icon
     return props
コード例 #13
0
def groups_callback(name, request):
    """Collect and return roles and groups for user.

    XXX: request caching via decorator
    """
    environ = request.environ
    roles = environ.get(ROLES_CACHE_KEY)
    if roles:
        return roles
    if name == ADMIN_USER:
        roles = environ[ROLES_CACHE_KEY] = [u'role:manager']
        return roles
    ugm = app_config().auth
    user = None
    try:
        user = ugm.users.get(name)
    except Exception, e:
        logger.error(str(e))
コード例 #14
0
ファイル: authoring.py プロジェクト: AnneGilles/cone.app
 def items(self):
     ret = list()
     addables = self.model.nodeinfo.addables
     if not addables:
         return ret
     for addable in addables:
         info = getNodeInfo(addable)
         if not info:
             continue
         query = make_query(factory=addable)
         url = make_url(self.request, node=self.model,
                        resource='add', query=query)
         target = make_url(self.request, node=self.model, query=query)
         props = Properties()
         props.url = url
         props.target = target
         props.title = info.title
         icon = info.icon
         if not icon:
             icon = app_config().default_node_icon
         props.icon = make_url(self.request, resource=icon)
         ret.append(props)
     return ret
コード例 #15
0
 def js(self):
     return self.resources(app_config().js)
コード例 #16
0
ファイル: layout.py プロジェクト: AnneGilles/cone.app
 def css(self):
     return app_config().css
コード例 #17
0
ファイル: layout.py プロジェクト: AnneGilles/cone.app
 def js(self):
     return app_config().js
コード例 #18
0
 def css(self):
     return self.resources(app_config().css)
コード例 #19
0
 def js(self):
     return self.resources(app_config().js)
コード例 #20
0
 def test_app_config(self):
     # Fetch application configuration
     cfg = app_config()
     self.assertTrue(isinstance(cfg, Properties))
コード例 #21
0
ファイル: test_utils.py プロジェクト: bluedynamics/cone.app
 def test_app_config(self):
     # Fetch application configuration
     cfg = app_config()
     self.assertTrue(isinstance(cfg, Properties))
コード例 #22
0
 def css(self):
     return self.resources(app_config().css)