Пример #1
0
def verify_api_key(key, method):
    perm = db.is_key_valid(key)
    if not perm:
        raise AuthError("API key '%s' is invalid" % key)
    if method in ['POST', 'DELETE'] and perm != 'read-write':
        raise Forbidden("%s method requires 'read-write' API Key" % method)
    db.update_key(key)
Пример #2
0
def verify_api_key(key, method):
    key_info = db.is_key_valid(key)
    if not key_info:
        raise AuthError("API key '%s' is invalid" % key)
    if method in ["POST", "PUT", "DELETE"] and key_info["type"] != "read-write":
        raise Forbidden("%s method requires 'read-write' API Key" % method)
    db.update_key(key)
    return key_info
Пример #3
0
def verify_api_key(key, method):
    key_info = db.is_key_valid(key)
    if not key_info:
        raise AuthError("API key '%s' is invalid" % key)
    if method in ['POST', 'PUT', 'DELETE'] and key_info['type'] != 'read-write':
        raise Forbidden("%s method requires 'read-write' API Key" % method)
    db.update_key(key)
    return key_info
Пример #4
0
def verify_api_key(key, method):
    key_info = db.is_key_valid(key)
    if not key_info:
        raise AuthError("API key '%s' is invalid" % key)
    if method in ['POST', 'PUT', 'DELETE'] and key_info['type'] != 'read-write':
        raise Forbidden("%s method requires 'read-write' API Key" % method)
    db.update_key(key)
    return key_info
Пример #5
0
def verify_api_key(key):
    key_info = db.is_key_valid(key)
    if not key_info:
        raise AuthError("API key '%s' is invalid" % key)
    db.update_key(key)
    return key_info
Пример #6
0
 def update(self, **kwargs) -> 'ApiKey':
     kwargs['expireTime'] = DateTime.parse(kwargs['expireTime']) if 'expireTime' in kwargs else None
     return ApiKey.from_db(db.update_key(self.key, **kwargs))
Пример #7
0
def verify_api_key(key):
    if not db.is_key_valid(key):
        return False
    db.update_key(key)
    return True
Пример #8
0
def verify_api_key(key):
    if not db.is_key_valid(key):
        return False
    db.update_key(key)
    return True
Пример #9
0
 def update(self, **kwargs) -> 'ApiKey':
     kwargs['expireTime'] = DateTime.parse(kwargs['expireTime']) if 'expireTime' in kwargs else None
     return ApiKey.from_db(db.update_key(self.key, **kwargs))