From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- .../persona/remote_verification_api/index.html | 125 --------------------- 1 file changed, 125 deletions(-) delete mode 100644 files/ja/mozilla/persona/remote_verification_api/index.html (limited to 'files/ja/mozilla/persona/remote_verification_api/index.html') diff --git a/files/ja/mozilla/persona/remote_verification_api/index.html b/files/ja/mozilla/persona/remote_verification_api/index.html deleted file mode 100644 index f6c5fe4912..0000000000 --- a/files/ja/mozilla/persona/remote_verification_api/index.html +++ /dev/null @@ -1,125 +0,0 @@ ---- -title: Remote Verification API -slug: Mozilla/Persona/Remote_Verification_API -tags: - - BrowserID - - Persona -translation_of: Archive/Mozilla/Persona/Remote_Verification_API ---- -

要約

-

ユーザが Web サイトにログインしようとする時、ブラウザが アサーション と呼ばれるデータ構造を生成します。このデータの内容は、暗号化された署名付きのメールアドレスです。ブラウザは、このアサーションを Web サイトに送信し、ユーザにログインを許可する前にアサーションが正当か検証されます。

-

アサーションはローカルで検証することもできます。または、https://verifier.login.persona.org/verify でホストされた API でも検証できます。このページでは、この API の使い方を説明します。

-

メソッド

-

https://verifier.login.persona.org/verify に HTTP POST リクエストを送信します。

-

引数

-

assertion: ユーザが提供したアサーション。{{ domxref("navigator.id.watch()") }} の onlogin 関数に渡す最初の引数として使います。
- audience: あなたのサイトのプロトコル、ドメイン名、ポート番号。例えば、"https://example.com:443" と指定します。

-

戻り値

-

この API を呼び出すと、status 要素を含む JSON データ構造を返します。この要素は、"okay" と "failure" のどちらかになります。status の値に依存して、JSON データに以下の追加の要素が含まれることがあります。

-

"okay"

-

アサーションは正当です。

-

この場合、JSON データ構造に次の追加要素が含まれます:

- - - - - - - - - - - - - - - - - - - -
"email"アサーションに含まれるメールアドレス。これは、ログインしようとしているユーザのものです。
"audience"アサーションに含まれる audience 値。あなたの Web サイトの URL であることが期待されます。
"expires"アサーションの有効期限日。Date オブジェクトの初期値 を表します。これは、1970 年 1 月 1 日の午前 0 時 (UTC) から経過したミリ秒単位の値です。
"issuer"アサーションを発行した ID プロバイダのホスト名。
-

"failure"

-

アサーションは不正です。この場合、JSON データ構造に 1 個の追加要素が含まれます:

- - - - - - - -
"reason"検証が失敗した理由を説明する文字列。
-

コード例

-

node.js

-

このコード例は、express.js を使用する node.js サーバを使用します。

-
var express = require("express"),
-    app = express.createServer(),
-    https = require("https"),
-    querystring = require("querystring");
-/* ... */
-
-// audience は、ブラウザのアドレスバーに表示されている URL と一致しなければなりません。
-// プロトコルとホスト名、ポート番号を含みます。
-var audience = "http://localhost:8888";
-
-app.post("/authenticate", function(req, res) {
-  var vreq = https.request({
-    host: "verifier.login.persona.org",
-    path: "/verify",
-    method: "POST"
-  }, function(vres) {
-    var body = "";
-    vres.on('data', function(chunk) { body+=chunk; } )
-        .on('end', function() {
-          try {
-            var verifierResp = JSON.parse(body);
-            var valid = verifierResp && verifierResp.status === "okay";
-            var email = valid ? verifierResp.email : null;
-            req.session.email = email;
-            if (valid) {
-              console.log("assertion verified successfully for email:", email);
-              res.json(email);
-            } else {
-              console.log("failed to verify assertion:", verifierResp.reason);
-              res.send(verifierResp.reason, 401);
-            }
-          } catch(e) {
-            console.log("non-JSON response from verifier");
-            // 検証側から偽の応答がありました!
-            res.send("bogus response from verifier!", 401);
-
-          }
-        });
-  });
-  vreq.setHeader('Content-Type', 'application/x-www-form-urlencoded');
-
-  var data = querystring.stringify({
-    assertion: req.body.assertion,
-    audience: audience
-  });
-  vreq.setHeader('Content-Length', data.length);
-  vreq.write(data);
-  vreq.end();
-  console.log("verifying assertion!");
-});
-
-
-

via Lloyd Hilaiel

-

PHP

-
$url = 'https://verifier.login.persona.org/verify';
-$assert = $_POST['assert'];
-$params = 'assertion='.$assert.'&audience=' .
-           urlencode('http://example.com:80');
-$ch = curl_init();
-$options = array(
-    CURLOPT_URL => $url,
-    CURLOPT_RETURNTRANSFER => TRUE,
-    CURLOPT_POST => 2,
-    CURLOPT_POSTFIELDS => $params
-);
-curl_setopt_array($ch, $options);
-$result = curl_exec($ch);
-curl_close($ch);
-echo $result;
-
-

Via Christian Heilmann

-- cgit v1.2.3-54-g00ecf