Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.149.0"
".": "0.150.0"
}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [0.150.0](https://github.com/kernel/kernel-python-sdk/compare/v0.149.0...v0.150.0) (2026-11-19)


### Features

* add workload identity federation credentials ([#15](https://github.com/kernel/kernel-python-sdk/issues/15)) ([885ec8f](https://github.com/kernel/kernel-python-sdk/commit/885ec8f8163969fed46a6be5c0ac779edeed11b9))
* Accept `browser_id` when authorizing a Kernel card: Evervault alias cards route that browser through the card vault's proxy as soon as the cardholder enters a fresh CVC ([9d1fc90](https://github.com/kernel/kernel-python-sdk/commit/9d1fc9005ced339c660280489741d383d1d90ca7))
* Add `captcha_solver` to browser creation; `stealth` is deprecated in favor of `captcha_solver` and `proxy` ([9d1fc90](https://github.com/kernel/kernel-python-sdk/commit/9d1fc9005ced339c660280489741d383d1d90ca7))
* Add `BrowserFingerprint` records to browsers, applied at claim time ([9d1fc90](https://github.com/kernel/kernel-python-sdk/commit/9d1fc9005ced339c660280489741d383d1d90ca7))
* Add `line_items` to AgentCard card specs, passed through to checkout authorizations ([9d1fc90](https://github.com/kernel/kernel-python-sdk/commit/9d1fc9005ced339c660280489741d383d1d90ca7))
* Add workload identity, the effective policy and the service account principal to the auth context ([9d1fc90](https://github.com/kernel/kernel-python-sdk/commit/9d1fc9005ced339c660280489741d383d1d90ca7))
* Add the `source_ip` condition to API key policies ([9d1fc90](https://github.com/kernel/kernel-python-sdk/commit/9d1fc9005ced339c660280489741d383d1d90ca7))
* Replace an API key's permissions in place with `PATCH /org/api_keys/{id}`, and link API keys to service accounts ([9d1fc90](https://github.com/kernel/kernel-python-sdk/commit/9d1fc9005ced339c660280489741d383d1d90ca7))
* Document conditions in the API key reference descriptions ([760bf19](https://github.com/kernel/kernel-python-sdk/commit/760bf192ca4f4b85f95c9e9562ad02ac24417788))
* Route VGS reveal-session payment windows through their own session in egress ([cbed38d](https://github.com/kernel/kernel-python-sdk/commit/cbed38d38314834b513fa2d110440846500bbdf7))

## [0.149.0](https://github.com/kernel/kernel-python-sdk/compare/v0.148.0...v0.149.0) (2026-11-17)


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ from kernel import Kernel
client = Kernel()

browser = client.browsers.create(
fingerprint={"os": "macos"},
captcha_solver={"enabled": True},
)
print(browser.fingerprint)
print(browser.captcha_solver)
```

## File uploads
Expand Down
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Types:
```python
from kernel.types import (
BrowserAllowlistState,
BrowserCaptchaSolver,
BrowserFingerprint,
BrowserLocation,
BrowserLocationRequest,
Expand Down
70 changes: 70 additions & 0 deletions examples/workload_identity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""Example: authenticate with workload identity federation instead of an API key.

The workload trades a token from its own identity provider for a short-lived
Kernel access token. Each way of supplying that identity token is shown below;
pick the one that matches where the code runs.
"""

import os

import httpx

from kernel import (
Kernel,
IdentityTokenFile,
WorkloadIdentityCredentials,
exchange_federation_assertion,
)

FEDERATION_RULE_ID = os.environ.get("KERNEL_FEDERATION_RULE_ID", "wifr_...")


def from_environment() -> Kernel:
# With KERNEL_FEDERATION_RULE_ID set and no KERNEL_API_KEY, the client finds
# the identity token itself: KERNEL_IDENTITY_TOKEN_SOURCE (github_actions,
# gcp_metadata, aws_sts, file or env), or KERNEL_IDENTITY_TOKEN_FILE, or a
# GitHub Actions job with `permissions: id-token: write`.
return Kernel()


def from_token_file() -> Kernel:
# A Kubernetes projected service-account token. The file is read again for every exchange.
return Kernel(
credentials=WorkloadIdentityCredentials(
identity_token_provider=IdentityTokenFile("/var/run/secrets/kernel/token"),
federation_rule_id=FEDERATION_RULE_ID,
)
)


def from_callback() -> Kernel:
def fetch_identity_token() -> str:
# Called once per exchange. It has to return a newly issued token each
# time, because most identity providers' tokens can be exchanged only once.
response = httpx.post("https://idp.internal.example/token", data={"audience": "https://auth.onkernel.com"})
response.raise_for_status()
return response.text

return Kernel(
credentials=WorkloadIdentityCredentials(
identity_token_provider=fetch_identity_token,
federation_rule_id=FEDERATION_RULE_ID,
)
)


def one_shot_exchange(identity_token: str) -> None:
# For callers that want the access token itself. Nothing is cached or refreshed.
token = exchange_federation_assertion(assertion=identity_token, federation_rule_id=FEDERATION_RULE_ID)
print("issued to", token.principal, "for project", token.project_id, "until", token.expires_at)


def main() -> None:
client = from_environment()
browser = client.browsers.create()
print("created", browser.session_id)
client.browsers.delete_by_id(browser.session_id)


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "kernel"
version = "0.149.0"
version = "0.150.0"
description = "The official Python library for the kernel API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -43,6 +43,7 @@ Repository = "https://github.com/kernel/kernel-python-sdk"

[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"]
aws = ["boto3>=1.41.0"]

[tool.rye]
managed = true
Expand Down
13 changes: 13 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ attrs==25.4.0
# via nox
backports-asyncio-runner==1.2.0
# via pytest-asyncio
boto3==1.44.6
# via kernel
botocore==1.44.6
# via boto3
# via s3transfer
certifi==2026.1.4
# via httpcore
# via httpx
Expand Down Expand Up @@ -72,6 +77,9 @@ idna==3.11
importlib-metadata==8.7.1
iniconfig==2.1.0
# via pytest
jmespath==1.1.0
# via boto3
# via botocore
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
Expand Down Expand Up @@ -112,10 +120,13 @@ pytest==8.4.2
pytest-asyncio==1.2.0
pytest-xdist==3.8.0
python-dateutil==2.9.0.post0
# via botocore
# via time-machine
respx==0.22.0
rich==14.2.0
ruff==0.14.13
s3transfer==0.19.3
# via boto3
six==1.17.0
# via python-dateutil
sniffio==1.3.1
Expand All @@ -141,6 +152,8 @@ typing-extensions==4.15.0
# via virtualenv
typing-inspection==0.4.2
# via pydantic
urllib3==2.8.0
# via botocore
virtualenv==20.36.1
# via nox
yarl==1.22.0
Expand Down
16 changes: 16 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ async-timeout==5.0.1
# via aiohttp
attrs==25.4.0
# via aiohttp
boto3==1.44.6
# via kernel
botocore==1.44.6
# via boto3
# via s3transfer
certifi==2026.1.4
# via httpcore
# via httpx
Expand All @@ -49,6 +54,9 @@ idna==3.11
# via anyio
# via httpx
# via yarl
jmespath==1.1.0
# via boto3
# via botocore
multidict==6.7.0
# via aiohttp
# via yarl
Expand All @@ -59,6 +67,12 @@ pydantic==2.12.5
# via kernel
pydantic-core==2.41.5
# via pydantic
python-dateutil==2.9.0.post0
# via botocore
s3transfer==0.19.3
# via boto3
six==1.17.0
# via python-dateutil
sniffio==1.3.1
# via kernel
typing-extensions==4.15.0
Expand All @@ -72,5 +86,7 @@ typing-extensions==4.15.0
# via typing-inspection
typing-inspection==0.4.2
# via pydantic
urllib3==2.8.0
# via botocore
yarl==1.22.0
# via aiohttp
16 changes: 16 additions & 0 deletions src/kernel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@
app_registry,
export_registry,
)
from .lib.credentials import (
TokenCache as TokenCache,
AccessToken as AccessToken,
IdentityTokenFile as IdentityTokenFile,
AccessTokenProvider as AccessTokenProvider,
AWSSTSIdentityToken as AWSSTSIdentityToken,
StaticIdentityToken as StaticIdentityToken,
FederationAccessToken as FederationAccessToken,
WorkloadIdentityError as WorkloadIdentityError,
AsyncAccessTokenProvider as AsyncAccessTokenProvider,
GCPMetadataIdentityToken as GCPMetadataIdentityToken,
GitHubActionsIdentityToken as GitHubActionsIdentityToken,
WorkloadIdentityCredentials as WorkloadIdentityCredentials,
exchange_federation_assertion as exchange_federation_assertion,
async_exchange_federation_assertion as async_exchange_federation_assertion,
)
from .lib.audit_log_download import (
AuditLogDownloadError,
AuditLogDownloadResult,
Expand Down
Loading
Loading