成人AV在线无码|婷婷五月激情色,|伊人加勒比二三四区|国产一区激情都市|亚洲AV无码电影|日av韩av无码|天堂在线亚洲Av|无码一区二区影院|成人无码毛片AV|超碰在线看中文字幕

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

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

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

_VUv-l0GFgiw

密碼:rfxx11*

新建 CORE WEB空項目

首先,我們需要新建一個 Core Web空項目。

安裝identityserver4包

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

Install-Package IdentityServer4

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

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

using System;
using ;
using ;
using ;
using ;
using ;
using ;
namespace identityserverpeizhi
{
    public class IdentityConfig
    {
        // 可訪問的對象
        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 (())
    {
        ();
    }
    ();
}

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

標簽: