Beispiel #1
0
 def forbidden(**kw):
     raise ProcessingException(status=403, detail='forbidden')
Beispiel #2
0
 def raise_error(**kw):
     raise ProcessingException(status=500)
def handle400():
    return ProcessingException(description=STATUS_MESSAGE.BAD_REQUEST,
                               code=STATUS_CODE.ER_400)
def handle405():
    return ProcessingException(description=STATUS_MESSAGE['METHOD_NOT_ALLOWED'], code=STATUS_CODE['ER_405'])
def handle401():
    return ProcessingException(description=STATUS_MESSAGE.NOT_AUTHORIZED,
                               code=STATUS_CODE.ER_401)
def handle405():
    return ProcessingException(description=STATUS_MESSAGE.METHOD_NOT_ALLOWED,
                               code=STATUS_CODE.ER_405)
Beispiel #7
0
def auth_admin_func(instance_id=None, **kwargs):
    current_user = get_jwt_identity()
    if not current_user == "jim":

        raise ProcessingException(description='Only admins can access this view', code=401)
Beispiel #8
0
def preprocessors_check_adm_or_normal_user(instance_id=None, **kargs):
    if not (current_user.is_admin or current_user.username == instance_id):
        raise ProcessingException(description='Forbidden', code=403)
Beispiel #9
0
def is_auth_to_app_edit(*args, **kw):
     if not current_user.group.app_edit_all:
        raise ProcessingException(description='Not authenticated!', code=401)
Beispiel #10
0
def is_auth_to_user_drop(*args, **kw):
    if not current_user.group.user_drop:
        raise ProcessingException(description='Not authenticated!', code=401)
Beispiel #11
0
def auth_func(*args, **kw):
    if not login_fresh() and not current_user.is_authenticated:
        if not 'user' in session:
            raise ProcessingException(description='Not authenticated!', code=401)
Beispiel #12
0
def handle401():
    return ProcessingException(description=STATUS_MESSAGE['NOT_AUTHORIZED'], code=STATUS_CODE['ER_401'])
Beispiel #13
0
def handle400():
    return ProcessingException(description=STATUS_MESSAGE['BAD_REQUEST'], code=STATUS_CODE['ER_400'])
Beispiel #14
0
def auth(*args, **kargs):
    """
    Required API request to be authenticated
    """
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not authenticated', code=401)
Beispiel #15
0
def auth_func(**kw):
    '''Ensures api users are authenticated.'''
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not Authorized', code=401)
Beispiel #16
0
def preprocessor_check_adm(*args, **kargs):
    if not current_user.is_admin:
        raise ProcessingException(description='Forbidden', code=403)
Beispiel #17
0
def auth_func(**kw):
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not Authorized', code=401)
Beispiel #18
0
 def is_authorized(self, user, obj):
     if user.id != obj.user_id:
         raise ProcessingException(description='Not Authorized', code=401)
Beispiel #19
0
def auth_request(**kw):
    if not current_user.is_authenticated:
        user = load_user_from_request(request)
        if not user:
            raise ProcessingException(description='Not Authorized', status=401)
def handle404():
    return ProcessingException(description=STATUS_MESSAGE.NOT_FOUND,
                               code=STATUS_CODE.ER_404)
Beispiel #21
0
    def check(description, amount, content):

        if (not description) or (not amount) or (not content):
            raise ProcessingException(description='Tositteista puuttuu tietoja.')
def handle500():
    return ProcessingException(
        description=STATUS_MESSAGE.INTERNAL_SERVER_ERROR,
        code=STATUS_CODE.ER_500)
Beispiel #23
0
def authenticate(*args, **kwargs):
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not authenticated', code=401)
Beispiel #24
0
 def delete_preprocessor(self, instance_id=None, **kw):
     try:
         article = ArticleController(current_user.id).get(id=instance_id)
     except NotFound:
         raise ProcessingException(description='No such article.', code=404)
     self.is_authorized(current_user, article)
Beispiel #25
0
def handle404():
    return ProcessingException(description=STATUS_MESSAGE['NOT_FOUND'], code=STATUS_CODE['ER_404'])