Beispiel #1
0
 def wrapped(*args, **kwargs):
     usr_limit, proj_limit = rbac.get_limited_to(pecan.request.headers)
     # If User and Project are None, you have full access.
     if usr_limit and proj_limit:
         # since this decorator get's called out of wsme context
         # raising exception results internal error so call abort
         # for handling the error
         ex = base.ProjectNotAuthorized(proj_limit)
         pecan.core.abort(status_code=ex.code, detail=ex.msg)
     return func(*args, **kwargs)
Beispiel #2
0
 def wrapped(*args, **kwargs):
     usr_limit, proj_limit = rbac.get_limited_to(pecan.request.headers)
     # If User and Project are None, you have full access.
     if usr_limit and proj_limit:
         # since this decorator get's called out of wsme context
         # raising exception results internal error so call abort
         # for handling the error
         ex = base.ProjectNotAuthorized(proj_limit)
         pecan.core.abort(status_code=ex.code, detail=ex.msg)
     return func(*args, **kwargs)
Beispiel #3
0
def _build_rbac_query_filters():
    filters = {'t_filter': [], 'admin_proj': None}
    # Returns user_id, proj_id for non-admins
    user_id, proj_id = rbac.get_limited_to(pecan.request.headers)
    # If non-admin, filter events by user and project
    if user_id and proj_id:
        filters['t_filter'].append({"key": "project_id", "string": proj_id,
                                    "op": "eq"})
        filters['t_filter'].append({"key": "user_id", "string": user_id,
                                    "op": "eq"})
    elif not user_id and not proj_id:
        filters['admin_proj'] = pecan.request.headers.get('X-Project-Id')
    return filters
Beispiel #4
0
def _build_rbac_query_filters():
    filters = {'t_filter': [], 'admin_proj': None}
    # Returns user_id, proj_id for non-admins
    user_id, proj_id = rbac.get_limited_to(pecan.request.headers)
    # If non-admin, filter events by user and project
    if user_id and proj_id:
        filters['t_filter'].append({"key": "project_id", "string": proj_id,
                                    "op": "eq"})
        filters['t_filter'].append({"key": "user_id", "string": user_id,
                                    "op": "eq"})
    elif not user_id and not proj_id:
        filters['admin_proj'] = pecan.request.headers.get('X-Project-Id')
    return filters