auth-test

Test endpoints for HTTP Basic, Digest, API keys, form login and OAuth 2.0 / OIDC

Users

Passwords are PBKDF2-SHA256 hashed (Digest also stores the MD5 HA1 the protocol requires).

API keys

OAuth clients

Try a browser flow

Redirects to /oauth/authorize; /oauth/callback shows the result and can exchange the code. Device flow: use curl above, then open /oauth/device. Form login: /form/login.

Endpoints & curl examples

HTTP Basic /basic

curl -i -u USER:PASS https://auth-test.patricklaflam.me/basic

HTTP Digest (MD5, qop=auth) /digest

curl -i --digest -u USER:PASS https://auth-test.patricklaflam.me/digest

API key (X-API-Key header) /apikey

curl -i -H 'X-API-Key: atk_...' https://auth-test.patricklaflam.me/apikey

API key (Bearer) /apikey

curl -i -H 'Authorization: Bearer atk_...' https://auth-test.patricklaflam.me/apikey

Form login + cookie session (CSRF) /form/login

# get CSRF token + cookie, then log in
curl -s -c jar -b jar https://auth-test.patricklaflam.me/form/login -H 'Accept: application/json'   # -> {"csrf":"..."}
curl -i -c jar -b jar -X POST https://auth-test.patricklaflam.me/form/login -d username=USER -d password=PASS -d csrf=CSRF
curl -i -b jar https://auth-test.patricklaflam.me/form/protected
curl -i -c jar -b jar -X POST https://auth-test.patricklaflam.me/form/logout -d csrf=CSRF

OIDC discovery /.well-known/openid-configuration

curl -s https://auth-test.patricklaflam.me/.well-known/openid-configuration
curl -s https://auth-test.patricklaflam.me/.well-known/oauth-authorization-server
curl -s https://auth-test.patricklaflam.me/oauth/jwks

Authorization code (confidential, browser) /oauth/authorize

open 'https://auth-test.patricklaflam.me/oauth/authorize?response_type=code&client_id=CLIENT_ID&redirect_uri=https%3A%2F%2Fauth-test.patricklaflam.me%2Foauth%2Fcallback&scope=openid%20profile%20email&state=xyz&nonce=n1'
# exchange (client_secret_basic):
curl -s -u CLIENT_ID:CLIENT_SECRET https://auth-test.patricklaflam.me/oauth/token -d grant_type=authorization_code -d code=CODE -d redirect_uri=https://auth-test.patricklaflam.me/oauth/callback
# or client_secret_post:
curl -s https://auth-test.patricklaflam.me/oauth/token -d grant_type=authorization_code -d code=CODE -d redirect_uri=https://auth-test.patricklaflam.me/oauth/callback -d client_id=CLIENT_ID -d client_secret=CLIENT_SECRET

Authorization code + PKCE (public client) /oauth/authorize

VERIFIER=$(openssl rand -base64 48 | tr -d '=+/\n' | cut -c1-64)
CHALLENGE=$(printf %s "$VERIFIER" | openssl dgst -sha256 -binary | openssl base64 | tr '+/' '-_' | tr -d '=')
open "https://auth-test.patricklaflam.me/oauth/authorize?response_type=code&client_id=PUBLIC_ID&redirect_uri=https%3A%2F%2Fauth-test.patricklaflam.me%2Foauth%2Fcallback&scope=openid&code_challenge=$CHALLENGE&code_challenge_method=S256"
curl -s https://auth-test.patricklaflam.me/oauth/token -d grant_type=authorization_code -d client_id=PUBLIC_ID -d code=CODE -d redirect_uri=https://auth-test.patricklaflam.me/oauth/callback -d code_verifier=$VERIFIER
# plain: code_challenge=$VERIFIER&code_challenge_method=plain

Implicit (response_type=token) /oauth/authorize

open 'https://auth-test.patricklaflam.me/oauth/authorize?response_type=token&client_id=CLIENT_ID&redirect_uri=https%3A%2F%2Fauth-test.patricklaflam.me%2Foauth%2Fcallback&scope=read&state=xyz'
# token arrives in the URL fragment of /oauth/callback

Client credentials /oauth/token

curl -s -u CLIENT_ID:CLIENT_SECRET https://auth-test.patricklaflam.me/oauth/token -d grant_type=client_credentials -d scope=read

Password (ROPC) /oauth/token

curl -s -u CLIENT_ID:CLIENT_SECRET https://auth-test.patricklaflam.me/oauth/token -d grant_type=password -d username=USER -d password=PASS -d 'scope=openid profile offline_access'

Refresh token (rotating) /oauth/token

curl -s -u CLIENT_ID:CLIENT_SECRET https://auth-test.patricklaflam.me/oauth/token -d grant_type=refresh_token -d refresh_token=RT
# reusing an old refresh token revokes the whole token family

Device code (RFC 8628) /oauth/device_authorization

curl -s https://auth-test.patricklaflam.me/oauth/device_authorization -d client_id=CLIENT_ID -d scope=openid   # (+ secret if confidential)
# open verification_uri_complete in a browser and approve, then poll:
curl -s https://auth-test.patricklaflam.me/oauth/token -d grant_type=urn:ietf:params:oauth:grant-type:device_code -d client_id=CLIENT_ID -d device_code=DEVICE_CODE

Introspection / revocation /oauth/introspect

curl -s -u CLIENT_ID:CLIENT_SECRET https://auth-test.patricklaflam.me/oauth/introspect -d token=TOKEN
curl -i -u CLIENT_ID:CLIENT_SECRET https://auth-test.patricklaflam.me/oauth/revoke -d token=TOKEN

UserInfo / protected resource /oauth/userinfo

curl -s -H 'Authorization: Bearer ACCESS_TOKEN' https://auth-test.patricklaflam.me/oauth/userinfo
curl -s -H 'Authorization: Bearer ACCESS_TOKEN' https://auth-test.patricklaflam.me/oauth/resource

Setup API (JSON) /api/state

curl -s https://auth-test.patricklaflam.me/api/state
curl -s https://auth-test.patricklaflam.me/api/users -H 'content-type: application/json' -d '{"username":"alice","password":"test-only"}'
curl -s https://auth-test.patricklaflam.me/api/apikeys -H 'content-type: application/json' -d '{"name":"k1","username":"alice"}'
curl -s https://auth-test.patricklaflam.me/api/clients -H 'content-type: application/json' -d '{"name":"app","type":"confidential","redirect_uris":["https://auth-test.patricklaflam.me/oauth/callback"],"grant_types":["authorization_code","refresh_token"]}'
curl -s -X DELETE https://auth-test.patricklaflam.me/api/users/alice
curl -s -X POST https://auth-test.patricklaflam.me/api/reset

Danger zone

Deletes every user, API key, client, code, token and session.