Skip to content

You are currently viewing documentation for0.1.0-alpha.3

Saved documentation for 0.1.0-alpha.3 (npm) / 0.1.0a2 (PyPI). Interactive tools use the current release. View latest documentation.

Enable keyless remote access

Choose the authentication boundary

Embedded Node/Python execution needs no AGINDOW credential. Your existing client still supplies vendor credentials. Keyless remote access is for an explicit HTTP execution host; a dashboard session is only for interactive account administration. Fallback API keys are an explicit compatibility or break-glass option and are never required by the embedded SDK.

PathAuthenticationSetup
Embedded SDKNo separate AGINDOW credentialConfigure the detector in your application.
Self-hosted remote executionShort-lived, sender-bound tokenUse an enabled deployment and register a workload as described below.
Fallback API keysExplicit bearer credentialOnly for a boundary that explicitly supports the granted scopes.

1. Check account and execution-host availability

Sign into the dashboard and choose your organization and Test environment. You need an active owner membership, recent authentication and a host-enabled self-service policy for an existing read connection. Registration is scoped to your verified membership; never paste a different tenant ID to select an organization. If the deployment is unconfigured or has no eligible read connection, registration is unavailable. This flow has been tested locally, not with a live deployment. Local implementations do not establish a managed public execution service. Embedded SDK use remains available without a dashboard session.

2. Generate the key locally

Run this Node script locally (for example node generate-key.mjs). It creates an Ed25519 private PEM with mode 0600 and prints only public kid/x. Never upload the private PEM, a private JWK d field or a token. For an existing key, export its public JWK locally and choose a kid. Alternatively generate with openssl genpkey -algorithm Ed25519 -out workload-private.pem under umask 077, then use Node createPrivateKey/createPublicKey to export the public JWK; never paste the PEM into the dashboard.

ts
import { generateKeyPairSync, randomUUID } from 'node:crypto';
import { writeFile } from 'node:fs/promises';
const { privateKey, publicKey } = generateKeyPairSync('ed25519');
// Refuse to overwrite an existing workload key. Keep this file out of git and model context.
await writeFile('./workload-private.pem', privateKey.export({type:'pkcs8',format:'pem'}), {mode:0o600,flag:'wx'});
console.log(JSON.stringify({kid:randomUUID(),x:publicKey.export({format:'jwk'}).x}));

3. Dashboard: Workloads → Register workload

Open Workloads, separately from Fallback API keys. Under Register workload paste the public key ID (kid) and public Ed25519 coordinate (x). Review the server-selected Test connection and read tools, then choose Review registration and Confirm create. Your session authorizes registration, not execution. It cannot authenticate /v1/token or /v1/guard. The server binds the public key to your selected organization after checking membership. Other organizations cannot read or change its workloads. Do not use the public form for live or write scopes.

4. Wait for delivery and exchange readiness

Submitted means registration is pending. Admitted means it was approved but may not have reached the execution host. Delivered means the host acknowledged that version. Exchange ready additionally checks that the current registration and token issuer can be used. A new empty assertion ledger waits six minutes. Refresh when readiness expires; pending delivery is never ready. Readiness does not prove possession of your private key or successful upstream execution.

5. Public handoff fields

Once Exchange ready is current, copy the Node handoff or use the Python helper below. Public handoff fields can be viewed again: exchange URL, guard URL, registration/client ID, kid, assertion audience, connection and tools. These are not secrets. The assertion iss/sub equal the client ID; its audience is the exact exchange URL, distinct from access-token audience agindow:guard. Keep the private key file on your workload; it is never available for retrieval in AGINDOW. A lost private key requires a replacement public key.

6. Configure the Node client

Install the published version from the pinned Node guide. Save this helper as keyless-auth.ts and use connectSelfHosted with the ready handoff values and local privateKeyFile. connectSelfHosted is this application helper, not a package export. It uses private_key_jwt with fresh two-minute assertions with fresh jti and creates a separate ephemeral DPoP signer. It does not upload the private key. No agw_* key, dashboard cookie or implicit fallback belongs in this path.

ts
import { readFile } from 'node:fs/promises';
import { createPrivateKey, randomUUID, sign } from 'node:crypto';
import { createRemoteAuth, workloadIdentity } from 'agindow';

export async function connectSelfHosted(options: {
  exchangeEndpoint: string; registration: string;
  clientId: string; kid: string; audience: string;
  privateKeyFile: string; tools: string[];
}) {
  // This is the workload's key, held outside model context and source control.
  const key = createPrivateKey(await readFile(options.privateKeyFile));
  if (key.asymmetricKeyType !== 'ed25519') throw Error('Ed25519 client key required');
  const encode = (value: object) => Buffer.from(JSON.stringify(value)).toString('base64url');
  return createRemoteAuth({
    acquire: workloadIdentity({
      exchangeEndpoint: options.exchangeEndpoint,
      registration: options.registration, tools: options.tools,
      assertion: async () => {
        const now = Math.floor(Date.now() / 1000);
        const header = encode({ alg: 'EdDSA', typ: 'JWT', kid: options.kid });
        const claims = encode({ iss: options.clientId, sub: options.clientId,
          aud: options.audience, iat: now, nbf: now, exp: now + 120, jti: randomUUID() });
        const input = header + '.' + claims;
        return input + '.' + sign(null, Buffer.from(input), key).toString('base64url');
      },
    }),
  });
}

7. Configure Python RemoteAuth

Install the pinned Python SDK and a host Ed25519 signing library. This optional example uses cryptography (install it in your workload environment); it is not an AGINDOW dependency. Save the helper as keyless_auth.py. Call connect_self_hosted with the same public handoff values and private_key_file. It prepares RemoteAuth with workload_identity and a separate ProofSigner, acquiring and refreshing outside guarded calls. The private key file remains customer-side. Close auth when finished; do not store a permanent assertion JWT.

python
from base64 import urlsafe_b64encode
from pathlib import Path
from time import time
from uuid import uuid4
import json
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from agindow import ProofSigner, RemoteAuth, workload_identity


def connect_self_hosted(*, exchange_endpoint: str, registration: str,
                        client_id: str, kid: str, audience: str,
                        private_key_file: str, tools: tuple[str, ...]) -> RemoteAuth:
    # This file is read only by the customer's workload, never uploaded.
    key = serialization.load_pem_private_key(Path(private_key_file).read_bytes(), password=None)
    if not isinstance(key, Ed25519PrivateKey):
        raise ValueError("Ed25519 client key required")

    def encode(value: object) -> str:
        return urlsafe_b64encode(json.dumps(value, separators=(",", ":")).encode()).rstrip(b"=").decode()

    def assertion() -> str:
        now = int(time())
        header = encode({"alg": "EdDSA", "typ": "JWT", "kid": kid})
        claims = encode({"iss": client_id, "sub": client_id, "aud": audience,
                         "iat": now, "nbf": now, "exp": now + 120, "jti": str(uuid4())})
        value = header + "." + claims
        signature = urlsafe_b64encode(key.sign(value.encode())).rstrip(b"=").decode()
        return value + "." + signature

    proof_key = Ed25519PrivateKey.generate()
    public_x = urlsafe_b64encode(proof_key.public_key().public_bytes(
        serialization.Encoding.Raw, serialization.PublicFormat.Raw)).rstrip(b"=").decode()
    signer = ProofSigner(public_x, proof_key.sign)
    return RemoteAuth(workload_identity(exchange_endpoint=exchange_endpoint,
                      registration=registration, tools=tools, assertion=assertion), signer)

8. Run a first read in observe mode

Node: pass auth to guardRemote(original, {tool: admittedTool, connection: admittedConnection, operation: "read", args: {}, mode: "observe"}, {endpoint: guardUrl, auth}) and close auth in finally. Python: pass RemoteEnvelope(tool=admitted_tool, connection=admitted_connection, operation="read", args={}, mode="observe") and RemoteOptions(endpoint=guard_url, auth=auth) to guard_remote(original, envelope, options), then read/close the returned response and close auth. Use a safe configured upstream read. A successful exchange alone is not a protected read; distinguish SDK fallback events from actual host dispatch. A valid auth path does not enable a detector: the statistical guest is default; configure windows to detect.

9. Rotate public key or revoke

Generate the replacement Ed25519 key locally. In Workloads select Rotate public key, paste the new public kid/x, review and confirm. Rotation is revision-bound and has no automatic key overlap; wait again for delivery/readiness before switching the workload file. Revoke workload requires the current revision and confirmation. Neither retrying an old form nor the renewal job can resurrect a revoked grant. Already-issued tokens and stale leases retain bounded residual validity: conservatively up to 66 minutes under the documented host clock assumptions, not instant invalidation. Revoking the final grant stops the profile; ask the team running your deployment to review recovery before registering again.

10. Availability and recovery

This optional flow requires a self-hosted deployment with workload registration enabled and an approved Test/read connection. If Workloads is unavailable, use the embedded SDK or request access from the team running your deployment. New scopes and stopped or expired registrations require that team’s review. Renewals preserve existing scopes and cannot extend an expired authorization. Do not attempt to restore access by replaying a registration or bypassing readiness checks.

Replay and deployment limits

Local tests exercise token exchange, proof of possession, refusal and refresh using synthetic reads. They do not establish reliability for a public deployment or an external identity provider. Restart or lost authentication state can temporarily refuse exchange and execution; refresh outside the guarded call and wait for current readiness. The standalone host keeps replay and rate-limit state process-local. A successful exchange does not configure detection, verify a write or guarantee durable outcome retrieval. Reconcile uncertain writes with the vendor before any retry.