Metadata-Version: 2.4
Name: agent_auth_rs
Version: 1.0.1
Summary: Agent Auth RS 校验 SDK(spec 010 P1b):MCP 资源服务器侧 access token 校验 — aud 强校验、命名空间 sub_type 策略、kid 强制 alg、未知 kid 重取限流+负缓存、WWW-Authenticate 发现头。
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/amliuyong/a-auth
Project-URL: Documentation, https://github.com/amliuyong/a-auth/blob/main/docs/RS_SDK_RELEASE.md
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Requires-Dist: pyjwt>=2.8
Requires-Dist: cryptography>=41
Provides-Extra: test
Requires-Dist: build>=1.2; extra == "test"
Requires-Dist: pytest>=7; extra == "test"
Requires-Dist: setuptools>=77; extra == "test"
Requires-Dist: wheel>=0.45; extra == "test"
Dynamic: license-file

# Agent Auth resource-server SDK

Python 3.10+ access-token verification for resource servers. Apache-2.0.

Install a qualified wheel or source distribution into an independent virtual
environment:

```bash
python -m venv .venv
.venv/bin/python -m pip install /absolute/path/to/agent_auth_rs-1.0.1-py3-none-any.whl
```

The fixed registry command is `python -m pip install agent_auth_rs==1.0.1`.
See the release guide below for verified registry availability and receipts.
The distribution name is `agent_auth_rs`; the existing Python import remains
`agent_auth_rs`.

```python
from agent_auth_rs import RsSdk, RsSdkConfig, RoutePolicy

sdk = RsSdk(RsSdkConfig(
    issuer="https://auth.example.com",
    resource_id="https://mcp.example.com",
))

def protected_resource(authorization_header):
    result = sdk.authenticate(
        authorization_header,
        RoutePolicy(require_sub_type="user", require_scopes=["read"]),
    )
    if not result.ok:
        return result.status, result.headers, None
    return 200, {}, {"subject": result.token.sub}
```

Configure the exact issuer and resource identifier of your deployment. The
SDK obtains public JWKS and rejects wrong issuer, audience, signature, expiry,
subject type and required scopes. It consumes the issued pairwise subject.

`verify_dpop_proof` is a separate helper: call it for a verified `cnf.jkt`
token with the actual method/URL/access token and maintain a replay cache using
the returned `jti`. `authenticate` does not automatically enforce DPoP.
RAR helpers and route policy evaluators only narrow access. Grant-backed RAR
requires authenticated introspection; offline JWT verification cannot promise
immediate revocation or cancel an operation already running.

Version 1.x preserves the existing public verification API. Pin versions, run
the installed-artifact qualification on upgrades, and review release notes.
This package does not obtain, store, refresh or exchange OAuth credentials.

Release and compatibility evidence:
[RS SDK release guide](https://github.com/amliuyong/a-auth/blob/main/docs/RS_SDK_RELEASE.md).
