「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicrosofttech.osscons.jp/]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。

-[[戻る>Web Authentication API]]

* 目次 [#e714d9cd]
#contents

*概要 [#ve68877a]
-[[WebAuthn>Web Authentication API]]を実装する前に理解を深める。
-specレベルは上位項を参照のこと。

*詳細 [#h2a3b42d]
以下に、各種、調査結果をサマリーする(まだまだ理解不足です)。

**登録フロー [#xedb9d2b]

***(1) challengeの受信 [#l5e6e253]
-fido2-net-lib ... [[サーバー側で処理>fido2-net-lib#f89b4f96]]
--request
--[[response>https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-1-response-from-makecredentialoptions-webapi-json]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/33]]
--[[request>https://www.slideshare.net/techblogyahoo/fido-124019677/35]]
--[[response>https://www.slideshare.net/techblogyahoo/fido-124019677/36]]

***(2) navigator.credentials.create() の param [#u04b283d]
-[[spec>Web Authentication API#k26de1bf]]

-[[fido2-net-lib>https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-2-parameter-of-navigator-credentials-create]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/38]]

|#|>|パラメタ|必須 / 任意|説明|フォーマット|h
|1|>|rp|必須|Relying partyに関する情報|[[JSON]] Object (下記メンバを持つ)|
|1-1|・|id|~|FQDN名|String|
|1-2|・|name|~|任意のRPサイト名|String|
|2|>|user|必須|Credentialが紐づくユーザー情報|[[JSON]] Object (下記メンバを持つ)|
|2-1|・|id|~|RP上のユーザID|ArrayBuffer|
|2-2|・|name|~|RP上のユーザID|String|
|2-3|・|displayName|~|RP上のユーザ表示名|String|
|3|>|challenge|必須|サーバーで生成した乱数|ArrayBuffer|
|4|>|pubKeyCredParams|必須|Credential情報|[[JSON]] Objectの配列|
|4-1|・|type|~|タイプ(public-key固定)|String|
|4-2|・|alg|~|アルゴリズムを表す数値|Int|
|5|>|timeout|任意|ユーザーの入力待機時間|Int|
|6|>|[[attestation>#y9d814dd]]|任意|Authenticator自体の検証|[[JSON]] Object (AttestationConveyancePreference)|
|7|>|[[authenticatorSelection>#y9d814dd]]|任意|認証器への要求事項|[[JSON]] Object (AuthenticatorSelectionCriteria)|
|8|>|excludeCredentials|任意||[[JSON]] Object (PublicKeyCredentialDescriptor)|

***(3) navigator.credentials.create() の return [#head8b53]
-[[spec>Web Authentication API#z3e54d7d]]

-[[fido2-net-lib>https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-3-return-of-navigator-credentials-create]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/42]]

|#      |>|>|>|>|パラメタ|説明|フォーマット|h
|1      |>|>|>|>|id|割り当てられたid|rawIdの文字列表現|
|2      |>|>|>|>|rawId|idのArrayBuffer版|ArrayBuffer|
|3      |・|>|>|>|response|AuthenticatorAttestationResponse|[[JSON]] Object (AuthenticatorAttestationResponse)|
|3-1    ||・|>|>|attestationObject|公開鍵などを含む|[[CBOR]]形式|
|3-1-1  |||・|>|fmt|Attestation format|"fmt": "packed"|
|3-1-2  |||・|>|authData|Raw buffer struct containing user info|"authData": "..."|
|3-1-3  |||・|>|attStmt|Attestation statement data|"attStmt": {|
|3-1-3-1||||・|sig|Signature|"sig": "..."|
|3-1-3-2||||・|x5c"|X.509 Certificate Chain|"x5c": ["..."]|
|3-2    ||・|>|>|clientDataJSON|クライアント・データ|[[CBOR]]形式|
|3-2-1  |||・|>|challenge|Random number|"challenge": "..."|
|3-2-2  |||・|>|origin|Origin of the website|"origin": "http(s)://..."|
|3-2-3  |||・|>|type|Type of the call|"type": "webauthn.create"|
|4      |>|>|>|>|type|pubKeyCredParams - typeと同じ|"type": "public-key"|
|#       |>|>|>|>|パラメタ|説明|フォーマット|h
|1       |>|>|>|>|id|割り当てられたid|rawIdの文字列表現|
|2       |>|>|>|>|rawId|idのArrayBuffer版|ArrayBuffer|
|3       |・|>|>|>|response|AuthenticatorAttestationResponse|[[JSON]] Object (AuthenticatorAttestationResponse)|
|3-1     ||・|>|>|attestationObject|公開鍵などを含む|[[CBOR]]形式|
|3-1-1   |||・|>|fmt|Attestation format|"fmt": "packed"|
|3-1-2   |||・|>|authData|Raw buffer struct containing user info|"authData": "{rpIdHash: "..." ,... }"|
|3-1-2-1 ||||・|rpIdHash|||
|3-1-2-2 ||||・|flags|||
|3-1-2-3 ||||・|flagsBuf|||
|3-1-2-4 ||||・|counter|||
|3-1-2-5 ||||・|counterBuf|||
|3-1-2-6 ||||・|aaguid|||
|3-1-2-7 ||||・|credID|||
|3-1-2-8 ||||・|credIDLen|||
|3-1-2-9 ||||・|credIDLenBuf|||
|3-1-2-10||||・|COSEPublicKey|||
|3-1-3   |||・|>|attStmt|Attestation statement data|"attStmt": {sig: "", x5c: ""}|
|3-1-3-1 ||||・|sig|Signature|"sig": "..."|
|3-1-3-2 ||||・|x5c|X.509 Certificate Chain|"x5c": ["..."]|
|3-2     ||・|>|>|clientDataJSON|クライアント・データ|[[CBOR]]形式|
|3-2-1   ||||・|challenge|Random number|"challenge": "..."|
|3-2-2   ||||・|origin|Origin of the website|"origin": "http(s)://..."|
|3-2-3   ||||・|type|Type of the call|"type": "webauthn.create"|
|4       |>|>|>|>|type|pubKeyCredParams - typeと同じ|"type": "public-key"|

***(4) challenge、origin、typeの検証 [#vb30e592]
-[[fido2-net-lib>https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-4-request-to-makecredential-webapi-json]] ... [[サーバー側で処理>fido2-net-lib#m0f94989]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/49]]
-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/49]]~
clientDataJSONの...
--[[challenge>https://www.slideshare.net/techblogyahoo/fido-124019677/51]]~
param.challenge = return.clientDataJSON.challenge みたいな話。
--[[origin>https://www.slideshare.net/techblogyahoo/fido-124019677/52]]~
xxxx = return.clientDataJSON.origin みたいな話。
--[[type>https://www.slideshare.net/techblogyahoo/fido-124019677/53]]~
"webauthn.create" = return.clientDataJSON.type みたいな話。

***(5) flagsの検証 [#pe1d0784]
-fido2-net-lib ... [[サーバー側で処理>fido2-net-lib#m0f94989]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/54]]
--UP : User Presence~
ユーザーの存在確認(必須) 
--UV : User Verification~
ユーザーの認証(任意)

***(6) signatureの検証 [#j1fd7b8b]
-fido2-net-lib ... [[サーバー側で処理>fido2-net-lib#m0f94989]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/57]]
>[[authDataをattStmt.x5cで署名した値 = attStmt.sig みたいな話。>https://www.slideshare.net/techblogyahoo/fido-124019677/58]]

***(7) 公開鍵の保存 [#t769d565]
-fido2-net-lib ... [[サーバー側で処理>fido2-net-lib#m0f94989]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/63]]
>[[COSE]]から[[公開鍵を取り出して、>CWT#edb8c145]]保存する。

**認証フロー [#lc23111a]

***(1) challengeの受信 [#vbc77f66]
-fido2-net-lib ... [[サーバー側で処理>fido2-net-lib#ue95e631]]
--[[request>https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-6-request-to-assertionoptions-webapi-json]]
--[[response>https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-7-response-from-assertionoptions-webapi-json]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/70]]
--[[request>https://www.slideshare.net/techblogyahoo/fido-124019677/72]]
--[[response>https://www.slideshare.net/techblogyahoo/fido-124019677/73]]

***(2) navigator.credentials.get() の param [#ja036073]
-[[spec>Web Authentication API#j169c489]]

-[[fido2-net-lib>https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-8-parameter-of-navigator-credentials-get]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/75]]

|#|パラメタ|必須 / 任意|説明|フォーマット|h
|1|challenge|必須|サーバーで生成した乱数|ArrayBuffer|
|2|timeout|任意|ユーザーの入力待機時間|Int|
|3|rpId|任意|rpIdの指定(登録時と同じ値を指定)|String|
|4|allowCredentials|任意|ユーザに紐づくCredentialのリスト|Array (PublicKeyCredentialDescriptor)|
|5|[[userVerification>#y9d814dd]]|任意|ユーザ検証に関する要件|String (enum UserVerificationRequirement)|

***(3) navigator.credentials.get() の return [#v312bbc2]
-[[spec>Web Authentication API#v1038525]]

-[[fido2-net-lib>https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-9-return-of-navigator-credentials-get]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/79]]

|#|>|パラメタ|説明|フォーマット|h
|1|>|id|割り当てられたid|rawIdの文字列表現|
|2|>|rawId|idのArrayBuffer版|ArrayBuffer|
|3|>|response|assertion data|[[JSON]] Object (AuthenticatorAssertionResponse)|
|3-1|・|authenticatorData||ArrayBuffer|
|3-2|・|clientDataJSON||ArrayBuffer|
|3-3|・|signature||ArrayBuffer|
|3-4|・|userHandle||ArrayBuffer|
|4|>|type|タイプ(public-key固定)|String|
|5|>|getClientExtensionResults|extensions results struct||
|#    |>|>|パラメタ|説明|フォーマット|h
|1    |>|>|id|割り当てられたid|rawIdの文字列表現|
|2    |>|>|rawId|idのArrayBuffer版|ArrayBuffer|
|3    |>|>|response|assertion data|[[JSON]] Object (AuthenticatorAssertionResponse)|
|3-1  |・|>|authenticatorData|rpIdHash, flagsBuf, flags, counter, counterBuf|ArrayBuffer|
|3-2  |・|>|clientDataJSON|クライアント・データ|ArrayBuffer|
|3-2-1||・|challenge|Random number|"challenge": "..."|
|3-2-2||・|origin|Origin of the website|"origin": "http(s)://..."|
|3-2-3||・|type|Type of the call|"type": "webauthn.create"|
|3-3  |・|>|signature|署名の値|ArrayBuffer|
|3-4  |・|>|userHandle|認証器が返す値|ArrayBuffer|
|4    |>|>|type|タイプ(public-key固定)|String|
|5    |>|>|getClientExtensionResults|extensions results struct||

***(4) challenge、origin、typeの検証 [#c7de901d]
-[[fido2-net-lib>https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-a-request-to-makeassertion-webapi-json]] ... [[サーバー側で処理>fido2-net-lib#xad0155b]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/84]]
-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/84]]~
clientDataJSONの...
--[[challenge>https://www.slideshare.net/techblogyahoo/fido-124019677/85]]~
param.challenge = return.clientDataJSON.challenge みたいな話。
--[[origin>https://www.slideshare.net/techblogyahoo/fido-124019677/86]]~
xxxx = return.clientDataJSON.origin みたいな話。
--[[type>https://www.slideshare.net/techblogyahoo/fido-124019677/87]]~
"webauthn.create" = return.clientDataJSON.type みたいな話。

***(5) flagsの検証 [#pc3d8dee]
-fido2-net-lib ... [[サーバー側で処理>fido2-net-lib#xad0155b]]
-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/88]]
-fido2-net-lib ... [[サーバー側で処理>fido2-net-lib#xad0155b]]~
-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/88]]~
authenticatorData.flags
--UP : User Presence~
ユーザーの存在確認(必須) 
--UV : User Verification~
ユーザーの認証(任意)

***(6) signatureの検証 [#z00f8626]
-fido2-net-lib ... [[サーバー側で処理>fido2-net-lib#xad0155b]]

-[[techblogyahoo>https://www.slideshare.net/techblogyahoo/fido-124019677/90]]
--Authenticatorの検索
--PublicKeyの取得
--signatureを検証
--counterの検証と更新

*実装例 [#c959ed41]

**提案されたI/F [#c50d2962]
[[FIDO2]]サーバ標準は存在しないが、

-[[FIDO2]]適合テストツールで使用する提案されたREST APIのI/Fは存在する。

-このI/Fは必須で無いが、Serverが標準の方法でMessageを送受信することで~
適合テストツールによって使用され、機能が自動的に検証されるようにできる。

-問題点

--登録フローには、認証が必要だと思うのだケド、~
認証実装したらテストツールも通らないんじゃないか?と。

--以下の[[サーバ実装パターン>#p32f0b0d]]毎、実際の実装は変わってきそう。
>「[[RP & BaaSが実装>#yd0d2c38]]」に書いたように、~
Resource Serverとして動作する~
BaaS上に実装する方式に適合しそう。

-参考
--Server Requirements and Transport Binding Profile~
https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html

***Credential Creation Options [#rec1f227]
-https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html#example-credential-creation-options
-https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-1-response-from-makecredentialoptions-webapi-json

***Authenticator Attestation [#b71f68ec]
-https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html#example-authenticator-attestation-response
-https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-4-request-to-makecredential-webapi-json

***Credential Get Options [#tce204b7]
-https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html#authentication-example-credential-get-options
-https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-6-request-to-assertionoptions-webapi

***Authenticator Assertion [#l620d540]
-https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-server-v2.0-rd-20180702.html#authentication-example-authenticator-assertion-response
-https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#file-a-request-to-makeassertion-webapi-json

**サーバ実装パターン [#p32f0b0d]
[[OIDCのSTS/IdP(OP)、Client(RP)>OpenID Connect]]のどちらでも~
[[WebAuthn>Web Authentication API]]のRelying Party(RP)になれる。

***IdP/Stsが実装 [#te3090c2]
-IdP/Stsに集約可能で楽。

-[[提案されたI/F>#c50d2962]]の実装
--登録フロー~
認証アクセスが必要だが、サイト内なのでWebAPIよりポストバックがイイ
--認証フロー~
認証後に画面遷移が必要なのでWebAPIよりポストバックがイイ

***RP & BaaSが実装 [#yd0d2c38]
-折衷案
--RPが[[WebAuthn>Web Authentication API]]を操作し、
--バックエンドのIDaaS -> BaaSを使用して公開鍵を管理する。

-[[提案されたI/F>#c50d2962]]の実装
--登録フロー~
RPは、IdP/Stsと連携し、~
Resource Serverとして機能するBaaSに公開鍵を登録。
--認証フロー~
BaaSに登録した公開鍵を取得するために、~
[[Client認証のみのグラント種別>JWTとOAuth2.0#pebd83d3]]を使用しRPの認証をする。

***RPが実装 [#n65330d1]
-IdP/Sts
--のコントロールが効かない場合。
--を、そもそも、保有しない場合。

-[[提案されたI/F>#c50d2962]]の実装~
[[IdP/Stsが実装>#te3090c2]]の実装と同様。

**実現できるUX [#n55e981e]

***[[2FAのUserExperience]] [#z7587e1a]

***[[PasswordlessのUserExperience]] [#v5fe671c]

*参考 [#m98eeaca]

**[[fido2-net-lib]] [#k952458b]

**techblogyahoo [#ge4fa39c]
-FIDO認証によるパスワードレスログイン実装入門 > デモ~
https://www.slideshare.net/techblogyahoo/fido-124019677/29

***[[登録フロー>https://www.slideshare.net/techblogyahoo/fido-124019677/30]] [#c3d1bc55]
-[[実装範囲>https://www.slideshare.net/techblogyahoo/fido-124019677/32]]

-準備
--[[ユーザー名の入力>https://www.slideshare.net/techblogyahoo/fido-124019677/34]]
--[[ユーザ名の送信>https://www.slideshare.net/techblogyahoo/fido-124019677/35]]
--[[challengeの受信>https://www.slideshare.net/techblogyahoo/fido-124019677/36]]

-[[navigator.credentials.create()>https://www.slideshare.net/techblogyahoo/fido-124019677/37]] の
--[[param>https://www.slideshare.net/techblogyahoo/fido-124019677/38]]
--[[return>https://www.slideshare.net/techblogyahoo/fido-124019677/42]]

-[[検証>https://www.slideshare.net/techblogyahoo/fido-124019677/49]]

--[[challenge、origin、typeの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/50]]
---[[challengeの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/51]]
---[[originの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/52]]
---[[typeの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/53]]

--[[flagsの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/54]]

--[[signatureの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/57]]
---[[Attestation Certificateの取得>https://www.slideshare.net/techblogyahoo/fido-124019677/59]]
---[[signatureを検証>https://www.slideshare.net/techblogyahoo/fido-124019677/60]]

-[[保存>https://www.slideshare.net/techblogyahoo/fido-124019677/63]]
--[[公開鍵の保存 (1)>https://www.slideshare.net/techblogyahoo/fido-124019677/64]]
--[[公開鍵の保存 (2)>https://www.slideshare.net/techblogyahoo/fido-124019677/65]]
--[[公開鍵の保存 (3)>https://www.slideshare.net/techblogyahoo/fido-124019677/66]]

***[[認証フロー>https://www.slideshare.net/techblogyahoo/fido-124019677/67]] [#a9244aab]
-[[実装範囲>https://www.slideshare.net/techblogyahoo/fido-124019677/69]]

-[[準備>https://www.slideshare.net/techblogyahoo/fido-124019677/70]]
--[[ユーザー名の入力>https://www.slideshare.net/techblogyahoo/fido-124019677/71]]
--[[ユーザ名の送信>https://www.slideshare.net/techblogyahoo/fido-124019677/72]]
--[[challengeの受信>https://www.slideshare.net/techblogyahoo/fido-124019677/73]]

-[[navigator.credentials.get()>https://www.slideshare.net/techblogyahoo/fido-124019677/74]] の
--[[param>https://www.slideshare.net/techblogyahoo/fido-124019677/75]]
--[[return>https://www.slideshare.net/techblogyahoo/fido-124019677/79]]

-[[検証>https://www.slideshare.net/techblogyahoo/fido-124019677/83]]

--[[challenge、origin、typeの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/84]]
---[[challengeの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/85]]
---[[originの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/86]]
---[[typeの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/87]]

--[[flagsの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/88]]

--[[signatureの検証>https://www.slideshare.net/techblogyahoo/fido-124019677/90]]
---[[Authenticatorの検索>https://www.slideshare.net/techblogyahoo/fido-124019677/92]]
---[[PublicKeyの取得>https://www.slideshare.net/techblogyahoo/fido-124019677/93]]
---[[signatureを検証>https://www.slideshare.net/techblogyahoo/fido-124019677/95]]
---[[ counterの検証と更新>https://www.slideshare.net/techblogyahoo/fido-124019677/96]]

**パラメタ [#y9d814dd]

***[[Web Authentication API]] [#j0811b10]
-[[navigator.credentials.create()メソッド>Web Authentication API#d6d0bcf7]]
-[[navigator.credentials.get()メソッド>Web Authentication API#d385464d]]

***gist.github.com/daisukenishino2 [#r368d093]
https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38#gistcomment-2852202

***Ackermann Yuriy – Medium [#v0c30aea]
-Introduction to WebAuthn API~
https://medium.com/@herrjemand/introduction-to-webauthn-api-5fd1fb46c285

***enjoy struggling [#j9dcdad6]
-Webauthn における ResidentKey と UserVerification について~
https://blog.haniyama.com/2018/10/19/webauthn-residentkey/
-WebAuthn の Attestation~
https://blog.haniyama.com/2018/11/19/webauthn-attestation/

***Qiita [#u32b017f]
-FIDOによるChromeとMacBook Proのtouch idを利用したパスワードレスログインの実装~
https://qiita.com/ifsec_56/items/0cc5f1d73e7d2e3029ad

**ritou [#e6549dc4]

***r-weblife [#o24b3d4a]
-WebAuthn カテゴリーの記事一覧~
https://ritou.hatenablog.com/archive/category/WebAuthn

-OpenID Connect のあれが WebAuthn のこれになったらどうなるかって話~
https://ritou.hatenablog.com/entry/2018/09/28/032327
--OIDC OP == WebAuthn RP
--OIDC RP == WebAuthn RP

***Qiita [#sd089730]

-WebAuthn の利用/実装パターンを考える - Qiita~
https://qiita.com/ritou/items/e32239dd482e8dc765d6

----
Tags: [[:IT国際標準]], [[:認証基盤]]



トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS