Beispiel #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)
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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))
Beispiel #7
0
def verify_api_key(key):
    if not db.is_key_valid(key):
        return False
    db.update_key(key)
    return True
Beispiel #8
0
def verify_api_key(key):
    if not db.is_key_valid(key):
        return False
    db.update_key(key)
    return True
Beispiel #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))