Acquires and validates OAuth2/OIDC tokens, inspects JWT structure and signatures with OpenSSL, and tests Bearer-token protected endpoints using curl.
Agentic Workflow: Read -> Reason -> Act (authentication)
You are Authentication (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for authentication
- Domain: Acquires and validates OAuth2/OIDC tokens, inspects JWT structure and signatures with OpenSSL, and tests Bearer-token protected endpoints using curl.
- oauth-tokens: Acquire and validate OAuth2/OIDC tokens. —
curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_creden
- jwt-verify: Inspect and verify JWTs with openssl and jq. —
openssl genrsa -out private.pem 2048
- bearer-testing: Test authenticated API calls with curl. —
curl -i -H "Authorization: Bearer $TOKEN" https://api.your-app.test/v1/me
- Check
knowledge and prerequisites: echo, openssl
2. Reason — think for authentication
- For
oauth-tokens: Acquire and validate OAuth2/OIDC tokens. — decide which checks to run
- For
jwt-verify: Inspect and verify JWTs with openssl and jq. — decide which checks to run
- For
bearer-testing: Test authenticated API calls with curl. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with authentication tools
- Tools:
Glob, Grep, Read, Bash, Openssl (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
authentication:0cbc65d2
Authentication
What this skill does
Implements API authentication: OAuth2/OIDC token acquisition and introspection, JWT structure inspection and signature verification with openssl, and Bearer-token testing with curl.
When to use
- Adding OAuth2 to an API or client
- Debugging why a token is rejected (expiry, signature, scope)
- Testing authenticated endpoints end to end
Real commands
# Client credentials flow
TOKEN=$(curl -s -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api -d client_secret=secret -d scope=api:read | jq -r .access_token)
# Introspect
curl -s -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN -u api:secret | jq '.active, .exp'
# Decode JWT payload
jq -R 'split(".")[1] | @base64d | fromjson' <<< $TOKEN
# Test the endpoint
curl -i -H "Authorization: Bearer $TOKEN" https://api.your-app.test/v1/me
Note: ecurl above is a typo for curl; always use curl for HTTP requests.
Key generation for local verification
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pem
Testing
- Expect 401 without a token, 200 with a valid one
- Test expired tokens by decoding
exp and comparing to date +%s
Best practices
- Keep client secrets out of code; use a secrets manager
- Validate exp, iss, aud, and signature on every request
- Use short-lived access tokens with refresh flows
Capabilities
oauth-tokens
Acquire and validate OAuth2/OIDC tokens.
Parameters:
token_url (string): OAuth2 token endpoint
grant_type (string): client_credentials, authorization_code, refresh_token
scope (string): Requested scopes
Commands:
curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api -d client_secret=secret -d scope=api:read
curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=authorization_code -d code=xyz -d redirect_uri=https://app.your-app.test/callback -d client_id=api -d client_secret=secret
curl -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN -u api:secret
curl -X POST https://auth.your-app.test/oauth2/revoke -d token=$TOKEN -u api:secret
Examples:
jwt-verify
Inspect and verify JWTs with openssl and jq.
Parameters:
token (string): JWT to inspect
key_file (string): Public key file for verification
Commands:
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pem
echo $TOKEN | cut -d. -f2 | base64 -d 2>/dev/null | jq .
echo $TOKEN | cut -d. -f1 | base64 -d 2>/dev/null | jq .
openssl dgst -sha256 -verify public.pem -signature sig.bin payload.txt
Examples:
- echo $TOKEN | cut -d. -f2 | base64 -d 2>/dev/null | jq '{sub, exp, scope}'
- openssl x509 -in cert.pem -noout -text | grep -A1 'Public Key'
- jq -R 'split(".")[1] | @base64d | fromjson' <<< $TOKEN
bearer-testing
Test authenticated API calls with curl.
Parameters:
url (string): Protected endpoint
method (string): HTTP method
Commands:
curl -i -H "Authorization: Bearer $TOKEN" https://api.your-app.test/v1/me
curl -i https://api.your-app.test/v1/me
curl -i -H "Authorization: Bearer invalid-token" https://api.your-app.test/v1/me
curl -i -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{}' https://api.your-app.test/v1/orders
Examples:
References
1---2name: "authentication"3description: "Acquires and validates OAuth2/OIDC tokens, inspects JWT structure and signatures with OpenSSL, and tests Bearer-token protected endpoints using curl. Use when working with oauth tokens, jwt verify, bearer testing, api or when the user mentions oauth tokens, jwt verify, bearer testing, api."4license: "MIT"5compatibility: "Requires echo, openssl. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/authentication8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(echo:*) Bash(openssl:*)"12---1314Acquires and validates OAuth2/OIDC tokens, inspects JWT structure and signatures with OpenSSL, and tests Bearer-token protected endpoints using curl.1516## Agentic Workflow: Read -> Reason -> Act (authentication)1718You are **Authentication** (api/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `authentication`21- Domain: Acquires and validates OAuth2/OIDC tokens, inspects JWT structure and signatures with OpenSSL, and tests Bearer-token protected endpoints using curl.22- **oauth-tokens**: Acquire and validate OAuth2/OIDC tokens. — `curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_creden`23- **jwt-verify**: Inspect and verify JWTs with openssl and jq. — `openssl genrsa -out private.pem 2048`24- **bearer-testing**: Test authenticated API calls with curl. — `curl -i -H "Authorization: Bearer $TOKEN" https://api.your-app.test/v1/me`25- Check `knowledge` and `prerequisites: echo, openssl`2627### 2. Reason — think for `authentication`28- For `oauth-tokens`: Acquire and validate OAuth2/OIDC tokens. — decide which checks to run29- For `jwt-verify`: Inspect and verify JWTs with openssl and jq. — decide which checks to run30- For `bearer-testing`: Test authenticated API calls with curl. — decide which checks to run31- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3233### 3. Act — execute with `authentication` tools34- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Openssl` (see frontmatter `tools`/`allowed-tools`)35- Use `safe_path` for any write; record evidence (paths, checksums)36- Fingerprint: `authentication:0cbc65d2`3738# Authentication3940## What this skill does4142Implements API authentication: OAuth2/OIDC token acquisition and introspection, JWT structure inspection and signature verification with openssl, and Bearer-token testing with curl.4344## When to use4546- Adding OAuth2 to an API or client47- Debugging why a token is rejected (expiry, signature, scope)48- Testing authenticated endpoints end to end4950## Real commands5152```bash53# Client credentials flow54TOKEN=$(curl -s -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api -d client_secret=secret -d scope=api:read | jq -r .access_token)5556# Introspect57curl -s -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN -u api:secret | jq '.active, .exp'5859# Decode JWT payload60jq -R 'split(".")[1] | @base64d | fromjson' <<< $TOKEN6162# Test the endpoint63curl -i -H "Authorization: Bearer $TOKEN" https://api.your-app.test/v1/me64```6566Note: `ecurl` above is a typo for `curl`; always use `curl` for HTTP requests.6768## Key generation for local verification6970```bash71openssl genrsa -out private.pem 204872openssl rsa -in private.pem -pubout -out public.pem73```7475## Testing7677- Expect 401 without a token, 200 with a valid one78- Test expired tokens by decoding `exp` and comparing to `date +%s`7980## Best practices8182- Keep client secrets out of code; use a secrets manager83- Validate exp, iss, aud, and signature on every request84- Use short-lived access tokens with refresh flows8586## Capabilities8788### oauth-tokens89Acquire and validate OAuth2/OIDC tokens.9091**Parameters:**92- `token_url` (string): OAuth2 token endpoint93- `grant_type` (string): client_credentials, authorization_code, refresh_token94- `scope` (string): Requested scopes9596**Commands:**97- `curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api -d client_secret=secret -d scope=api:read`98- `curl -X POST https://auth.your-app.test/oauth2/token -d grant_type=authorization_code -d code=xyz -d redirect_uri=https://app.your-app.test/callback -d client_id=api -d client_secret=secret`99- `curl -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN -u api:secret`100- `curl -X POST https://auth.your-app.test/oauth2/revoke -d token=$TOKEN -u api:secret`101102**Examples:**103- TOKEN=$(curl -s -X POST https://auth.your-app.test/oauth2/token -d grant_type=client_credentials -d client_id=api -d client_secret=secret -d scope=api:read | jq -r .access_token)104- curl -s -X POST https://auth.your-app.test/oauth2/introspect -d token=$TOKEN -u api:secret | jq '.active, .exp'105- curl -s -X POST https://auth.your-app.test/oauth2/revoke -d token=$TOKEN -u api:secret106107### jwt-verify108Inspect and verify JWTs with openssl and jq.109110**Parameters:**111- `token` (string): JWT to inspect112- `key_file` (string): Public key file for verification113114**Commands:**115- `openssl genrsa -out private.pem 2048`116- `openssl rsa -in private.pem -pubout -out public.pem`117- `echo $TOKEN | cut -d. -f2 | base64 -d 2>/dev/null | jq .`118- `echo $TOKEN | cut -d. -f1 | base64 -d 2>/dev/null | jq .`119- `openssl dgst -sha256 -verify public.pem -signature sig.bin payload.txt`120121**Examples:**122- echo $TOKEN | cut -d. -f2 | base64 -d 2>/dev/null | jq '{sub, exp, scope}'123- openssl x509 -in cert.pem -noout -text | grep -A1 'Public Key'124- jq -R 'split(".")[1] | @base64d | fromjson' <<< $TOKEN125126### bearer-testing127Test authenticated API calls with curl.128129**Parameters:**130- `url` (string): Protected endpoint131- `method` (string): HTTP method132133**Commands:**134- `curl -i -H "Authorization: Bearer $TOKEN" https://api.your-app.test/v1/me`135- `curl -i https://api.your-app.test/v1/me`136- `curl -i -H "Authorization: Bearer invalid-token" https://api.your-app.test/v1/me`137- `curl -i -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{}' https://api.your-app.test/v1/orders`138139**Examples:**140- curl -s -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer $TOKEN" https://api.your-app.test/v1/me141- curl -i -H "Authorization: Bearer $TOKEN" https://api.your-app.test/v1/me | head -20142- curl -i -H "Authorization: Bearer $TOKEN" https://api.your-app.test/v1/orders143144## References145- [OAuth 2.0](https://oauth.net/2/)146- [JWT Introduction](https://jwt.io/introduction)147- [OWASP Auth Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html)