-
Notifications
You must be signed in to change notification settings - Fork 0
MS_Fido2NetLib
- 戻る(WebAuthnを実装する。)
- fido2-net-lib
- Web Authentication API
- FIDO認証器
- .NET Standard 対応の Web Authentication API 対応ライブラリ。
- preview も取れ、公式バージョンもリリースされたもよう。
- https://twitter.com/andersaberg/status/1156679907721797633\ After 1,5 years of development, Fido2 for .net is now OFFICIALLY released!
補足(現在の状況):
fido2-net-libはその後も更新が続いており、
NuGet パッケージ名はFido2(およびFido2.Models、
ASP.NET Core 連携用のFido2.AspNet)である。
.NET のサーバ側で WebAuthn(Relying Party)を実装する際の
事実上の標準的な選択肢になっている。
https://github.com/abergs/fido2-net-lib/blob/master/fido2-net-lib/DevelopmentInMemoryStore.cs
-
DevelopmentInMemoryStoreをデモ実装にして、
本体側は、IUserStore的な Interface のみにした方が良さそう。 - 一先ず、
WebAuthnStoreを実装して、内部を UserStoreType (mem, sql, ora, npg) で Switch。
-
storedUsersConcurrentDictionary<string, User> storedUsers = new ConcurrentDictionary<string, User>();
-
User- string Name - byte[] Id - string DisplayName
-
-
storedCredentialsList<StoredCredential> storedCredentials = new List<StoredCredential>();
-
StoredCredential- byte[] UserId - PublicKeyCredentialDescriptor Descriptor - byte[] PublicKey - byte[] UserHandle - uint SignatureCounter - string CredType - DateTime RegDate - Guid AaGuid
-
PublicKeyCredentialDescriptor- PublicKeyCredentialType? Type(enum) - byte[] Id - AuthenticatorTransport[] Transports
-
補足(
SignatureCounterとAaGuid):SignatureCounterは
認証器が署名するたびに増える値で、
サーバ側が前回値より大きいことを確認することで
認証器のクローン(複製)を検知するために使う。
AaGuidは認証器のモデルを表す識別子で、
メタデータ サービス(MDS)と突き合わせると
「どのメーカーのどの製品か」「認定を受けているか」が分かる。
-
User- User GetUser - User GetOrAddUser(string username, Func<User> addCallback) - List<User> GetUsersByCredentialIdAsync(byte[] credentialId)
-
StoredCredential- List<StoredCredential> GetCredentialsByUser(User user) - List<StoredCredential> GetCredentialsByUserHandleAsync(byte[] userHandle) - StoredCredential GetCredentialById(byte[] id) - void AddCredentialToUser(User user, StoredCredential credential) - void UpdateCounter(byte[] credentialId, uint counter)
https://github.com/abergs/fido2-net-lib/blob/master/Fido2Demo/Controller.cs
- Get from DB by username (ユーザ名で DB から取得)
- user (in our example, auto create missing users)
(ユーザ (この例では、見つからないユーザを自動作成)) - keys (キー)
- user (in our example, auto create missing users)
- Create options (MakeCredentialOptions を作成)
- Temporarily store options, session/in-memory cache/redis/db
(session/in-memory cache/redis/db の一時保存オプション) - return options to client
(クライアントに MakeCredentialOptions を返す)
- get the options we sent the client
(クライアントに送信した MakeCredentialOptions を取得) - Create callback so that lib can verify credential id is unique to this user
(信任状 ID がこのユーザに固有であることを lib が検証できるように callback を作成。) - Verify and make the credentials
(認証情報を確認して作成) - Store the credentials in db
(資格情報を db に格納) - return "ok" to the client
(クライアントに "ok" を返す)
移行メモ(誤字): 元ページの「the clientt」は「the client」の誤りである
(引用元のコード コメントに由来する可能性もあるため、
本文では修正のうえここに注記する)。
- Get from DB (DB から取得)
- user (ユーザ)
- registered credentials (登録済み資格情報)
- Create options (AssertionOptions を作成)
- Temporarily store options, session/in-memory cache/redis/db
(session/in-memory cache/redis/db の一時保存オプション) - Return options to client
(クライアントに AssertionOptions を返す)
- Get the assertion options we sent the client
(クライアントに送信した AssertionOptions を取得) - Get from database (DB から取得)
- Registered credential (登録済み資格情報)
- Credential counter (資格情報カウンタ)
- Create callback to check if userhandle owns the credentialId
(userhandle が credentialId を所有しているかどうかを確認する callback を作成) - Make the assertion
(アサーションをする) - Store the updated counter
(更新したカウンタを保存) - return OK to client
(クライアントに "ok" を返す)
補足(options の一時保存が要になる): 4 つの手順すべてに
「送った options を取り出す」という段が入っている点が要点である。
WebAuthn の検証はサーバが直前に発行した challenge との照合が前提なので、
options をセッション等に保持しておかないと
リプレイ攻撃を防げない。
ステートレスにしたい場合は、challenge を署名付きトークンにして
クライアントに預ける方式を取る。
- NuGet Gallery
- Fido2
https://www.nuget.org/packages/Fido2/ - Fido2NetLib
登録ミス(若しくはリネーム)
- Fido2
abergs/fido2-net-lib: FIDO2 .NET library for FIDO2 / WebAuthn Attestation and Assertion using .NET
https://github.com/abergs/fido2-net-lib
- 本体
https://github.com/abergs/fido2-net-lib/tree/master/fido2-net-lib - デモ
https://github.com/abergs/fido2-net-lib/tree/master/Fido2Demo
Latest Posts
http://ideasof.andersaberg.com/
- FIDO2 - Things I learned by building a FIDO2 server
http://ideasof.andersaberg.com/development/fido2-net-library - The passwordless web is coming
http://ideasof.andersaberg.com/development/the-passwordless-web
https://twitter.com/openhishopjpo/status/1101432292419895296
現在、分析中。
- 2018/08/29
https://gist.github.com/daisukenishino2/d50bfcfa415902abfdee0e27ed48a715 - 2019/03/03
https://gist.github.com/daisukenishino2/f09fb400fa2186aead4b6f8cad59ab38
-
Phase1
https://gist.github.com/daisukenishino2/204f16d612831421ab7451861a29c001 -
Phase2
...MDS 実装や、様々なオプションでのテストなどを予定...
- DataProvider.cs
- WebAuthnHelper.cs
- https://github.com/OpenTouryoProject/MultiPurposeAuthSite/blob/develop/root/programs/MultiPurposeAuthSite/MultiPurposeAuthSite/Views/Home/WebAuthnStarters.cshtml
- https://github.com/OpenTouryoProject/MultiPurposeAuthSite/blob/develop/root/programs/MultiPurposeAuthSite/MultiPurposeAuthSite/Controllers/Fido2ServerController.cs
移行メモ(表記): 元ページの見出しは「HTPM + WebAPI」だったが、
挙げられているのが Razor ビュー(.cshtml)とコントローラーであることから
「HTML + WebAPI」の誤りと判断して修正した。
- https://github.com/OpenTouryoProject/MultiPurposeAuthSite/blob/develop/root/programs/MultiPurposeAuthSite/MultiPurposeAuthSite/Scripts/touryo/arrayBufferUtil.js
- https://github.com/OpenTouryoProject/MultiPurposeAuthSite/blob/develop/root/programs/MultiPurposeAuthSite/MultiPurposeAuthSite/Scripts/touryo/webauthn.js
Tags: IT国際標準, 認証基盤
このWikiは「Open棟梁Project」,「OSSコンソーシアム 開発基盤部会」によって運営されています。