日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

第44章 通过GoogleAuthenticator插件执行登录操作

發布時間:2023/12/20 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第44章 通过GoogleAuthenticator插件执行登录操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?119 CustomerChangeMultiFactorAuthenticationProviderEvent、MultiFactorAuthenticationProviderModel、MultiFactorAuthenticationModel

??? CustomerChangeMultiFactorAuthenticationProviderEvent類,“EventPublisher.PublishAsync”方法通過調用該類的實例,自動的從靜態緩存數據庫/分布式緩存數據庫中,移除與指定用戶多因素身份認證相關的一些緩存數據(不管這些緩存數據是否已經達到相應的緩存時間)。

??? MultiFactorAuthenticationProviderModel紀錄,通過紀錄及其成員,為多因素身份認組件在頁面中的綁定及其顯示提供數據支撐。

??? MultiFactorAuthenticationModel紀錄,通過紀錄及其成員,為我的多因素身份認證頁面的綁定及其顯示提供數據支撐。

  • 取消Nop.Services.Installation.InstallationService.InstallSettingsAsync.MultiFactorAuthenticationSettings設置前的注釋。
  • 2、取消Nop.Services.Customers.CustomerRegistrationService.ValidateCustomerAsync方法中對下列語句的注釋。??

    var selectedProvider = await _genericAttributeService.GetAttributeAsync<string>(customer, NopCustomerDefaults.SelectedMultiFactorAuthenticationProviderAttribute);

    ??????????? var methodIsActive = await _multiFactorAuthenticationPluginManager.IsPluginActiveAsync(selectedProvider, customer, (await _storeContext.GetCurrentStoreAsync()).Id);

    ??????????? if (methodIsActive)

    ??????????????? return CustomerLoginResults.MultiFactorAuthenticationRequired;

    2、重構Nop.Web.Infrastructure.RouteProvider.RegisterRoutes方法,取消對該方法中下列語句的注釋。

    //我的多因素身份認證提供程序配置頁面的路由映射。

    ??????????? endpointRouteBuilder.MapControllerRoute(name: "CustomerMultiFactorAuthenticationProviderConfig",

    ??????????????? pattern: $"{lang}/customer/providerconfig",

    ??????????????? defaults: new { controller = "Customer", action = "ConfigureMultiFactorAuthenticationProvider" });

    ?? //我的多因素身份認證設定頁面的路由映射。

    ??????????? endpointRouteBuilder.MapControllerRoute(name: "MultiFactorAuthenticationSettings",

    ??????????????? pattern: $"{lang}/customer/multifactorauthentication",

    3、重構Nop.Web.Factories.IcustomerModelFactory和Nop.Web.Factories.CustomerModelFactory,取消對下列方法的注釋:

    PrepareMultiFactorAuthenticationModelAsync

    PrepareMultiFactorAuthenticationProviderModelAsync

    4、在Nop.Web.Controllers.CustomerController定義以下方法:

    ParseSelectedProviderAsync

    MultiFactorVerification

    MultiFactorAuthentication

    [HttpPost] MultiFactorAuthentication

    ConfigureMultiFactorAuthenticationProvider

    GoogleAuthenticator插件執行登錄操作

    ??? 1、按F5通過初始化安裝頁面,安裝數據庫及其默認數據。

    2、通過后臺頁面“https://localhost:44303/Admin/Authentication/MultiFactorMethods”啟用GoogleAuthenticator插件,最終效果如下圖:

    ?

    3、通過前臺頁面“https://localhost:44303/customer/multifactorauthentication”對GoogleAuthenticator插件進行配置,最終效果如下圖:

    ??? 注意:先點擊“保存”按鈕把當前面中的設置數據信息持久化保存到數據庫相應的表中。然后再點擊“配置”按鈕,以用于把當前程序與手機端“GoogleAuthenticator”進行綁定設定。

    ?4、通過前臺頁面“https://localhost:44303/customer/providerconfig?providerSysName=MultiFactorAuth.GoogleAuthenticator” 把當前程序與手機端“GoogleAuthenticator”app進行綁定設定,最終效果如下圖:

    ?

    5、關閉整個瀏覽器,再重啟使用本地登錄后會直接跳轉到“GoogleAuthenticator”多因子身份認證頁面“https://localhost:44303/multi-factor-verification”,最終效果如下圖:

    6、只有再次輸入手機端“GoogleAuthenticator”app中的“6”位數,才能訪問授權頁面。

    ??? 注意:因為授權頁面的訪問必須先登錄當前程序的注冊用戶,然后通過手機端“GoogleAuthenticator”app的身份認證后,才能被訪問,這就是“GoogleAuthenticator”被稱為多因素身份認證的原因。

    對以上功能更為具體實現和注釋見:22-04-12-044_Nop_4.40.4(通過GoogleAuthenticator插件執行登錄操作)。

    總結

    以上是生活随笔為你收集整理的第44章 通过GoogleAuthenticator插件执行登录操作的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。