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