Spaces:
Sleeping
Sleeping
| import json | |
| import os | |
| KEY_FILE = "keys.json" | |
| def load_keys(): | |
| if os.path.exists(KEY_FILE): | |
| with open(KEY_FILE, "r") as f: | |
| return json.load(f) | |
| return {} | |
| def save_keys(keys): | |
| with open(KEY_FILE, "w") as f: | |
| json.dump(keys, f, indent=2) | |
| def revoke_key(key): | |
| keys = load_keys() | |
| if key in keys: | |
| del keys[key] | |
| save_keys(keys) | |
| return True | |
| return False | |
| def validate_key_format(key): | |
| return key.startswith("aw-ay-") and len(key.split("-")) == 3 |