Schémas d’authentification
Schémas d’authentification : un point d’accès par schéma courant (Basic, Bearer, clé d’API en en-tête/query/cookie, Digest, signature HMAC des requêtes, contrôle des rôles et des scopes, CSRF à double soumission) pour tester comment un client envoie ses identifiants. Tous les identifiants sont fixes et listés par GET /api/auth.
- GET
https://api.testingapis.com/api/authList every auth scheme with its test credentials. - GET
https://api.testingapis.com/api/auth/api-key/cookieAuthenticate with an API key in the api_key cookie. - GET
https://api.testingapis.com/api/auth/api-key/headerAuthenticate with an API key in the X-API-Key header. - GET
https://api.testingapis.com/api/auth/api-key/queryAuthenticate with an API key in the api_key query parameter. - GET
https://api.testingapis.com/api/auth/basicAuthenticate with HTTP Basic auth. - GET
https://api.testingapis.com/api/auth/basic-hidden/{user}/{pass}Authenticate with Basic auth, returning 404 instead of 401 on failure. - GET
https://api.testingapis.com/api/auth/basic/{user}/{pass}Authenticate with Basic auth against credentials taken from the URL. - GET
https://api.testingapis.com/api/auth/bearerAuthenticate with a static bearer token. - POST
https://api.testingapis.com/api/auth/csrf/submitSubmit a CSRF-protected form (double-submit cookie check). - GET
https://api.testingapis.com/api/auth/csrf/tokenIssue a CSRF token and set it as the XSRF-TOKEN cookie. - GET
https://api.testingapis.com/api/auth/digestAuthenticate with HTTP Digest auth (MD5, qop=auth). - POST
https://api.testingapis.com/api/auth/hmacVerify an HMAC-SHA256 request signature. - GET
https://api.testingapis.com/api/auth/roles/adminAllow only tokens with the admin role (401 vs 403 demo). - DELETE
https://api.testingapis.com/api/auth/roles/resourceAllow only tokens with the delete scope. - GET
https://api.testingapis.com/api/auth/roles/userAllow only tokens with the user role.
Exemple de requête
List every auth scheme with its test credentials. Référence complète et bouton Send (en anglais).
cURL
curl -X GET "https://api.testingapis.com/api/auth"Réponse · 200 OK
{
"message": "Hardcoded credentials for every auth scheme. Send them wrong to test your 401 handling; the role endpoints also return 403.",
"schemes": [
{
"scheme": "basic",
"endpoint": "GET /api/auth/basic",
"credentials": {"username": "apibee", "password": "password123"}
},
{
"scheme": "basic (path creds)",
"endpoint": "GET /api/auth/basic/{user}/{pass}",
"credentials": "Any user/pass — must match the path"
},
"… 12 more items"
… (2 more lines)Voir aussi
- Guide : des points d’accès de test pour chaque schéma d’authentification
- Leçon : authentification et autorisation (en anglais)
- Leçon : sessions, clés d’API et tokens bearer (en anglais)
- Leçon : authentification Basic et Digest (en anglais)
- Leçon : tester les rôles, les scopes et le CSRF (en anglais)
- Encodeur et décodeur Base64
- API d’authentification JWT