「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicrosofttech.osscons.jp/]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。 -戻る --[[ASP.NET Core]] --[[ASP.NET Identity]] * 目次 [#n9d7262b] #contents *概要 [#d3c67788] -[[ASP.NET Identity(Identity 2.0)>ASP.NET Identity]](net45)はメンテナンス・フェーズ~ -新規採用時は、[[ASP.NET Core Identity(Identity 3.0)>https://github.com/aspnet/Identity/]](netcore)の使用を検討。 *詳細 [#w7230143] **互換性 [#y0e575df] [[ASP.NET Identity(Identity 2.0)>ASP.NET Identity]](net45)と、~ [[OpenID / OAuth / OpenID Connect]]が分かっていれば差分の知識で済む。 **新機能 [#e77ce3f4] ***2要素認証 [#t410d67c] -既存のSMSを用いた2要素認証に加えて、 -[[TOTP>ワンタイム・パスワード#x917920a]]の二要素認証機能が追加されている。 --[[QRコード>https://dotnetdevelopmentinfrastructure.osscons.jp/index.php?QR%E3%82%B3%E3%83%BC%E3%83%89]]の生成には、qrcode.jsを使用する。 --[[TOTP>ワンタイム・パスワード#x917920a]]には、各種Authenticator appを使用する。 ---Google Authenticator app ---Microsoft Authenticator app -参考 --ASP.NET Core Two Factor Authentication Using Google Authenticator - DZone Security~ https://dzone.com/articles/aspnet-core-two-factor-authentication-using-google --How to set up two factor authentication in ASP.NET Core using Google Authenticator~ https://medium.freecodecamp.org/how-to-set-up-two-factor-authentication-on-asp-net-core-using-google-authenticator-4b15d0698ec9 --Microsoft Docs ---ASP.NET Core での SMS で 2 要素認証~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/2fa?view=aspnetcore-1.1 ---ASP.NET Core で TOTP authenticator アプリの QR コード生成を有効にします。~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/identity-enable-qrcodes ***STS機能 [#d9f3ef87] -[[OAuthAuthorizationServerMiddleware>ASP.NET IdentityのOAuth2によるSTS実装]]は、~ 他の[[ASP.NET Identity の Community STS]]に移行する必要がある。 他の[[ASP.NET Identity の Community STS>#ac7e5a3d]]に移行する必要がある。 -「[[汎用認証サイト>ASP.NET Identity#oe281d0a]]」では、STSをスクラッチ実装した。 *その他 [#k4c67d35] **基本的な画面の追加方法 [#eeb59cab] ***2.0まで [#ha9cc793] -従来通り、MVCのビューが追加される。 -ただしRazorではなく[[Tagヘルパー>ASP.NET Core MVC#o6d55285]]を使用する。 ***2.1から [#lb006613] -従来のMVCのビューが追加されなくなっている。 -[[Razor Class Library>#r941c0e7]] --により提要される。 --のスキャフォで追加できる模様。 ***Razor [#l51c4ad0] -とは言え、RazorでもOK。 -[[汎用認証サイト>ASP.NET Identity#oe281d0a]]では、~ [[ASP.NET Identity]] の Razor画面を移植できた。 **管理画面の追加方法 [#u64f6ec7] -[[ASP.NET Identity(Identity 2.0)>ASP.NET Identity]](net45)のUsersAdmin、RolesAdmin的な。 -[[ASP.NET Core Identity(Identity 3.0)>https://github.com/aspnet/Identity/]](netcore)に発見できず。 **[[Entity Framework]]前提の解除 [#vf8cb58f] -2.0と同じように、解除可能。 -詳しくは、[[コチラ>#eff7023d]]を参照。 **マイグレーション(移行) [#f09595aa] [[ASP.NET Identity(Identity 2.0)>ASP.NET Identity]](net45)から、~ [[ASP.NET Core Identity(Identity 3.0)>https://github.com/aspnet/Identity/]](netcore)は、~ マイグレーション(移行)というより再構築に近い。~ ***互換性が低い [#c003b1a8] -[[以下のような移行情報>#f4b12d88]]もあるが、そもそも、 --[[ASP.NETとASP.NET Coreの互換性がそれほど高くない>ASP.NET Coreへの移行]]のだが、 --以下の点も加えて、加えて、互換性は、あまり高くない。 -互換性の問題点 --ASP.NET Core Identityは、~ [[.NET Standard]]レイヤではなく[[.NET Core]]レイヤ --IUserインタフェースの廃止などがあり、~ ApplicationUser、ApplicationRoleが継承するクラスが異なる。 --メソッド・シグネチャが異なる。 --IUserStore、IRoleStore --UserManager、RoleManager、SignInManager -とは言え、[[汎用認証サイト>ASP.NET Identity#oe281d0a]]では --[[ASP.NET Identity]] --[[ASP.NET Core Identity]] >の両方をサポートしている(為せば成る的な)。 ***機能追加 [#xe299d93] -[[2要素認証>#t410d67c]]に新しい機能が追加されている。 -[[STS機能(フレームワーク)>#d9f3ef87]]が刷新されている。 *参考 [#c1a82a76] -ASP.NET Identity - CodePlex Archive~ https://archive.codeplex.com/?p=aspnetidentity --Identity 2.0 is no longer under primary development. No new features will be added, only bugs will be considered. --If Identity 3.0 does not have the feature you require then feel free to log a bug there. -aspnet/Identity:~ ASP.NET Core Identity is the membership system for building ASP.NET Core web applications, including membership, login, and user data.~ https://github.com/aspnet/Identity -aspnet/Docs:~ Docs/aspnetcore/security/authentication/identity/sample/src/ASPNETCore-IdentityDemoComplete at master~ https://github.com/aspnet/Docs/tree/master/aspnetcore/security/authentication/identity/sample/src/ASPNETCore-IdentityDemoComplete **[[Razor Class Library>ASP.NET Web Pages#e6ff0d5d]] [#r941c0e7] -asp.net identity - Where are the Login and Register pages in an AspNet Core scafolded app? - Stack Overflow~ https://stackoverflow.com/questions/50802781/where-are-the-login-and-register-pages-in-an-aspnet-core-scafolded-app -ASP.NET Core 2.1.0-preview1: Introducing Identity UI as a library | ASP.NET Blog~ https://blogs.msdn.microsoft.com/webdev/2018/03/02/aspnetcore-2-1-identity-ui/ -Scaffold Identity in ASP.NET Core projects | Microsoft Docs~ https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity **[[Entity Framework>Entity Framework Core]]前提の解除 [#eff7023d] 上級者は基本[[EF>Entity Framework Core]]キャンセル(RDB ⇔ NoSQL、LDAP切り替え等が必要な場合の考慮)。 -Writing an ASP.NET Core Identity Storage Provider from Scratch with RavenDB - Elemar JR~ http://www.elemarjr.com/en/2017/05/writing-an-asp-net-core-identity-storage-provider-from-scratch-with-ravendb/ ***Microsoft Docs [#ha371d82] -ASP.NET Core Identity 用のカスタム ストレージ プロバイダー~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/identity-custom-storage-providers ***時が癒す [#h5322942] -Identity カテゴリーの記事一覧~ http://mrgchr.hatenablog.com/archive/category/Identity --ASP.NET Core MVC にて、Entity Frameworkを使わずにASP.NET Identityを利用する Part.0(準備編) --ASP.NET Core MVC にて、Entity Frameworkを使わずにASP.NET Identityを利用する Part.1 --ASP.NET Core MVC にて、Entity Frameworkを使わずにASP.NET Identityを利用する Part.2 ***ネスケラボ [#ab920ee7] -ASP.NET Core Identity をテンプレートからカスタマイズ~ https://blog.nextscape.net/archives/Date/2017/12/aspnetidentity1 -ASP.NET Core Identity をゼロから構築する~ https://blog.nextscape.net/archives/Date/2017/12/aspnetcoreidentity2 **ASP.NET Core Identity の 外部ログイン [#hef2f3a0] ***Microsoft Docs [#p55944e3] -ASP.NET Core では、Ws-federation でユーザーを認証します。~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/ -Facebook、Google、ASP.NET Core での外部プロバイダーの認証~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/social/ --ASP.NET Core での Facebook 外部ログインのセットアップ~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/social/facebook-logins --ASP.NET Core での twitter 外部ログインのセットアップ~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/social/twitter-logins --ASP.NET Core での Google 外部ログインのセットアップ~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/social/google-logins --ASP.NET Core での Microsoft アカウントの外部ログインのセットアップ~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/social/microsoft-logins --外部の OAuth 認証プロバイダー~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/social/other-logins --その他の要求と ASP.NET Core での外部プロバイダーからのトークンを保存します。~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/social/additional-claims ***Okta [#db028707] -Okta Authentication Quickstart Guides | Okta Developer --https://developer.okta.com/quickstart/#/okta-sign-in-page/dotnet/aspnet4 --https://developer.okta.com/quickstart/#/okta-sign-in-page/dotnet/aspnetcore ***OneLogin [#l17196e2] -.NET Frameworkは、SAMLのみらしい。~ https://developers.onelogin.com/saml/c-and-aspnet -How to use OpenId Connect Authentication with Dotnet Core - OneLogin~ https://www.onelogin.com/blog/how-to-use-openid-connect-authentication-with-dotnet-core **[[ASP.NET Identity の Community STS]] [#ac7e5a3d] **[[Community STS>ASP.NET Identity の Community STS]] [#ac7e5a3d] **マイグレーション(移行) [#f4b12d88] -ASP.NET Identity から ASP.NET Core Identity へ移行してみた - しばやん雑記~ https://blog.shibayan.jp/entry/20180710/1531150250 >NormalizedUserName、NormalizedEmailなどのNormalizedXXXXには、~ .ToUpper()された値が入るもよう。これらの値は、DBの検索で利用。 -Microsoft Docs --ASP.NET Core への認証と Id を移行します。~ https://docs.microsoft.com/ja-jp/aspnet/core/migration/identity --Migrate Authentication and Identity to ASP.NET Core~ https://docs.microsoft.com/en-us/aspnet/core/migration/identity **Microsoft Docs [#b7ddd0a0] -ASP.NET Core Security の概要~ https://docs.microsoft.com/ja-jp/aspnet/core/security/ ***認証 [#scbc320a] -[[Entity Framework>Entity Framework Core]]前提 --ASP.NET core Identity の概要~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/identity --ASP.NET Core での id モデルのカスタマイズ~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/customize-identity-model -[[Entity Framework前提の解除>#eff7023d]] -構成 --ASP.NET Core Identity を構成します。~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/identity-configuration --アカウントの確認と ASP.NET Core でのパスワードの回復~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/accconfirm --ASP.NET Core で TOTP authenticator アプリの QR コード生成を有効にします。~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/identity-enable-qrcodes -その他 --ASP.NET Core での Windows 認証を構成します。~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/windowsauth --ASP.NET Core Identity なしでの cookie 認証を使用します。~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authentication/cookie ***承認 [#p656adec] -ASP.NET Core での承認の概要~ https://docs.microsoft.com/ja-jp/aspnet/core/security/authorization/introduction -ASP.NET Core 2.0: Getting Started With Identity And Role Management - TechNet Articles - TechNet Wiki~ https://social.technet.microsoft.com/wiki/contents/articles/51333.asp-net-core-2-0-getting-started-with-identity-and-role-management.aspx **その他 [#t90ddfe1] ***present [#sc0a7312] -ASP.NET Core MVC で JWT を使った認証を実装する~ https://tnakamura.hatenablog.com/entry/2017/08/04/jwt-bearer-authentication -ASP.NET Core 2.0 で JWT を使った認証を実装する~ https://tnakamura.hatenablog.com/entry/2017/08/31/use-jwt-bearer-authentication-on-aspnetcore2 ***ONE-RUN [#icdd0988] -ユーザー認証機能の実装~ https://st40.xyz/one-run/article/333/ -UseInMemoryDatabaseを使う際の注意点~ https://st40.xyz/one-run/article/334/ -AuthorizeのRolesに複数のロールを設定する~ https://st40.xyz/one-run/article/526/ -パスワードのハッシュ化(PasswordHasher、Bcrypt)~ https://st40.xyz/one-run/article/527/ ---- Tags: [[:.NET開発]], [[:.NET Core]], [[:ASP.NET]], [[:ASP.NET MVC]], [[:ASP.NET SPA]], [[ASP.NET Web API]], [[:ASP.NET Identity]], [[:認証基盤]], [[:セキュリティ]]