API Endpoint Security¶
asvin-Komponenten stellen ihre Dienste über RESTful-API-Endpunkte zur Verfügung. Sie werden mit Jason Web Token (JWT) gesichert. Es ist erforderlich, ein JWT vom OAuth-Server zu erhalten. Erst danach kann auf die Endpunkte erfolgreich zugegriffen werden. Der Login -API-Endpunkt wird verwendet, um JWT von OAuth zu erhalten.
Geräte-Signatur¶
Die in der Die Login -API verwendete device_signature
ist ein hashed-basierter
Message Authentication Code (MAC). Er besteht aus einer kryptografischen Hash-Funktion
(HMAC-SHA256) und einem geheimen Schlüssel. Im Pseudocode kann er als HMAC-SHA256(key, message)
.
dargestellt werden. Hier ist die Nachricht timestamp+device_key
und der Schlüssel ist customer_key
. Die device_signature
wird also berechnet als
device_signature = HMAC-SHA256(customer_key, timestamp+device_key)
The customer_key and device_key are acquired from Customer Platform. One needs to make a account there. The code block below
shows the device_signature
generation.
Der customer_key und device_key werden von der Customer Platform bezogen.
Man muss dort ein Konto anlegen. Der Codeblock unten zeigt die Erzeugung der device_signature
#!/bin/bash
customer_key="my-customer-key"
device_key="my-device-key"
timestamp=$(date +%s)
device_signature=$(echo -n $timestamp$device_key | openssl dgst -sha256 -hmac $customer_key)
echo $device_signature
import hmac
import hashlib
from time import time
customer_key = "my-customer-key"
device_key = "my-device-key"
timestamp = str(math.floor(time()))
device_signature = hmac.new(customer_key, msg=timestamp+device_key, digestmod=hashlib.sha256).hexdigest().upper()
print device_signature
const CryptoJS = require("crypto-js");
const dateNow = new Date();
const customerKey = "my-customer-key";
const deviceKey = "my-device-key";
const timestamp = Math.floor(dateNow.getTime() / 1000);
const deviceSignature = CryptoJS.HmacSHA256(timestamp + deviceKey, customerKey).toString(CryptoJS.digest);
console.log(deviceSignature)