aion-protocol 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aion_protocol-2.0.0/PKG-INFO +91 -0
- aion_protocol-2.0.0/README.md +83 -0
- aion_protocol-2.0.0/aion/__init__.py +2 -0
- aion_protocol-2.0.0/aion/api.py +34 -0
- aion_protocol-2.0.0/aion/audit.py +30 -0
- aion_protocol-2.0.0/aion/authority.py +50 -0
- aion_protocol-2.0.0/aion/cli.py +37 -0
- aion_protocol-2.0.0/aion/enforce.py +12 -0
- aion_protocol-2.0.0/aion/storage.py +86 -0
- aion_protocol-2.0.0/aion/store.py +6 -0
- aion_protocol-2.0.0/aion_protocol.egg-info/PKG-INFO +91 -0
- aion_protocol-2.0.0/aion_protocol.egg-info/SOURCES.txt +18 -0
- aion_protocol-2.0.0/aion_protocol.egg-info/dependency_links.txt +1 -0
- aion_protocol-2.0.0/aion_protocol.egg-info/entry_points.txt +2 -0
- aion_protocol-2.0.0/aion_protocol.egg-info/top_level.txt +1 -0
- aion_protocol-2.0.0/pyproject.toml +19 -0
- aion_protocol-2.0.0/setup.cfg +4 -0
- aion_protocol-2.0.0/tests/test_expiry.py +22 -0
- aion_protocol-2.0.0/tests/test_replay.py +15 -0
- aion_protocol-2.0.0/tests/test_scope.py +11 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aion-protocol
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Immutable Authority Infrastructure for Autonomous AI Agents
|
|
5
|
+
Author: Sourabh Ranjan
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# AION Protocol
|
|
10
|
+
|
|
11
|
+
Immutable Authority Infrastructure for Autonomous AI Agents.
|
|
12
|
+
|
|
13
|
+
Before any AI agent can act in the world — it must be authorized.
|
|
14
|
+
AION issues, enforces, and immutably logs that authority.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## The Problem
|
|
19
|
+
|
|
20
|
+
AI agents are acting without permission systems.
|
|
21
|
+
They send emails, execute code, move data — with no cryptographic proof of who authorized them.
|
|
22
|
+
This is the core unsolved problem of the Autonomous AI Agent era.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## What AION Does
|
|
27
|
+
|
|
28
|
+
1. **Issue** — a signed authority token is created with scope + expiry
|
|
29
|
+
2. **Enforce** — agent must present token before acting
|
|
30
|
+
3. **Audit** — every action is immutably logged with hash chaining
|
|
31
|
+
|
|
32
|
+
No token = no action. Simple.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
pip install aion-protocol
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Quickstart
|
|
43
|
+
|
|
44
|
+
Issue a token:
|
|
45
|
+
aion issue ops.read
|
|
46
|
+
|
|
47
|
+
Enforce it:
|
|
48
|
+
aion enforce <jti> ops.read
|
|
49
|
+
|
|
50
|
+
Revoke it:
|
|
51
|
+
aion revoke <jti>
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## REST API
|
|
56
|
+
|
|
57
|
+
Start the server:
|
|
58
|
+
uvicorn aion.api:app --reload
|
|
59
|
+
|
|
60
|
+
Endpoints:
|
|
61
|
+
POST /issue
|
|
62
|
+
POST /enforce
|
|
63
|
+
GET /verify/{jti}
|
|
64
|
+
POST /revoke/{jti}
|
|
65
|
+
GET /health
|
|
66
|
+
|
|
67
|
+
API docs: http://127.0.0.1:8000/docs
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## What AION Prevents
|
|
72
|
+
|
|
73
|
+
- Agents acting without permission
|
|
74
|
+
- Replay attacks — consumed tokens are blocked
|
|
75
|
+
- Scope escalation — ops.read cannot enforce ops.write
|
|
76
|
+
- Silent actions — every action is logged
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Built For
|
|
81
|
+
|
|
82
|
+
The Autonomous AI Agent era.
|
|
83
|
+
When millions of agents act in the world — authority infrastructure is not optional.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Status
|
|
88
|
+
|
|
89
|
+
v2.0 — SQLite storage, REST API, 3 tests passing.
|
|
90
|
+
|
|
91
|
+
GitHub: https://github.com/Sourabh1845/aion-protocol
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# AION Protocol
|
|
2
|
+
|
|
3
|
+
Immutable Authority Infrastructure for Autonomous AI Agents.
|
|
4
|
+
|
|
5
|
+
Before any AI agent can act in the world — it must be authorized.
|
|
6
|
+
AION issues, enforces, and immutably logs that authority.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## The Problem
|
|
11
|
+
|
|
12
|
+
AI agents are acting without permission systems.
|
|
13
|
+
They send emails, execute code, move data — with no cryptographic proof of who authorized them.
|
|
14
|
+
This is the core unsolved problem of the Autonomous AI Agent era.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## What AION Does
|
|
19
|
+
|
|
20
|
+
1. **Issue** — a signed authority token is created with scope + expiry
|
|
21
|
+
2. **Enforce** — agent must present token before acting
|
|
22
|
+
3. **Audit** — every action is immutably logged with hash chaining
|
|
23
|
+
|
|
24
|
+
No token = no action. Simple.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
pip install aion-protocol
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quickstart
|
|
35
|
+
|
|
36
|
+
Issue a token:
|
|
37
|
+
aion issue ops.read
|
|
38
|
+
|
|
39
|
+
Enforce it:
|
|
40
|
+
aion enforce <jti> ops.read
|
|
41
|
+
|
|
42
|
+
Revoke it:
|
|
43
|
+
aion revoke <jti>
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## REST API
|
|
48
|
+
|
|
49
|
+
Start the server:
|
|
50
|
+
uvicorn aion.api:app --reload
|
|
51
|
+
|
|
52
|
+
Endpoints:
|
|
53
|
+
POST /issue
|
|
54
|
+
POST /enforce
|
|
55
|
+
GET /verify/{jti}
|
|
56
|
+
POST /revoke/{jti}
|
|
57
|
+
GET /health
|
|
58
|
+
|
|
59
|
+
API docs: http://127.0.0.1:8000/docs
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## What AION Prevents
|
|
64
|
+
|
|
65
|
+
- Agents acting without permission
|
|
66
|
+
- Replay attacks — consumed tokens are blocked
|
|
67
|
+
- Scope escalation — ops.read cannot enforce ops.write
|
|
68
|
+
- Silent actions — every action is logged
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Built For
|
|
73
|
+
|
|
74
|
+
The Autonomous AI Agent era.
|
|
75
|
+
When millions of agents act in the world — authority infrastructure is not optional.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Status
|
|
80
|
+
|
|
81
|
+
v2.0 — SQLite storage, REST API, 3 tests passing.
|
|
82
|
+
|
|
83
|
+
GitHub: https://github.com/Sourabh1845/aion-protocol
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from fastapi import FastAPI
|
|
2
|
+
from pydantic import BaseModel
|
|
3
|
+
from aion.authority import issue, verify, revoke
|
|
4
|
+
from aion.enforce import enforce
|
|
5
|
+
|
|
6
|
+
app = FastAPI(title="AION Protocol", version="2.0.0")
|
|
7
|
+
|
|
8
|
+
class IssueRequest(BaseModel):
|
|
9
|
+
scope: str
|
|
10
|
+
issuer: str = "root.system"
|
|
11
|
+
|
|
12
|
+
class EnforceRequest(BaseModel):
|
|
13
|
+
jti: str
|
|
14
|
+
scope: str
|
|
15
|
+
|
|
16
|
+
@app.post("/issue")
|
|
17
|
+
def issue_authority(req: IssueRequest):
|
|
18
|
+
return issue(req.scope, issuer=req.issuer)
|
|
19
|
+
|
|
20
|
+
@app.post("/enforce")
|
|
21
|
+
def enforce_authority(req: EnforceRequest):
|
|
22
|
+
return enforce(req.jti, req.scope)
|
|
23
|
+
|
|
24
|
+
@app.get("/verify/{jti}")
|
|
25
|
+
def verify_authority(jti: str, scope: str):
|
|
26
|
+
return verify(jti, scope)
|
|
27
|
+
|
|
28
|
+
@app.post("/revoke/{jti}")
|
|
29
|
+
def revoke_authority(jti: str):
|
|
30
|
+
return revoke(jti)
|
|
31
|
+
|
|
32
|
+
@app.get("/health")
|
|
33
|
+
def health():
|
|
34
|
+
return {"status": "AION is running"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import hashlib
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
AUDIT_FILE = Path(__file__).parent.parent / "storage" / "audit_log.json"
|
|
7
|
+
|
|
8
|
+
def _hash_record(record):
|
|
9
|
+
payload = json.dumps(record, sort_keys=True).encode()
|
|
10
|
+
return hashlib.sha256(payload).hexdigest()
|
|
11
|
+
|
|
12
|
+
def log(event_type, payload):
|
|
13
|
+
AUDIT_FILE.parent.mkdir(exist_ok=True)
|
|
14
|
+
|
|
15
|
+
if AUDIT_FILE.exists():
|
|
16
|
+
data = json.loads(AUDIT_FILE.read_text())
|
|
17
|
+
else:
|
|
18
|
+
data = []
|
|
19
|
+
|
|
20
|
+
prev_hash = data[-1]["hash"] if data else "GENESIS"
|
|
21
|
+
|
|
22
|
+
record = {
|
|
23
|
+
"timestamp": datetime.now(timezone.utc).isoformat(),
|
|
24
|
+
"event": event_type,
|
|
25
|
+
"payload": payload,
|
|
26
|
+
"prev_hash": prev_hash,
|
|
27
|
+
}
|
|
28
|
+
record["hash"] = _hash_record(record)
|
|
29
|
+
data.append(record)
|
|
30
|
+
AUDIT_FILE.write_text(json.dumps(data, indent=2))
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
from datetime import datetime, timedelta, timezone
|
|
3
|
+
from aion.store import save_authority, get_authority, mark_consumed, revoke_authority
|
|
4
|
+
from aion.audit import log
|
|
5
|
+
|
|
6
|
+
TTL_SECONDS = 300
|
|
7
|
+
|
|
8
|
+
def issue(scope, parent=None, policy=None, issuer="root.system"):
|
|
9
|
+
now = datetime.now(timezone.utc)
|
|
10
|
+
auth = {
|
|
11
|
+
"jti": str(uuid.uuid4()),
|
|
12
|
+
"issuer": issuer,
|
|
13
|
+
"scope": scope,
|
|
14
|
+
"parent": parent,
|
|
15
|
+
"policy": policy or {},
|
|
16
|
+
"issued_at": now.isoformat(),
|
|
17
|
+
"expires_at": (now + timedelta(seconds=TTL_SECONDS)).isoformat(),
|
|
18
|
+
"consumed": False,
|
|
19
|
+
"revoked": False,
|
|
20
|
+
}
|
|
21
|
+
save_authority(auth)
|
|
22
|
+
log("ISSUE", auth)
|
|
23
|
+
return auth
|
|
24
|
+
|
|
25
|
+
def verify(jti, scope):
|
|
26
|
+
auth = get_authority(jti)
|
|
27
|
+
|
|
28
|
+
if not auth:
|
|
29
|
+
return {"error": "NOT_FOUND"}
|
|
30
|
+
if auth["revoked"]:
|
|
31
|
+
log("VERIFY_FAIL", {"jti": jti, "reason": "REVOKED"})
|
|
32
|
+
return {"error": "REVOKED"}
|
|
33
|
+
if auth["consumed"]:
|
|
34
|
+
log("VERIFY_FAIL", {"jti": jti, "reason": "CONSUMED"})
|
|
35
|
+
return {"error": "CONSUMED"}
|
|
36
|
+
if auth["scope"] != scope:
|
|
37
|
+
log("VERIFY_FAIL", {"jti": jti, "reason": "SCOPE_MISMATCH"})
|
|
38
|
+
return {"error": "SCOPE_MISMATCH"}
|
|
39
|
+
if datetime.fromisoformat(auth["expires_at"]) < datetime.now(timezone.utc):
|
|
40
|
+
log("VERIFY_FAIL", {"jti": jti, "reason": "EXPIRED"})
|
|
41
|
+
return {"error": "EXPIRED"}
|
|
42
|
+
|
|
43
|
+
mark_consumed(jti)
|
|
44
|
+
log("VERIFY_OK", {"jti": jti, "scope": scope})
|
|
45
|
+
return {"status": "OK", "jti": jti, "scope": scope}
|
|
46
|
+
|
|
47
|
+
def revoke(jti):
|
|
48
|
+
revoke_authority(jti)
|
|
49
|
+
log("REVOKE", {"jti": jti})
|
|
50
|
+
return {"status": "REVOKED", "jti": jti}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import json
|
|
3
|
+
from aion.authority import issue, verify, revoke
|
|
4
|
+
from aion.enforce import enforce
|
|
5
|
+
|
|
6
|
+
def main():
|
|
7
|
+
if len(sys.argv) < 2:
|
|
8
|
+
print("Usage: aion <command> [args]")
|
|
9
|
+
print("Commands: issue <scope> | verify <jti> <scope> | enforce <jti> <scope> | revoke <jti>")
|
|
10
|
+
return
|
|
11
|
+
|
|
12
|
+
cmd = sys.argv[1]
|
|
13
|
+
|
|
14
|
+
if cmd == "issue":
|
|
15
|
+
scope = sys.argv[2] if len(sys.argv) > 2 else "default"
|
|
16
|
+
result = issue(scope)
|
|
17
|
+
print(json.dumps(result, indent=2))
|
|
18
|
+
|
|
19
|
+
elif cmd == "verify":
|
|
20
|
+
jti = sys.argv[2]
|
|
21
|
+
scope = sys.argv[3]
|
|
22
|
+
print(json.dumps(verify(jti, scope), indent=2))
|
|
23
|
+
|
|
24
|
+
elif cmd == "enforce":
|
|
25
|
+
jti = sys.argv[2]
|
|
26
|
+
scope = sys.argv[3]
|
|
27
|
+
print(json.dumps(enforce(jti, scope), indent=2))
|
|
28
|
+
|
|
29
|
+
elif cmd == "revoke":
|
|
30
|
+
jti = sys.argv[2]
|
|
31
|
+
print(json.dumps(revoke(jti), indent=2))
|
|
32
|
+
|
|
33
|
+
else:
|
|
34
|
+
print(f"Unknown command: {cmd}")
|
|
35
|
+
|
|
36
|
+
if __name__ == "__main__":
|
|
37
|
+
main()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from aion.authority import verify
|
|
2
|
+
from aion.audit import log
|
|
3
|
+
|
|
4
|
+
def enforce(jti, scope):
|
|
5
|
+
result = verify(jti, scope)
|
|
6
|
+
|
|
7
|
+
if "error" in result:
|
|
8
|
+
log("ENFORCE_DENY", result)
|
|
9
|
+
return {"error": "ENFORCEMENT_DENIED", "reason": result}
|
|
10
|
+
|
|
11
|
+
log("ENFORCE_ALLOW", result)
|
|
12
|
+
return {"status": "ENFORCED", "jti": jti, "scope": scope}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import sqlite3
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
DB_FILE = Path(__file__).parent.parent / "storage" / "aion.db"
|
|
6
|
+
|
|
7
|
+
def get_conn():
|
|
8
|
+
DB_FILE.parent.mkdir(exist_ok=True)
|
|
9
|
+
return sqlite3.connect(DB_FILE)
|
|
10
|
+
|
|
11
|
+
def init_db():
|
|
12
|
+
conn = get_conn()
|
|
13
|
+
conn.execute("""
|
|
14
|
+
CREATE TABLE IF NOT EXISTS authorities (
|
|
15
|
+
jti TEXT PRIMARY KEY,
|
|
16
|
+
issuer TEXT,
|
|
17
|
+
scope TEXT,
|
|
18
|
+
parent TEXT,
|
|
19
|
+
policy TEXT,
|
|
20
|
+
issued_at TEXT,
|
|
21
|
+
expires_at TEXT,
|
|
22
|
+
consumed INTEGER DEFAULT 0,
|
|
23
|
+
revoked INTEGER DEFAULT 0
|
|
24
|
+
)
|
|
25
|
+
""")
|
|
26
|
+
conn.execute("""
|
|
27
|
+
CREATE TABLE IF NOT EXISTS audit_log (
|
|
28
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
29
|
+
event TEXT,
|
|
30
|
+
jti TEXT,
|
|
31
|
+
scope TEXT,
|
|
32
|
+
timestamp TEXT,
|
|
33
|
+
prev_hash TEXT,
|
|
34
|
+
hash TEXT
|
|
35
|
+
)
|
|
36
|
+
""")
|
|
37
|
+
conn.commit()
|
|
38
|
+
conn.close()
|
|
39
|
+
|
|
40
|
+
def insert_authority(auth):
|
|
41
|
+
import json
|
|
42
|
+
conn = get_conn()
|
|
43
|
+
conn.execute("""
|
|
44
|
+
INSERT INTO authorities VALUES (?,?,?,?,?,?,?,?,?)
|
|
45
|
+
""", (
|
|
46
|
+
auth["jti"], auth["issuer"], auth["scope"],
|
|
47
|
+
auth.get("parent"), json.dumps(auth.get("policy", {})),
|
|
48
|
+
auth["issued_at"], auth["expires_at"],
|
|
49
|
+
int(auth["consumed"]), int(auth["revoked"])
|
|
50
|
+
))
|
|
51
|
+
conn.commit()
|
|
52
|
+
conn.close()
|
|
53
|
+
|
|
54
|
+
def get_authority(jti):
|
|
55
|
+
import json
|
|
56
|
+
conn = get_conn()
|
|
57
|
+
row = conn.execute(
|
|
58
|
+
"SELECT * FROM authorities WHERE jti=?", (jti,)
|
|
59
|
+
).fetchone()
|
|
60
|
+
conn.close()
|
|
61
|
+
if not row:
|
|
62
|
+
return None
|
|
63
|
+
return {
|
|
64
|
+
"jti": row[0], "issuer": row[1], "scope": row[2],
|
|
65
|
+
"parent": row[3], "policy": json.loads(row[4]),
|
|
66
|
+
"issued_at": row[5], "expires_at": row[6],
|
|
67
|
+
"consumed": bool(row[7]), "revoked": bool(row[8])
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
def mark_consumed(jti):
|
|
71
|
+
conn = get_conn()
|
|
72
|
+
conn.execute(
|
|
73
|
+
"UPDATE authorities SET consumed=1 WHERE jti=?", (jti,)
|
|
74
|
+
)
|
|
75
|
+
conn.commit()
|
|
76
|
+
conn.close()
|
|
77
|
+
|
|
78
|
+
def revoke_authority(jti):
|
|
79
|
+
conn = get_conn()
|
|
80
|
+
conn.execute(
|
|
81
|
+
"UPDATE authorities SET revoked=1 WHERE jti=?", (jti,)
|
|
82
|
+
)
|
|
83
|
+
conn.commit()
|
|
84
|
+
conn.close()
|
|
85
|
+
|
|
86
|
+
init_db()
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aion-protocol
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Immutable Authority Infrastructure for Autonomous AI Agents
|
|
5
|
+
Author: Sourabh Ranjan
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# AION Protocol
|
|
10
|
+
|
|
11
|
+
Immutable Authority Infrastructure for Autonomous AI Agents.
|
|
12
|
+
|
|
13
|
+
Before any AI agent can act in the world — it must be authorized.
|
|
14
|
+
AION issues, enforces, and immutably logs that authority.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## The Problem
|
|
19
|
+
|
|
20
|
+
AI agents are acting without permission systems.
|
|
21
|
+
They send emails, execute code, move data — with no cryptographic proof of who authorized them.
|
|
22
|
+
This is the core unsolved problem of the Autonomous AI Agent era.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## What AION Does
|
|
27
|
+
|
|
28
|
+
1. **Issue** — a signed authority token is created with scope + expiry
|
|
29
|
+
2. **Enforce** — agent must present token before acting
|
|
30
|
+
3. **Audit** — every action is immutably logged with hash chaining
|
|
31
|
+
|
|
32
|
+
No token = no action. Simple.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
pip install aion-protocol
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Quickstart
|
|
43
|
+
|
|
44
|
+
Issue a token:
|
|
45
|
+
aion issue ops.read
|
|
46
|
+
|
|
47
|
+
Enforce it:
|
|
48
|
+
aion enforce <jti> ops.read
|
|
49
|
+
|
|
50
|
+
Revoke it:
|
|
51
|
+
aion revoke <jti>
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## REST API
|
|
56
|
+
|
|
57
|
+
Start the server:
|
|
58
|
+
uvicorn aion.api:app --reload
|
|
59
|
+
|
|
60
|
+
Endpoints:
|
|
61
|
+
POST /issue
|
|
62
|
+
POST /enforce
|
|
63
|
+
GET /verify/{jti}
|
|
64
|
+
POST /revoke/{jti}
|
|
65
|
+
GET /health
|
|
66
|
+
|
|
67
|
+
API docs: http://127.0.0.1:8000/docs
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## What AION Prevents
|
|
72
|
+
|
|
73
|
+
- Agents acting without permission
|
|
74
|
+
- Replay attacks — consumed tokens are blocked
|
|
75
|
+
- Scope escalation — ops.read cannot enforce ops.write
|
|
76
|
+
- Silent actions — every action is logged
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Built For
|
|
81
|
+
|
|
82
|
+
The Autonomous AI Agent era.
|
|
83
|
+
When millions of agents act in the world — authority infrastructure is not optional.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Status
|
|
88
|
+
|
|
89
|
+
v2.0 — SQLite storage, REST API, 3 tests passing.
|
|
90
|
+
|
|
91
|
+
GitHub: https://github.com/Sourabh1845/aion-protocol
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
aion/__init__.py
|
|
4
|
+
aion/api.py
|
|
5
|
+
aion/audit.py
|
|
6
|
+
aion/authority.py
|
|
7
|
+
aion/cli.py
|
|
8
|
+
aion/enforce.py
|
|
9
|
+
aion/storage.py
|
|
10
|
+
aion/store.py
|
|
11
|
+
aion_protocol.egg-info/PKG-INFO
|
|
12
|
+
aion_protocol.egg-info/SOURCES.txt
|
|
13
|
+
aion_protocol.egg-info/dependency_links.txt
|
|
14
|
+
aion_protocol.egg-info/entry_points.txt
|
|
15
|
+
aion_protocol.egg-info/top_level.txt
|
|
16
|
+
tests/test_expiry.py
|
|
17
|
+
tests/test_replay.py
|
|
18
|
+
tests/test_scope.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aion
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "aion-protocol"
|
|
7
|
+
version = "2.0.0"
|
|
8
|
+
description = "Immutable Authority Infrastructure for Autonomous AI Agents"
|
|
9
|
+
authors = [{name = "Sourabh Ranjan"}]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = []
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
aion = "aion.cli:main"
|
|
16
|
+
|
|
17
|
+
[tool.setuptools.packages.find]
|
|
18
|
+
where = ["."]
|
|
19
|
+
include = ["aion*"]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from aion.authority import issue, verify
|
|
2
|
+
from aion.storage import get_conn
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
|
|
5
|
+
def test_expiry():
|
|
6
|
+
auth = issue("ops.read")
|
|
7
|
+
jti = auth["jti"]
|
|
8
|
+
|
|
9
|
+
# Manually expire karo
|
|
10
|
+
conn = get_conn()
|
|
11
|
+
conn.execute(
|
|
12
|
+
"UPDATE authorities SET expires_at=? WHERE jti=?",
|
|
13
|
+
("2020-01-01T00:00:00+00:00", jti)
|
|
14
|
+
)
|
|
15
|
+
conn.commit()
|
|
16
|
+
conn.close()
|
|
17
|
+
|
|
18
|
+
# Ab verify karo — expired hona chahiye
|
|
19
|
+
result = verify(jti, "ops.read")
|
|
20
|
+
assert result["error"] == "EXPIRED"
|
|
21
|
+
|
|
22
|
+
print("Expiry test PASSED")
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from aion.authority import issue, verify
|
|
2
|
+
|
|
3
|
+
def test_replay_attack():
|
|
4
|
+
auth = issue("ops.read")
|
|
5
|
+
jti = auth["jti"]
|
|
6
|
+
|
|
7
|
+
# Pehli baar — pass hona chahiye
|
|
8
|
+
result1 = verify(jti, "ops.read")
|
|
9
|
+
assert result1["status"] == "OK"
|
|
10
|
+
|
|
11
|
+
# Doosri baar — block hona chahiye
|
|
12
|
+
result2 = verify(jti, "ops.read")
|
|
13
|
+
assert result2["error"] == "CONSUMED"
|
|
14
|
+
|
|
15
|
+
print("Replay attack test PASSED")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from aion.authority import issue, verify
|
|
2
|
+
|
|
3
|
+
def test_scope_escalation():
|
|
4
|
+
auth = issue("ops.read")
|
|
5
|
+
jti = auth["jti"]
|
|
6
|
+
|
|
7
|
+
# ops.write maangna — block hona chahiye
|
|
8
|
+
result = verify(jti, "ops.write")
|
|
9
|
+
assert result["error"] == "SCOPE_MISMATCH"
|
|
10
|
+
|
|
11
|
+
print("Scope escalation test PASSED")
|