Defines and validates authentication mechanisms for event-driven APIs including API keys, OAuth2 flows, OpenID Connect, and mutual TLS across message brokers and generated client code.
Agentic Workflow: Read -> Reason -> Act (asyncapi-security)
You are Asyncapi Security (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for asyncapi-security
- Domain: Defines and validates authentication mechanisms for event-driven APIs including API keys, OAuth2 flows, OpenID Connect, and mutual TLS across message brokers and generated client code.
- security-schemes: Author AsyncAPI securitySchemes and validate documents. —
npx @asyncapi/cli validate asyncapi.yaml
- oauth-broker: Obtain OAuth2 tokens and connect to broker operations secured with OAuth2/OpenID Connect. —
curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_creden
- tls-mtls: Validate and test TLS/mTLS security schemes for broker endpoints. —
echo | openssl s_client -connect kafka.your-app.test:9093 -showcerts 2>/dev/null
- Check
knowledge and prerequisites: kafka-topics, mosquitto_pub, npx, openssl
2. Reason — think for asyncapi-security
- For
security-schemes: Author AsyncAPI securitySchemes and validate documents. — decide which checks to run
- For
oauth-broker: Obtain OAuth2 tokens and connect to broker operations secured with OAuth2/OpenID Connect. — decide which checks to run
- For
tls-mtls: Validate and test TLS/mTLS security schemes for broker endpoints. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with asyncapi-security tools
- Tools:
Glob, Grep, Read, Npx, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
asyncapi-security:5cbba702
AsyncAPI Security
What this skill does
Models and enforces AsyncAPI security schemes (apiKey, OAuth2, OpenID Connect, mutual TLS) in documents, generated clients, and broker connections.
When to use
- A spec must declare how channels are authenticated
- Connecting generated clients to OAuth2-secured brokers
- Validating mTLS handshakes to Kafka/MQTT endpoints
Real commands
# Validate the security schemes in a document
npx @asyncapi/cli validate asyncapi.yaml
# Get a client-credentials token
curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api-consumer -d client_secret=secret -d scope=kafka:read
# Introspect the token
curl -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN | jq '.active'
# mTLS check to the broker
openssl s_client -connect kafka.your-app.test:9093 -cert client.crt -key client.key -CAfile ca.crt < /dev/null 2>&1 | grep 'Verify return code'
Spec example
components:
securitySchemes:
oauth:
type: oauth2
flows:
clientCredentials:
tokenUrl: https://auth.your-app.test/oauth2/token
scopes:
kafka:read: Read access
mtls:
type: mutualTLS
channels:
orders:
address: orders
security:
- oauth: [kafka:read]
Testing
- Validate documents in CI with the AsyncAPI CLI
- Test broker auth with kafka-topics --command-config
Best practices
- Apply security at both the document and broker level
- Rotate client credentials; never embed secrets in specs
- Use scope-based authorization, not shared topics
Capabilities
security-schemes
Author AsyncAPI securitySchemes and validate documents.
Parameters:
file (string): AsyncAPI document to validate
ruleset (string): Custom lint ruleset
Commands:
npx @asyncapi/cli validate asyncapi.yaml
npx @asyncapi/cli lint asyncapi.yaml
npx @asyncapi/cli validate https://raw.githubusercontent.com/asyncapi/spec/master/examples/streetlights.yml
npx @asyncapi/cli --version
Examples:
- npx @asyncapi/cli validate asyncapi.yaml
- npx @asyncapi/cli lint --ruleset security-rules.json asyncapi.yaml
- npx @asyncapi/cli validate asyncapi.yaml && echo valid
oauth-broker
Obtain OAuth2 tokens and connect to broker operations secured with OAuth2/OpenID Connect.
Parameters:
token_url (string): OAuth2 token endpoint URL
client_id (string): OAuth2 client identifier
scope (string): Requested OAuth2 scopes
Commands:
curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api-consumer -d client_secret=secret -d scope=kafka:read
curl -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN
kafka-topics --bootstrap-server kafka.your-app.test:9093 --command-config client-oauth.properties --list
mosquitto_pub -h mqtt.your-app.test -p 8883 -u client --pw $TOKEN -t orders/created -m '{"id":1}' --cafile ca.crt
Examples:
tls-mtls
Validate and test TLS/mTLS security schemes for broker endpoints.
Parameters:
broker_host (string): Broker host:port
cafile (string): CA certificate path
client_cert (string): Client certificate for mTLS
Commands:
echo | openssl s_client -connect kafka.your-app.test:9093 -showcerts 2>/dev/null | openssl x509 -noout -subject -issuer
echo | openssl s_client -connect kafka.your-app.test:9093 -cert client.crt -key client.key -CAfile ca.crt 2>&1 | grep -E 'Verify|Protocol'
kafka-topics --bootstrap-server kafka.your-app.test:9093 --command-config client-mtls.properties --list
openssl verify -CAfile ca.crt client.crt
Examples:
- openssl s_client -connect kafka.your-app.test:9093 -showcerts < /dev/null | openssl x509 -noout -dates
- openssl s_client -connect kafka.your-app.test:9093 -cert client.crt -key client.key -CAfile ca.crt < /dev/null 2>&1 | grep 'Verify return code'
- kafka-topics --bootstrap-server kafka.your-app.test:9093 --command-config client-mtls.properties --describe --topic orders
References
1---2name: "asyncapi-security"3description: "Defines and validates authentication mechanisms for event-driven APIs including API keys, OAuth2 flows, OpenID Connect, and mutual TLS across message brokers and generated client code. Use when working with security schemes, oauth broker, tls mtls, api or when the user mentions security schemes, oauth broker, tls mtls, api."4license: "MIT"5compatibility: "Requires kafka-topics, mosquitto_pub, npx, openssl. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/asyncapi-security8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(echo:*) Bash(kafka-topics:*) Bash(mosquitto_pub:*) Bash(npx:*) Bash(openssl:*)"12---1314Defines and validates authentication mechanisms for event-driven APIs including API keys, OAuth2 flows, OpenID Connect, and mutual TLS across message brokers and generated client code.1516## Agentic Workflow: Read -> Reason -> Act (asyncapi-security)1718You are **Asyncapi Security** (api/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `asyncapi-security`21- Domain: Defines and validates authentication mechanisms for event-driven APIs including API keys, OAuth2 flows, OpenID Connect, and mutual TLS across message brokers and generated client code.22- **security-schemes**: Author AsyncAPI securitySchemes and validate documents. — `npx @asyncapi/cli validate asyncapi.yaml`23- **oauth-broker**: Obtain OAuth2 tokens and connect to broker operations secured with OAuth2/OpenID Connect. — `curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_creden`24- **tls-mtls**: Validate and test TLS/mTLS security schemes for broker endpoints. — `echo | openssl s_client -connect kafka.your-app.test:9093 -showcerts 2>/dev/null`25- Check `knowledge` and `prerequisites: kafka-topics, mosquitto_pub, npx, openssl`2627### 2. Reason — think for `asyncapi-security`28- For `security-schemes`: Author AsyncAPI securitySchemes and validate documents. — decide which checks to run29- For `oauth-broker`: Obtain OAuth2 tokens and connect to broker operations secured with OAuth2/OpenID Connect. — decide which checks to run30- For `tls-mtls`: Validate and test TLS/mTLS security schemes for broker endpoints. — decide which checks to run31- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3233### 3. Act — execute with `asyncapi-security` tools34- Tools: `Glob`, `Grep`, `Read`, `Npx`, `Bash` (see frontmatter `tools`/`allowed-tools`)35- Use `safe_path` for any write; record evidence (paths, checksums)36- Fingerprint: `asyncapi-security:5cbba702`3738# AsyncAPI Security3940## What this skill does4142Models and enforces AsyncAPI security schemes (apiKey, OAuth2, OpenID Connect, mutual TLS) in documents, generated clients, and broker connections.4344## When to use4546- A spec must declare how channels are authenticated47- Connecting generated clients to OAuth2-secured brokers48- Validating mTLS handshakes to Kafka/MQTT endpoints4950## Real commands5152```bash53# Validate the security schemes in a document54npx @asyncapi/cli validate asyncapi.yaml5556# Get a client-credentials token57curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api-consumer -d client_secret=secret -d scope=kafka:read5859# Introspect the token60curl -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN | jq '.active'6162# mTLS check to the broker63openssl s_client -connect kafka.your-app.test:9093 -cert client.crt -key client.key -CAfile ca.crt < /dev/null 2>&1 | grep 'Verify return code'64```6566## Spec example6768```yaml69components:70 securitySchemes:71 oauth:72 type: oauth273 flows:74 clientCredentials:75 tokenUrl: https://auth.your-app.test/oauth2/token76 scopes:77 kafka:read: Read access78 mtls:79 type: mutualTLS80channels:81 orders:82 address: orders83 security:84 - oauth: [kafka:read]85```8687## Testing8889- Validate documents in CI with the AsyncAPI CLI90- Test broker auth with kafka-topics --command-config9192## Best practices9394- Apply security at both the document and broker level95- Rotate client credentials; never embed secrets in specs96- Use scope-based authorization, not shared topics9798## Capabilities99100### security-schemes101Author AsyncAPI securitySchemes and validate documents.102103**Parameters:**104- `file` (string): AsyncAPI document to validate105- `ruleset` (string): Custom lint ruleset106107**Commands:**108- `npx @asyncapi/cli validate asyncapi.yaml`109- `npx @asyncapi/cli lint asyncapi.yaml`110- `npx @asyncapi/cli validate https://raw.githubusercontent.com/asyncapi/spec/master/examples/streetlights.yml`111- `npx @asyncapi/cli --version`112113**Examples:**114- npx @asyncapi/cli validate asyncapi.yaml115- npx @asyncapi/cli lint --ruleset security-rules.json asyncapi.yaml116- npx @asyncapi/cli validate asyncapi.yaml && echo valid117118### oauth-broker119Obtain OAuth2 tokens and connect to broker operations secured with OAuth2/OpenID Connect.120121**Parameters:**122- `token_url` (string): OAuth2 token endpoint URL123- `client_id` (string): OAuth2 client identifier124- `scope` (string): Requested OAuth2 scopes125126**Commands:**127- `curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api-consumer -d client_secret=secret -d scope=kafka:read`128- `curl -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN`129- `kafka-topics --bootstrap-server kafka.your-app.test:9093 --command-config client-oauth.properties --list`130- `mosquitto_pub -h mqtt.your-app.test -p 8883 -u client --pw $TOKEN -t orders/created -m '{"id":1}' --cafile ca.crt`131132**Examples:**133- TOKEN=$(curl -s -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api-consumer -d client_secret=secret -d scope=kafka:read | jq -r .access_token) && echo $TOKEN134- curl -s -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN | jq '.active'135- mosquitto_pub -h mqtt.your-app.test -p 8883 -u client --pw $TOKEN -t orders/created -m hello136137### tls-mtls138Validate and test TLS/mTLS security schemes for broker endpoints.139140**Parameters:**141- `broker_host` (string): Broker host:port142- `cafile` (string): CA certificate path143- `client_cert` (string): Client certificate for mTLS144145**Commands:**146- `echo | openssl s_client -connect kafka.your-app.test:9093 -showcerts 2>/dev/null | openssl x509 -noout -subject -issuer`147- `echo | openssl s_client -connect kafka.your-app.test:9093 -cert client.crt -key client.key -CAfile ca.crt 2>&1 | grep -E 'Verify|Protocol'`148- `kafka-topics --bootstrap-server kafka.your-app.test:9093 --command-config client-mtls.properties --list`149- `openssl verify -CAfile ca.crt client.crt`150151**Examples:**152- openssl s_client -connect kafka.your-app.test:9093 -showcerts < /dev/null | openssl x509 -noout -dates153- openssl s_client -connect kafka.your-app.test:9093 -cert client.crt -key client.key -CAfile ca.crt < /dev/null 2>&1 | grep 'Verify return code'154- kafka-topics --bootstrap-server kafka.your-app.test:9093 --command-config client-mtls.properties --describe --topic orders155156## References157- [AsyncAPI Security Schemes](https://www.asyncapi.com/docs/reference/specification/v3.0.0#security-scheme-object)158- [AsyncAPI Security Best Practices](https://www.asyncapi.com/docs/guides/security)159- [OAuth 2.0 Spec](https://www.rfc-editor.org/rfc/rfc6749)