【 FIDO Conformance Toolsメモ 】イントロダクション

はじめに

FIDO Conformance Toolsのテストのクリアを目指してやっていきます。これはその奮闘記です。
そもそもWebAuthnのRelying Party実装ってどうやるの?という方は以前、資料を作ったので目を通していただけると幸いです。

www.slideshare.net

こちら以外にも実装に役立ちそうなリンクを参考に貼っておきますので合わせて見ていただければと思います。

FIDO Conformance Toolsの取得

そもそもFIDO Conformance Toolsはどうやって取得できるのか説明します。
テストツールは誰でも取得できる訳ではなく、以下のページからテストツールへのアクセスを要求して承認される必要があります。

fidoalliance.org

テストツールへのアクセス要求画面は以下のようになっています。承認されると数日後にテストツールのURLやらID、パスワードなどがメールで届きます。 f:id:kent056-n:20190219212321p:plain

承認される条件はよくわかりませんが、自分はCompany NameとFIDO Memberが空欄のままで大丈夫でした。

テスト項目

そもそもどういったテストが行われるのかですが、以下に記載されている仕様を満たしていくイメージになります。

https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html

自分が利用しているバージョンv0.10.110(BETA)(BETA FIDO2)では合計158のテストが存在します。
テストの大項目としては以下のようになっています。

PublicKeyCredentialsCreation

  • Server-ServerAuthenticatorAttestationResponse-Resp-1 Test server processing ServerAuthenticatorAttestationResponse structure
  • Server-ServerAuthenticatorAttestationResponse-Resp-2 Test server processing CollectClientData
  • Server-ServerAuthenticatorAttestationResponse-Resp-3 Test server processing AttestationObject
  • Server-ServerAuthenticatorAttestationResponse-Resp-4 Test server support of the authentication algorithms
  • Server-ServerAuthenticatorAttestationResponse-Resp-5 Test server processing "packed" FULL attestation
  • Server-ServerAuthenticatorAttestationResponse-Resp-6 Test server processing "packed" SELF(SURROGATE) attestation
  • Server-ServerAuthenticatorAttestationResponse-Resp-7 Test server processing "none" attestation
  • Server-ServerAuthenticatorAttestationResponse-Resp-8 Test server processing "fido-u2f" attestation
  • Server-ServerAuthenticatorAttestationResponse-Resp-9 Test server processing "tpm" attestation
  • Server-ServerAuthenticatorAttestationResponse-Resp-A Test server processing "android-key" attestation
  • Server-ServerAuthenticatorAttestationResponse-Resp-B Test server processing "android-safetynet" attestation
  • Server-ServerPublicKeyCredentialCreationOptions-Req-1 Test server generating ServerPublicKeyCredentialCreationOptionsRequest

    GetAssertion

  • Server-ServerAuthenticatorAssertionResponse-Resp-1 Test server processing ServerAuthenticatorAssertionResponse structure
  • Server-ServerAuthenticatorAssertionResponse-Resp-2 Test server processing CollectClientData
  • Server-ServerAuthenticatorAssertionResponse-Resp-3 Test server processing authenticatorData
  • Server-ServerPublicKeyCredentialGetOptionsResponse-Req-1 Test server generating ServerPublicKeyCredentialGetOptionsResponse

    MDS

  • Server-ServerAuthenticatorAttestationResponse-Resp-1 Test server processing ServerAuthenticatorAttestationResponse structure

FIDO Conformance Toolについて

利用イメージ

今回利用しているテストツールのバージョンはv0.10.110(BETA)(BETA FIDO2)になります。
現状、macOSで動作するものではこちらのバージョンが最新のようです。
テストツールを起動すると以下のような表示がでてきます。自分はFIDO2 Testsをやっていきますが、FIDO2 以外も試せそうです。

f:id:kent056-n:20190219230454p:plain

FIDO2 Testsを選択すると以下のような画面が表示されます。
Server Testsにチェックを入れ、Server URL(http://localhost:3000など)を入力することで検証が行われます。

f:id:kent056-n:20190219230652p:plain

動作イメージ

まず、FIDO Conformance Toolsの動作イメージについて。
FIDO Conformance ToolsはElectron製であり、以下のようなに動作していそうです。

f:id:kent056-n:20190221200633p:plain

サーバーのURLを入力すると特定のパスに対してリクエストを送信し、そのレスポンスをチェックしているようです。
あくまで各パスに対してリクエストを送信し、レスポンスを検証しているだけなので、フロントエンドとバックエンドが分離しているような構成のRPの方がテストしやすいかもしれません。(サーバーサイドレンダリングしているバターンだとテストし辛そう??)

確認推奨事項

まず、テストする前に最低限以下を確認しておいた方が良さそうです。

  • FIDO Conformance Toolsがリクエストを送信するエンドポイントが用意されているか
  • FIDO Conformance Toolsが送信するパラメーターを受け取れる状態か
  • FIDO Conformance Toolsが検証できるようなレスポンスの形式か

上記についてそれぞれ説明していきます。

FIDO Conformance Toolsがリクエストを送信するエンドポイントが用意されているか

具体的に必要なエンドポイントは以下の4つになります。

  • /attestation/options
  • /attestation/result
  • /assertion/options
  • /assertion/result

それぞれのパスで行う処理に関しては以下に詳細に記載されているのでここでは割愛します。 techblog.yahoo.co.jp

FIDO Conformance Toolsが送信するパラメーターを受け取れる状態か

以下、実際にConformance Toolsから送信されていたパラメーターの一つになります。 f:id:kent056-n:20190219214045p:plain displayNameusernameattestationというkeyに対してvalueが入っているのが確認できます。
つまり、RP側で上記の名前でパラメーターを受け取るように実装していないと、ユーザー名が見つけられない等の思いがけないエラーとなります。
それぞれのパスに対して送信される具体的なリクエストはこちらを参考にすれば問題ないでしょう。
https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html#examples

FIDO Conformance Toolsが検証できるようなレスポンスの形式か

RPではConformance Toolsが送信したリクエストに対して、期待しているレスポンスを返さなければなりません。
そのためには、レスポンスがConformance Tools受け取れ検証できる形式でなければならないという前提があります。 具体的にどういったレスポンスを返せばよいのかも以下を参考にしてください。
https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html#examples

おわりに

何かしらの認証器で登録および認証ができ、今回紹介した内容をクリアすると大体スタートラインに立てたイメージです。 (↓自分のスタート時)

ここまでできたら、対応するAttestationを増やしたり、バリデーションの処理を増やしたりしてテストを地道にパスして行く作業に入ります。 自分もこの記事を書いている段階で passes : 129、falilures : 29 なのでまだまだ先は長いですが頑張っていきましょう。

f:id:kent056-n:20190219215910p:plain

引き続き、キリが良いタイミング(特定の項目を全部パスしたなど)で更新していこうと思います。

参考

https://techblog.yahoo.co.jp/advent-calendar-2018/webauthn/ https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html https://fidoalliance.org/certification/functional-certification/conformance/ https://github.com/fido-alliance/webauthn-demo https://medium.com/@herrjemand/introduction-to-webauthn-api-5fd1fb46c285 https://speakerdeck.com/ynojima/webauthn-from-the-relying-party-view