国产成人毛片视频|星空传媒久草视频|欧美激情草久视频|久久久久女女|久操超碰在线播放|亚洲强奸一区二区|五月天丁香社区在线|色婷婷成人丁香网|午夜欧美6666|纯肉无码91视频

CORE OAuth之identityServer4服務(wù)中心

在本文中,我們將介紹如何使用identityServer4實(shí)現(xiàn) CORE的OAuth服務(wù)中心。你可以通過以下鏈接下載示例代碼: _VUv-l0GFgiw 密碼:rfxx11* 新建 CORE

在本文中,我們將介紹如何使用identityServer4實(shí)現(xiàn) CORE的OAuth服務(wù)中心。你可以通過以下鏈接下載示例代碼:

_VUv-l0GFgiw

密碼:rfxx11*

新建 CORE WEB空項(xiàng)目

首先,我們需要新建一個(gè) Core Web空項(xiàng)目。

安裝identityserver4包

接下來,我們需要安裝identityserver4包。在Visual Studio中,打開NuGet包管理器控制臺(tái),并運(yùn)行以下命令:

Install-Package IdentityServer4

創(chuàng)建identityconfig配置幫助類

我們需要?jiǎng)?chuàng)建一個(gè)名為IdentityConfig的配置幫助類,用于定義可訪問的對(duì)象和客戶端信息。

using System;
using ;
using ;
using ;
using ;
using ;
using ;
namespace identityserverpeizhi
{
    public class IdentityConfig
    {
        // 可訪問的對(duì)象
        public static IEnumerable GetResource()
        {
            return new List
            {
                new ApiResource("apiServer","apiServer")
            };
        }
        public static IEnumerable GetClients()
        {
            return new List
            {
                new Client()
                {
                    ClientId  "clientId",
                    AllowedGrantTypes  ,
                    ClientSecrets  { new Secret("secret1122".Sha512()) },
                    AllowedScopes { "apiServer" } //可以訪問的resource
                }
            };
        }
    }
}

注入identity配置

在ConfigureServices方法中,我們需要注入identityServer4的配置。

public void ConfigureServices(IServiceCollection services)
{
    // 依賴注入的配置
    ()
        .AddDeveloperSigningCredential()
        .AddInMemoryApiResources(())
        .AddInMemoryClients(())
        .AddMvc();
}

配置identity管道

在Configure方法中,我們需要配置identityServer4的管道。

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (())
    {
        ();
    }
    ();
}

完成上述步驟后,你可以運(yùn)行項(xiàng)目,并在瀏覽器中打開/.well-known/openid-configuration來驗(yàn)證服務(wù)是否正確工作。

標(biāo)簽: