HTTP Authorization Header

Der HTTP-Header Authorization ist ein Request-Header, mit dem der Client Authentifizierungs-Credentials an den Server übermittelt. Er ist der Standard-Mechanismus für API-Authentifizierung mit Bearer Tokens, JWT oder Basic Auth.

Typ

Request-Header

Syntax

Der Header kombiniert ein Authentication-Schema mit den entsprechenden Credentials.

http
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Direktiven

Die Direktiven definieren das Authentication-Schema und die Credentials.

Bearer <token>
OAuth 2.0 Bearer Token oder JWT für Token-basierte Authentifizierung. Standard für moderne REST APIs.
Basic <credentials>
Base64-kodierte Username:Password-Kombination. Unsicher ohne HTTPS, Legacy-Methode.
Digest <parameters>
Challenge-Response-Authentifizierung mit Hashing. Selten genutzt.
<custom-scheme> <token>
Proprietäre Auth-Schemas wie API-Key-basierte Mechanismen.

Beispiele

Nachfolgend finden Sie praktische Anwendungsbeispiele für den Authorization-Header.

Beispiel 1 JWT Bearer Token

http
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Moderner REST API-Zugriff mit JSON Web Token, enthält Claims und Signatur für stateless Authentication.

Beispiel 2 OAuth 2.0 Access Token

http
Authorization: Bearer sk_live_51HqF2dKZvx8r7P9mN3L4c2Y1t6W8h9D0s

OAuth 2.0 Access Token von Authorization Server, typisch für Third-Party API-Integration.

Beispiel 3 Basic Authentication

http
Authorization: Basic YWRtaW46c2VjcmV0MTIz

Legacy Basic Auth (Base64: admin:secret123), nur über HTTPS sicher, für einfache APIs oder Prototyping.

API Authentication Flow

Bearer Token Authentication Flow für REST APIs

Vorteile für die Systemarchitektur

  • Stateless Authentication: JWT ermöglicht Session-freie APIs ohne Server-seitigen Session-Store
  • Standard-Konformität: OAuth 2.0 und Bearer Tokens sind Industrie-Standard für API-Security
  • Flexible Integration: Unterstützt verschiedene Auth-Flows (Client Credentials, Authorization Code, etc.)

Spezifikation

RFC 9110, Section 11.6.2 – HTTP Semantics https://www.rfc-editor.org/rfc/rfc9110.html#name-authorization RFC 6750 – OAuth 2.0 Bearer Token Usage https://www.rfc-editor.org/rfc/rfc6750.html

Weitere Spezifikationen

WWW-Authenticate Header, HTTP Status 401 - Unauthorized, Cookie Header