Authentication & Connectivity

OAuth, Basic Auth, SAP Cloud Connector und Zertifikatsverwaltung.

1. Pull-Modell (Bilendo → SAP)

1.1 S/4HANA Cloud: OAuth 2.0 Client Credentials

Konfiguration in SAP:

HTTP-Anfrage:

POST /oauth/token HTTP/1.1
Host: <sap-cloud-instance>.authentication.<region>.hana.ondemand.com
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id=<CLIENT_ID>
&client_secret=<CLIENT_SECRET>

Antwort:

{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 3600
}

Nachfolgende OData-Anfrage:

GET /sap/opu/odata/sap/C_SALESDOCUMENT_CDS HTTP/1.1
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

Sequence Diagram:

sequenceDiagram
    participant Bilendo as Bilendo<br/>(Client)
    participant TokenSrv as SAP Token<br/>Service
    participant SAP as SAP S/4HANA<br/>Cloud
    
    Bilendo->>TokenSrv: POST /oauth/token<br/>(client_id, client_secret)
    TokenSrv-->>Bilendo: access_token (Bearer)
    Bilendo->>SAP: GET /odata/...<br/>Authorization: Bearer token
    SAP-->>Bilendo: OData Response (JSON)

1.2 S/4HANA On-Premise: Basic Auth oder X.509

Basic Authentication:

  1. SAP-Seite (SU01):

    • Technischen Benutzer anlegen (z.B. BILENDO_INT)

    • Passwort setzen (min. 8 Zeichen, komplexes Passwort)

    • Berechtigungsgruppe zuweisen

  2. Gateway aktivieren (SICF):

    • Transaction SICF

    • Service /sap/opu/odata/sap/<Service> aktivieren

    • Authentifizierung: Basic Auth

  3. Test-Befehl (cURL):

curl -X GET \
  -H "Authorization: Basic $(echo -n 'BILENDO_INT:Passwort123!' | base64)" \
  -H "Content-Type: application/json" \
  "https://sap-on-premise.example.com:50000/sap/opu/odata/sap/C_SALESDOCUMENT_CDS?$top=10"

X.509 Zertifikat-Auth (höherer Sicherheitsstandard):

curl -X GET \
  --cert /path/to/client.crt --key /path/to/client.key \
  "https://sap-on-premise.example.com:50000/sap/opu/odata/sap/C_SALESDOCUMENT_CDS"

1.3 ECC + Gateway: Basic Auth

Architektur:

Konfiguration:

  1. RFC-Benutzer in ECC (SU01):

    • Typ: System (System User)

    • Dialog-Anmeldung: deaktiviert

    • Automatische Anmeldung: nicht zulässig

  2. Gateway Service (SICF):

    • Service /sap/opu/odata/sap/<ODataService> registrieren

    • RFC-Destination auf ECC System setzen

    • SSL: Protokoll HTTPS erzwingen

  3. IP-Whitelist (optional aber empfohlen):

Transaction SICF → Service Properties → Access Control
Allowed IP ranges: 192.168.1.0/24, 10.0.0.0/8
  1. Test (Basic Auth):

curl -u "RFC_USER:password" \
  "https://gateway.example.com:50000/sap/opu/odata/sap/Z_CUSTOMER_SRV/Customers"

2. Push-Modell (SAP → Bilendo)

2.1 Bilendo REST API: API Key oder OAuth2

API Key-Authentifizierung (einfach):

POST https://api.bilendo.de/v2/documents HTTP/1.1
Authorization: ApiKey <API_KEY>
Content-Type: application/json

{
  "document_type": "SALES_ORDER",
  "external_id": "4500123456",
  "amount": 5499.99
}

OAuth2 Authorization Code Flow (sicher):

  1. SAP leitet Benutzer auf Bilendo Authorization Endpoint

  2. Benutzer bestätigt Zugriff

  3. SAP erhält Authorization Code

  4. SAP tauscht Code gegen Access Token

POST https://api.bilendo.de/oauth/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code
&code=<AUTHORIZATION_CODE>
&client_id=<SAP_CLIENT_ID>
&client_secret=<SAP_CLIENT_SECRET>
&redirect_uri=https://sap-system/callback

2.2 SAP CPI: HTTP Destination & Credential Store

Konfiguration in SAP Cloud Integration:

  1. HTTP Destination (BTP):

    • URL: https://api.bilendo.de

    • Authentication Type: OAuth2

    • Token Service URL: https://api.bilendo.de/oauth/token

    • Client ID / Secret aus Credential Store

  2. Credential Store (Cloud Connector / BTP):

    Key: bilendo_oauth_credentials
    Value: {"client_id": "...", "client_secret": "..."}
  3. iFlow Integration:

    • HTTP Target Adapter mit Destination Bilendo_OData_Push

    • Message Type: JSON

    • POST zu /v2/documents Endpoint

    • Mapping: SAP Geschäftsdokument → Bilendo Format

  4. Error Handling:

    • Retry mit exponential backoff (3x)

    • Dead Letter Queue bei persistenten Fehlern

    • Audit Log für alle Transaktionen


3. Netzwerk-Konnektivität

Topologie für S/4HANA Cloud & On-Premise

graph TB
    subgraph Bilendo["Bilendo (SaaS)"]
        BE["REST API<br/>OData Consumer"]
    end
    
    subgraph AWS["AWS / Azure"]
        LB["Load Balancer"]
        API["API Gateway"]
    end
    
    subgraph SAP_Cloud["SAP S/4HANA Cloud<br/>(BTP)"]
        S4C["OData Services"]
    end
    
    subgraph Kundennetz["Customer Network"]
        RP["Reverse Proxy<br/>(Optional)"]
        FW["Firewall"]
        ECC["SAP System<br/>(On-Prem/ECC)"]
    end
    
    BE -->|HTTPS| LB
    API -->|Direct HTTPS| S4C
    API -->|Cloud Connector| S4C
    BE -->|HTTPS| RP
    RP -->|HTTP| FW
    FW -->|RFC| ECC

Connectivity-Optionen

OptionKomplexitätVoraussetzungSicherheitLatenzFirewall
S/4HANA Cloud: Direct HTTPSNiedrigBTP Tenant, OAuth2⭐⭐⭐⭐⭐<100msNur ausgehend
S/4HANA Cloud: Cloud ConnectorMittelCC Installation, JVM⭐⭐⭐⭐⭐100–200msNur ausgehend
On-Prem: Reverse ProxyMittelApache/nginx, SSL⭐⭐⭐⭐<50msEingehend, Whitelist
On-Prem: VPNHochVPN Appliance, Zertifikate⭐⭐⭐⭐⭐50–150msTransparent
On-Prem: Cloud ConnectorHochCC + BTP Middleware⭐⭐⭐⭐⭐100–300msNur ausgehend

Empfehlung:


4. Berechtigungen

Erforderliche SAP Authorization Objects

ObjektBerechtigter BenutzerAktivitätBerechtigungswert
S_SERVICERFC/Technischer UserOData Service Zugriff/sap/opu/odata/sap/C_*
F_BKPF_BUKRFC/Technischer UserDokumentenlesung (Finance)Buchungskreis 0001
F_KNA1_BUKRFC/Technischer UserKundenstamm-LesungVerkaufsorganisation 1000
V_VBAK_VKORFC/Technischer UserVerkaufsorder-LesungVerkaufsorganisation 1000
S_TABU_DISRFC/Technischer UserTabellenzugriffAktivität 03 (Display)

Minimalprinzip:


5. Sicherheitsempfehlungen

Kryptographie & Transport

# Test TLS-Version:
openssl s_client -connect sap-system.example.com:50000 -tls1_2

Authentifizierung

Netzwerk & Zugriffskontrolle

Audit & Monitoring

Passwort-Policy

Beispiel: Sichere Integration (Best Practice)

# Authentifizierung: OAuth2
POST https://sap-instance.authentication.eu10.hana.ondemand.com/oauth/token
  client_id=ABC123
  client_secret=<aus_credential_store>

# OData-Aufruf mit Bearer Token
GET https://sap-cloud.example.com/sap/opu/odata/sap/C_SALESDOCUMENT_CDS?$filter=CreatedOn%20gt%202026-04-01
  Authorization: Bearer eyJhbGciOiJSUzI1NiJ9...
  X-Request-ID: bilendo-20260409-12345  # für Tracing

Checkliste vor Produktivgang


**