Agentic Identity Framework abstracting Keycloak/OIDC complexity for AI Agents
Project description
Agentic Security
A "Convention over Configuration" Python package for adding Agentic Identity to your AI Agents.
This package abstracts away the complexity of:
- Dynamic Client Registration: Automatically registers your agent with Keycloak if no credentials exist.
- Token Exchange: Implements RFC 8693 logic to exchange user tokens for downstream service access.
- Token Verification: Provides FastAPI dependencies to validate incoming Bearer tokens.
Installation
pip install SecureAgent
Note: You may need to install from source or a private repository until published.
Usage
Initialization
Initialize the security module with your realm URL and service details.
from SecureAgent import AgentSecurity
security = AgentSecurity(
realm_url="http://localhost:8080",
service_name="my-specialist-agent",
# initial_access_token is required only for the very first run to register the client
initial_access_token="<YOUR_INITIAL_ACCESS_TOKEN>"
)
The first time this runs, it will:
- Check for
credentials.json. - If missing, use
initial_access_tokento registermy-specialist-agent. - Save the new
client_idandclient_secrettocredentials.json.
Protecting an Endpoint
Use the verify_token dependency to protect your FastAPI routes.
from fastapi import FastAPI, Depends
app = FastAPI()
@app.get("/secure-data")
def secure_endpoint(token_payload = Depends(security.verify_token)):
return {
"user": token_payload["sub"],
"message": "You have access!"
}
Exchanging Tokens (The Orchestrator Pattern)
If your agent needs to call another agent, use exchange_token.
def call_downstream_agent(user_token: str):
# Exchange the incoming user token for a token to access 'target-service'
downstream_token = security.exchange_token(
user_token=user_token,
target_client="target-service"
)
# Use the new token to make the request
# headers = {"Authorization": f"Bearer {downstream_token}"}
# requests.get(..., headers=headers)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secureagent-0.1.2.tar.gz.
File metadata
- Download URL: secureagent-0.1.2.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d90310e63a12962e3bc0c75cbb832c8b91c4384c8a3b17559706e12e3adf2aa2
|
|
| MD5 |
0bbed7fcd7b4fabfde8493fa629cfb03
|
|
| BLAKE2b-256 |
4cf22ce7c2de74e36d89dd44e2a4b98206de771918c1f89530510e2f4e5709af
|
Provenance
The following attestation bundles were made for secureagent-0.1.2.tar.gz:
Publisher:
test.yml on armstrongsam25/SecureAgent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secureagent-0.1.2.tar.gz -
Subject digest:
d90310e63a12962e3bc0c75cbb832c8b91c4384c8a3b17559706e12e3adf2aa2 - Sigstore transparency entry: 760472694
- Sigstore integration time:
-
Permalink:
armstrongsam25/SecureAgent@ab9109bffc8a40721a1ba9c45e453340914bc6d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/armstrongsam25
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@ab9109bffc8a40721a1ba9c45e453340914bc6d4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file secureagent-0.1.2-py3-none-any.whl.
File metadata
- Download URL: secureagent-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47106c4845d5c29ddf4164e8b20bcb5ee8eec0b6b314bf61f86544115f956d3e
|
|
| MD5 |
52edaa14064650d4dc54f432e1b3e0af
|
|
| BLAKE2b-256 |
d25979401b271b9ac4a328281867782832c74ce6f27828fd5edd36bc7670d009
|
Provenance
The following attestation bundles were made for secureagent-0.1.2-py3-none-any.whl:
Publisher:
test.yml on armstrongsam25/SecureAgent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secureagent-0.1.2-py3-none-any.whl -
Subject digest:
47106c4845d5c29ddf4164e8b20bcb5ee8eec0b6b314bf61f86544115f956d3e - Sigstore transparency entry: 760472701
- Sigstore integration time:
-
Permalink:
armstrongsam25/SecureAgent@ab9109bffc8a40721a1ba9c45e453340914bc6d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/armstrongsam25
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@ab9109bffc8a40721a1ba9c45e453340914bc6d4 -
Trigger Event:
push
-
Statement type: