「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicrosofttech.osscons.jp/]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。 -戻る --[[FIDO2]] --[[Microsoft Passport]] * 目次 [#t997f2c6] #contents *概要 [#oe736650] -Web Authentication API (別名 WebAuthn) は --[[FIDO2]] の Web Application用 JavaScript Library。 --公開鍵暗号を用た認証を行う [[Credential Management API>#r3e74bd1]] の拡張機能 --パスワードを用いない認証に加え、SMS を用いない二要素認証を実現する。 -昔のサンプルは、[[makeCredential & getAssertion()メソッド>Web Authentication API(旧)]]だったが、~ 最近のサンプルは、[[navigator.credentials.create & get()メソッド>#k5ae1509]]に、変わっている。 -ややこしい --RegistrationでAttestationされる。 --AuthenticationでAssertionされる。 *詳細 [#m60489ae] -W3C で定義されている使用する (主な) API の名前は、 --[[navigator.credentials.create()メソッド>#d6d0bcf7]] --[[navigator.credentials.get()メソッド>#d385464d]] -セキュアコンテキスト (https or localhost)であることを必要とし、~ ブラウザがセキュアコンテキストで動作していない場合は利用できない。 -[[冒頭のユースケース>https://www.w3.org/TR/webauthn/#use-cases]]では、デスクトップのブラウザで操作して、~ [[登録(RegistrationでAttestation)>#z6957f0b]]と[[認証(AuthenticationでAssertion)>#ca76964e]]~ だけをスマホに転送するというユースケースが紹介されている。 **[[登録(RegistrationでAttestation)>#z6957f0b]] [#n2d59363] -[[navigator.credentials.create()メソッド>#d6d0bcf7]]を呼び出す。 -publicKeyオプションと併用する。 --[[引数:PublicKeyCredentialCreationOptions>#k26de1bf]] --[[戻り値:AuthenticatorAttestationResponse>#z3e54d7d]] **[[認証(AuthenticationでAssertion)>#ca76964e]] [#vaec9d63] -[[navigator.credentials.get()メソッド>#d385464d]]を呼び出す。 -publicKeyオプションと併用する。 --[[引数:PublicKeyCredentialRequestOptions>#j169c489]]: --[[戻り値:AuthenticatorAssertionResponse>#v1038525]]: *[[仕様>#wfcfd0f0]] [#gbc53e73] **登場人物 [#k64e5e3d] ***ユーザ [#b7693434] -ユーザ同意~ ユーザが求めている内容に同意すること -ユーザ・ハンドル --[[依拠当事者(Relying Party)>#q93a608f]]によって識別されるユーザID --64バイトの最大サイズを持つ不透明バイトシーケンス --信用証明書の数を制御するために[[依拠当事者(Relying Party)>#q93a608f]]によって使用される。~ (ユーザ・ハンドル + [[RP ID>#q93a608f]]で信用証明書が一意に決まる) ***依拠当事者(Relying Party) [#q93a608f] -Web Authentication API (別名 WebAuthn) を使用する~ Webアプリケーションで、[[RP Client>FIDO2#ad1c979d]]側と、[[RP Server>FIDO2#nff1b46f]]側がある。 -[[ユーザ>#b7693434]]の[[登録(RegistrationでAttestation)>#z6957f0b]]と[[認証(AuthenticationでAssertion)>#ca76964e]]をする。 -Relying Party Identifier(RP ID): --WebAuthn Relying Partyを識別する有効なドメイン文字列 --スキームにはhttpsが必要(ポート番号に制限はない)。 --FQDN名か、ドメイン接尾辞の何れかになる。~ https://login.example.com:1337なら、 ---FQDN名: [login.example.com] ---ドメイン接尾辞: [example.com] ***[[認証器>FIDO#lf855e22]](Authenticator) [#ze70bbe2] -[[認証器>#ze70bbe2]]アテステーション(Authenticator Attestation)~ --[[認証器>#ze70bbe2]]の製造と機能と、[[認証器>#ze70bbe2]]が発行する[[Credential Public Key、Credential ID>#w66e2b42]]、署名カウンタなどのデータを検証する作業。 --アテステーション証明書: アテステーションするために使用する秘密鍵を含むX.509証明書。 -式(Ceremony) --[[登録式(Registration Ceremony)>#z6957f0b]]に従い、[[登録(RegistrationでAttestation)>#z6957f0b]]を行うと、アテステーション(Attestation)が発行される。 --[[認証式(Authentication Ceremony)>#ca76964e]]に従い、[[認証(AuthenticationでAssertion)>#ca76964e]]を行うと、[[認証器アサーション>#ca76964e]]が発行される。 -レート制限 --ブルートフォース攻撃に対する制御を実装するプロセス。 --限度に達すると、 ---指数関数的に増加する遅延を課すか、 ---または現在の認証方式を無効にし、 ---利用可能であれば異なる認証係数を提供する。 ***クライアント [#l4e269d3] -クライアント側~ 以下を接着するすべての組み合わせ。 --クライアント・プラットフォーム --認証プロバイダ --およびすべて -クライアント・プラットフォーム --クライアント・デバイス + クライアントの組み合わせ --単一のクライアント・デバイスが、異なるクライアントを~ 実行すると異なるクライアント・プラットフォームとなる。 -(WebAuthn)クライアント --ブラウザ実装など。 --ユーザエージェントに(全体的にまたは部分的に)実装された中間的なエンティティ -クライアント・デバイス --クライアントが実行されるハードウェア・デバイス --[[認証器>#ze70bbe2]]は、クライアント・デバイスにバインドされる。 **用語 [#o046d504] -[[登録(RegistrationでAttestation)>#z6957f0b]]と -[[認証(AuthenticationでAssertion)>#ca76964e]]は 儀式であり、 この儀式では、 -[[ユーザ>#b7693434]] -[[依拠当事者>#q93a608f]] -[[認証器>#ze70bbe2]] -[[クライアント>#l4e269d3]] が共同した、 >[[ユーザの存在またはユーザ確認のテスト(式典)>#pe519ad7]] が必要になる。 ***仕組み [#w66e2b42] -Resident Credential (Client-side-resident Public Key Credential Source) --authenticatorSelection に requiredResidentKey true をセットすると[[認証器>#ze70bbe2]]に格納される。 --この中には、ユーザ情報(PublicKeyCredentialUserEntity と Credential ID)が保存される。 --[[ユーザ・ハンドル>#b7693434]] + [[RP ID>#q93a608f]]で信用証明書を選択できるという特性を有する。 --なお、Resident Credentialを登録し続けると、[[認証器>#ze70bbe2]]の登録容量が足りなくなるらしい。 --参考:~ https://blog.haniyama.com/2018/06/17/edge-support-webauthn/#resident-key-toha -Credential ID --確率的にユニークなバイトシーケンス。 --Resident Credentialと、[[認証器アサーション>#ca76964e]]を紐付けるために指定する必要がある。~ https://github.com/OpenTouryoProject/MultiPurposeAuthSite/issues/50#issuecomment-337115270 -Credential Public Key --[[登録(RegistrationでAttestation)>#z6957f0b]]時に[[認証器>#ze70bbe2]]によって生成され、[[依拠当事者(Relying Party)>#q93a608f]]に返された信用証明書の公開鍵部分 --信用証明書の公開鍵は、FIDO UAF、FIDO U2F、それに関連する本仕様書の一部において、User Public Keyと呼ばれる。 ***ユーザの存在またはユーザ確認のテスト(式典) [#pe519ad7] [[登録(RegistrationでAttestation)>#z6957f0b]]と、~ [[認証(AuthenticationでAssertion)>#ca76964e]]では、~ 以下のような、[[認証ジェスチャ>FIDO認証器#g701954e]]を行う。 -ユーザ存在テスト --ユーザが[[認証器>#ze70bbe2]]と簡単に接触することによってブール結果が生成される。 --ユーザ存在テストが正常に完了すると、ユーザは「UP : User Present」と言われる。 -ユーザ検証 --authenticatorMakeCredential + authenticatorGetAssertionで行われる。 --ユーザ検証プロセスが正常に完了すると、ユーザは「UV : User Verified」と言われる。 ***[[登録(RegistrationでAttestation)>FIDO2#e7f048cc]] [#z6957f0b] -登録式(Registration Ceremony)~ --[[ユーザの存在またはユーザ確認のテスト(式典)>#pe519ad7]] --Credential Public Keyを作成し、[[ユーザ>#b7693434]]の[[依拠当事者(Relying Party)>#q93a608f]]上のアカウントに関連付ける。 -[[認証器>#ze70bbe2]]アテステーション(Authenticator Attestation)~ authenticatorMakeCredential操作の結果として[[認証器>#ze70bbe2]]から返された、~ 署名された[[AuthenticatorAttestationResponse>#z3e54d7d]]オブジェクト。 ***[[認証(AuthenticationでAssertion)>FIDO2#dacdf419]] [#ca76964e] -認証式(Authentication Ceremony)~ --[[ユーザの存在またはユーザ確認のテスト(式典)>#pe519ad7]] --[[ユーザ>#b7693434]]の[[依拠当事者(Relying Party)>#q93a608f]]上のCredential Public Keyで、[[認証器>#ze70bbe2]]アサーションの署名を検証する。 -[[認証器>#ze70bbe2]]アサーション(Authenticator Assertion)~ authenticatorGetAssertion操作の結果として[[認証器>#ze70bbe2]]から返された、~ 署名された[[AuthenticatorAssertionResponse>#v1038525]]オブジェクト。 **依存 [#t0d61404] ***データ [#s8d69a88] -Base64url encoding --Base64ではなくBase64url --ということは、Base64urlを使用する? -CBOR --オブジェクトをバイナリ・シリアライズする使用 --基礎となるデータモデルは、JSONデータモデル[RFC4627] --参考 ---The application/json Media Type for JavaScript Object Notation (JSON)~ https://www.ietf.org/rfc/rfc4627.txt ---RFC 7049 - Concise Binary Object Representation (CBOR)~ https://tools.ietf.org/html/rfc7049 -CDDL --CBOR表記規則(CBOR [RFC7049]を表現する表記法) --JSONデータ構造の記述にも使用できる。 --CDDLの目標 ---(G1)CBORデータ構造の全体的な構造の明瞭な記述を提供する。 ---(G2)自由度をCBORデータ形式で表現する柔軟性。 ---(G3)必要に応じてフォーマットの選択を制限する可能性がある[_形式]。 ---(G4)共通のCBORデータ型および構造を表現できること。 ---(G5)人と機械が読み書き可能であること。 ---(G6)データフォーマット準拠の自動チェック。 ---(G7)さらなる処理のためにCBORデータから特定の要素を抽出する。 --参考 ---ietf-cbor-cddl - Concise data definition language (CDDL):~ a notational convention to express CBOR and JSON data structures~ https://tools.ietf.org/html/draft-ietf-cbor-cddl -COSE --CBORオブジェクト署名と暗号化(COSE)[RFC8152]。 --参考 ---RFC 8152 - CBOR Object Signing and Encryption (COSE)~ https://tools.ietf.org/html/rfc8152 -ArrayBuffer --ECMAScriptによって定義されている。 --JavaScriptでバイナリを扱うために生まれた。 --画像・音声処理などで利用されている。 --参考 ---JSのArrayBufferがよくわからなかったのでほんの少しだけ調べた - はらへり日記~ https://sota1235.hatenablog.com/entry/2016/05/30/145137 const buf = new ArrayBuffer(100); // メモリ空間の確保 const view = new Uint8Array(buf); // 1行めで確保されたメモリ空間へアクセスするための型付き配列 view[0] = 0x12; // bufの0番めに書き込んでいるのと同義 ***その他 [#f329c892] -HTML -DOM -ECMAScript -Web IDL: Webブラウザーで実装するためのAPIを記述するためのIDL -FIDO AppID:~ 呼び出し元アプリケーションのFacetIDを決定し、呼び出し元のFacetIDが~ AppIDに対して許可されているかどうかを判断するアルゴリズムを定義する。 *API [#k5ae1509] **[[登録(Attestation)>FIDO2#e7f048cc]]: navigator.credentials.create()メソッド [#d6d0bcf7] 内部で、authenticatorMakeCredentialを呼び出す。 -https://www.w3.org/TR/webauthn/#op-make-cred -https://fidoalliance.org/specs/fido-v2.0-rd-20170927/fido-client-to-authenticator-protocol-v2.0-rd-20170927.html#authenticatorMakeCredential ***引数:PublicKeyCredentialCreationOptions [#k26de1bf] -主要な引数 --rp ---id:[[RP ID>#q93a608f]] ---name:文字列 --user ---id: ---name: ---displayName: --challenge ---ランダムな情報の大きなバッファー(例えば100バイト以上)が絶対に重要。 ---登録過程のセキュリティを確保するためにサーバ上で生成する必要がある。 --timeout --pubKeyCredParams ---・・・ -オプションの引数 --attestation ---"none"(既定値)~ ユーザ名/パスワードをFIDO2に切り替える場合。~ (FIDO2はパスワードよりも優れていると考える場合) ---"indirect"~ スマートカードまたはUAFから移行する場合、~ [[認証器>#ze70bbe2]]の信頼性をattestation statement から確認する必要がある。~ クライアントがattestation statement を取得する方法を決定できる。 ---"direct"~ スマートカードまたはUAFから移行する場合、~ [[認証器>#ze70bbe2]]の信頼性をattestation statement から確認する必要がある。~ サーバーがattestation statement を必要とすることを示す。 --authenticatorSelection~ 色々なオプションを指定、その一つにResident Key のサポートなどがある。 -参考 --PublicKeyCredentialCreationOptions~ https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialcreationoptions dictionary PublicKeyCredentialCreationOptions { required PublicKeyCredentialRpEntity rp; required PublicKeyCredentialUserEntity user; required BufferSource challenge; required sequence<PublicKeyCredentialParameters> pubKeyCredParams; unsigned long timeout; sequence<PublicKeyCredentialDescriptor> excludeCredentials = []; AuthenticatorSelectionCriteria authenticatorSelection; AttestationConveyancePreference attestation = "none"; AuthenticationExtensionsClientInputs extensions; }; ***戻り値:AuthenticatorAttestationResponse [#z3e54d7d] 厳密には、PublicKeyCredential.responseに、~ AuthenticatorResponse <- AuthenticatorAttestationResponse を含む、~ PublicKeyCredential に解決する Promiseを返す。 -id(rawId) : GlobalにUniqueなPublicKeyCredentialのID(credentialId) -type : public-key(このUseCaseでは固定) -AuthenticatorAttestationResponseのプロパティ --clientDataJSON ---AuthenticatorResponseから継承 ---[[認証器>#ze70bbe2]]のauthenticatorMakeCredential()メソッドの戻り値 --attestationObject~ id(rawId) = PublicKeyCredentialのID(credentialId)に対応した、公開鍵と他の認証データ ---authenticatorData~ https://www.w3.org/TR/webauthn/#sec-authenticator-data |#|Name|Length (in bytes)|Description|h |1|rpIdHash|32|PublicKeyCredentialに関連付けられた[[RP ID>#q93a608f]]のSHA-256ハッシュ| |2|flags|1|Flags (bit 0 is the least significant bit)| |3|signCount|4|署名カウンタ(32-bit unsigned big-endian integer)| |4|attestedCredentialData|可変(存在する場合)|検証された[[認証器アテステーション(Authenticator Attestation)>#ze70bbe2]](存在する場合)| |5|extensions|可変(存在する場合)|拡張の[[認証器>#ze70bbe2]]データ| ---fmt:アテステーションステートメントの形式を示すテキスト文字列~ ("packed"、 "tpm"、 "android-key"、 "android-safetynet"、 "fido-u2f"、"none") ---attStmt:"fmt"で定義された形式のアテステーションステートメント -参考 --PublicKeyCredential interface ---https://www.w3.org/TR/webauthn/#iface-pkcredential ---https://developer.mozilla.org/ja/docs/Web/API/PublicKeyCredential --AuthenticatorAttestationResponse interface~ ---https://www.w3.org/TR/webauthn/#authenticatorattestationresponse ---https://developer.mozilla.org/ja/docs/Web/API/AuthenticatorAttestationResponse **[[認証(Assertion)>FIDO2#dacdf419]]: navigator.credentials.get()メソッド [#d385464d] 内部で、authenticatorGetAssertionを呼び出す。 -https://www.w3.org/TR/webauthn/#op-get-assertion -https://fidoalliance.org/specs/fido-v2.0-rd-20170927/fido-client-to-authenticator-protocol-v2.0-rd-20170927.html#authenticatorGetAssertion ***引数:PublicKeyCredentialRequestOptions [#j169c489] -主要な引数 "rpId": "localhost", "allowCredentials": [ --challenge ---ランダムな情報の大きなバッファー(例えば100バイト以上)が絶対に重要。 ---登録過程のセキュリティを確保するためにサーバ上で生成する必要がある。 --timeout --rpId~ --allowCredentials ---type:"public-key" ---id:id(rawId) = PublicKeyCredentialのID(credentialId) ---transports: [] (通信のヒントらしいが、空の配列が指定されている) --userVerification~ ユーザー検証要件の列挙型 ---"required" ---"preferred" ---"discouraged" -参考 --PublicKeyCredentialRequestOptions ---https://www.w3.org/TR/webauthn/#dictdef-publickeycredentialrequestoptions ---https://developer.mozilla.org/ja/docs/Web/API/PublicKeyCredentialRequestOptions dictionary PublicKeyCredentialRequestOptions { required BufferSource challenge; unsigned long timeout; USVString rpId; sequence<PublicKeyCredentialDescriptor> allowCredentials = []; UserVerificationRequirement userVerification = "preferred"; AuthenticationExtensionsClientInputs extensions; }; ***戻り値:AuthenticatorAssertionResponse [#v1038525] 厳密には、PublicKeyCredential.responseに、~ AuthenticatorResponse <- AuthenticatorAssertionResponse を含む、~ PublicKeyCredential に解決する Promiseを返す。 -id(rawId) : GlobalにUniqueなPublicKeyCredentialのID(credentialId) -type : public-key(このUseCaseでは固定) -AuthenticatorAssertionResponseのプロパティ --clientDataJSON: 型ArrayBuffer、読み取り専用 ---AuthenticatorResponseから継承 ---[[認証器>#ze70bbe2]]のauthenticatorGetAssertion()メソッドの戻り値 --authenticatorData: 型ArrayBuffer、読み取り専用 --signature: 型ArrayBuffer、読み取り専用 --userHandle: 型ArrayBuffer、読み取り専用、nullable -参考 --AuthenticatorAssertionResponse *参考 [#b22f8c0c] -[[Web Authentication API(旧)]] -fido2-net-lib https://github.com/abergs/fido2-net-lib を分析している。~ https://gist.github.com/daisukenishino2/d50bfcfa415902abfdee0e27ed48a715 **w3c [#wfcfd0f0] -Web Authentication Working Group~ https://www.w3.org/Webauthn/ --Credential Management Level 1~ https://www.w3.org/TR/credential-management-1/ --Web Authentication: An API for accessing Public Key Credentials Level 1~ https://www.w3.org/TR/webauthn/ **MDN - Web APIs [#qcf1790f] ***Credential Management API [#r3e74bd1] -Credential Management API~ https://developer.mozilla.org/ja/docs/Web/API/Credential_Management_API -Credential~ https://developer.mozilla.org/ja/docs/Web/API/Credential --PublicKeyCredential~ https://developer.mozilla.org/ja/docs/Web/API/PublicKeyCredential --PasswordCredential~ https://developer.mozilla.org/ja/docs/Web/API/PasswordCredential --FederatedCredential~ https://developer.mozilla.org/ja/docs/Web/API/FederatedCredential ***Web Authentication API [#wbffefc4] [[Credential Management API>#r3e74bd1]]中のPublicKeyCredentialを拡張したもの。 -Web Authentication API --https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API --https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API/Attestation_and_Assertion -CredentialsContainer~ https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer -PublicKeyCredential~ https://developer.mozilla.org/ja/docs/Web/API/PublicKeyCredential -AuthenticatorResponse~ https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorResponse/ --clientDataJSON~ https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorResponse/clientDataJSON -AuthenticatorAttestationResponse~ https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAttestationResponse/ --attestationObject~ https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAttestationResponse/attestationObject -AuthenticatorAssertionResponse~ https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAssertionResponse --authenticatorData~ https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAssertionResponse/authenticatorData --signature~ https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAssertionResponse/signature --userHandle~ https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAssertionResponse/userHandle **webauthn.org [#ec6dcea6] -WebAuthn demo~ https://webauthn.org --apowers313/fido2-server-demo: A set of FIDO2 / WebAuthn demo servers~ https://github.com/apowers313/fido2-server-demo/ ***fido2-net-lib [#re8fa185] -abergs/fido2-net-lib: A proof of Concept implementation library~ https://github.com/abergs/fido2-net-lib --+ demo for fido2 and WebAuthn using .NET (Work in progress)~ https://github.com/abergs/fido2-net-lib/tree/master/Fido2Demo -WebAuthn.io~ https://fido2.azurewebsites.net/ -FIDO2 - Things I learned by building a FIDO2 server – Ideas Of Anders Åberg~ http://ideasof.andersaberg.com/development/fido2-net-library **Yubico [#m94f60dc] -Yubico WebAuthn demo~ https://demo.yubico.com/webauthn/ -Developer Program~ https://www.yubico.com/why-yubico/for-developers/developer-program/ -New NIST Authentication Guidelines for Public Safety and First Responders~ https://www.yubico.com/2018/05/new-nist-authentication-guidelines-for-public-safety-and-first-responders/ ***blog.jxck.io [#u5a7037b] -Web Authentication API で FIDO U2F(YubiKey) 認証 | ~ https://blog.jxck.io/entries/2018-05-15/webauthentication-api.html --Web Authentication API (FIDO-U2F) DEMO~ https://labs.jxck.io/webauthentication/fido-u2f/ ***enjoy struggling [#ne242fa6] -Edge が WebAuthN をサポートしたらしいので色々試してみた(Insider Preview)~ https://blog.haniyama.com/2018/06/17/edge-support-webauthn/ --HWataru/webauthn-demo: WebAuthn Demo~ https://github.com/HWataru/webauthn-demo --fido-alliance/webauthn-demo: WebAuthn Demo~ https://github.com/fido-alliance/webauthn-demo ***(株)ソフト技研 [#hdc805ce] -ワンタイムパスワードトークンYubiKey~ http://yubikey.yubion.com --ブログ~ http://yubikey.yubion.com/blog.html **Qiita [#rff64274] -もうすぐ来る? Web Authentication APIについて調べてみた~ https://qiita.com/syoichi/items/62e6aa66938692a3c0b6 ---- Tags: [[:認証基盤]]