認可

Veridata REST APIにアクセスするための認可トークンを生成するには、次のスクリプトをlinuxボックスのスクリプト・ファイルにコピーし、次のパラメータを編集します:
  1. USERNAME="<username>"

    これは作成したVeridataユーザーです。

  2. PASSWORD="<password>"

    これはVeridataユーザーのパスワードです。

  3. URL="http://<host>:<port>/veridata/v1/auth/login"

    ホスト: Veridata

    サーバー・ホスト名のポート: Veridataサーバーのポート

  4. スクリプトを保存して実行し、Veridata認可トークンを生成します。

#!/bin/bash # Function to generate MD5 hash md5_hash() { echo -n "$1" | openssl dgst -md5 | awk '{print $2}' } # Variables USERNAME="<userName>" PASSWORD="<password>" REALM="" NONCE="" QOP="" CNONCE=$(openssl rand -hex 8) # Random client nonce OPAQUE="" ALGORITHM="MD5" URL="http://<host>:<port>/veridata/v1/auth/login" API_URL="/v1/auth/login" # First call to get digest details (WWW-Authenticate header) response_headers=$(curl -s -I "$URL" | grep -i 'WWW-Authenticate-Custom') # Extracting the necessary fields from the WWW-Authenticate header REALM=$(echo "$response_headers" | grep -Eo 'realm="([^"]*)"' | cut -d'"' -f2) NONCE=$(echo "$response_headers" | grep -Eo 'nonce="([^"]*)"' | cut -d'"' -f2) QOP=$(echo "$response_headers" | grep -Eo 'qop="([^"]*)"' | cut -d'"' -f2) OPAQUE=$(echo "$response_headers" | grep -Eo 'opaque="([^"]*)"' | cut -d'"' -f2) # Generate HA1, HA2, and response based on Digest Authentication process HA1=$(md5_hash "$USERNAME:$REALM:$PASSWORD") HA2=$(md5_hash "GET:$API_URL") NC="00000001" # Nonce count RESPONSE=$(md5_hash "$HA1:$NONCE:$NC:$CNONCE:$QOP:$HA2") # Generate Authorization header AUTH_HEADER="Digest username=\"$USERNAME\", realm=\"$REALM\", nonce=\"$NONCE\", uri=\"$API_URL\", algorithm=$ALGORITHM, qop=$QOP, nc=$NC, cnonce=\"$CNONCE\", opaque=\"$OPAQUE\", response=\"$RESPONSE\"" # Perform second call with Authorization header curl -v -H "Authorization: $AUTH_HEADER" "$URL"