当前位置: 移动技术网 > IT编程>开发语言>.net > IdentityServer4-客户端定义-翻译

IdentityServer4-客户端定义-翻译

2018年05月06日  | 移动技术网IT编程  | 我要评论

利豪揪痧视频,医仙王妃,苏州解静聆照片

客户端定义(Defining Client)

客户端可以从你的IDS服务器请求tokens。

通常,客户端需要遵循下面的通用设置:

  • 一个唯一的Client ID

  • 如果需要还可以提供密码

  • 允许与token服务交互(授权类型)

  • identity 和/或 token被发送到的网络位置(redirect URI)

  • 客户端允许访问的scopes清单(resources)

Note:

在运行时,客户端通过实现IClientStore来检索。它允许在任意数据资源中加载比如配置文件或者数据库。此文档将使用内存版本进行客户端存储。你可以在ConfigureServices通过AddInMemoryClients额外方法连接内存存储。

定义一个服务器到服务器通信的客户端

在这种情况(scenario)下没有交互用户,服务端(这里是客户端)想和API(Scope)通信:


public class Clients
{
    public static IEnumerable<Client> Get()
    {
        return new List<Client>
        {
            new Client
            {
                ClientId = "service.client",
                ClientSecrets = { new Secret("secret".Sha256()) },
​
                AllowedGrantTypes = GrantTypes.ClientCredentials,
                AllowedScopes = { "api1", "api2.read_only" }
            }
        };
    }
}

 

定义基于浏览器的JavaScript客户端(例如SPA)以进行用户认证和授权访问和API

var jsClient =new Client
{
    ClientId="js",
    ClientName=""
    ClientName = "JavaScript Client",
    ClientUri = "http://identityserver.io",
​
    AllowedGrantTypes = GrantTypes.Implicit,
    AllowAccessTokensViaBrowser = true,
​
    RedirectUris =           { "http://localhost:7017/" },
    PostLogoutRedirectUris = { "http://localhost:7017/" },
    AllowedCorsOrigins =     { "http://localhost:7017" },
​
    AllowedScopes =
    {
        IdentityServerConstants.StandardScopes.OpenId,
        IdentityServerConstants.StandardScopes.Profile,
        IdentityServerConstants.StandardScopes.Email,
​
        "api1", "api2.read_only"
    }
}

 



定义服务器端Web应用程序(例如MVC)以进行使用验证和授权API访问

交互式服务器端(或本地桌面/移动)应用程序使用混合流。此流程为您提供最佳的安全性,因为访问令牌仅通过反向通道呼叫传输(并允许您访问刷新令牌)

var mvcClient = new Client
{
    ClientId = "mvc",
    ClientName = "MVC Client",
    ClientUri = "http://identityserver.io",
​
    AllowedGrantTypes = GrantTypes.Hybrid,
    AllowOfflineAccess = true,
    ClientSecrets = { new Secret("secret".Sha256()) },
​
    RedirectUris =           { "http://localhost:21402/signin-oidc" },
    PostLogoutRedirectUris = { "http://localhost:21402/" },
    FrontChannelLogoutUri =  "http://localhost:21402/signout-oidc",
​
    AllowedScopes =
    {
        IdentityServerConstants.StandardScopes.OpenId,
        IdentityServerConstants.StandardScopes.Profile,
        IdentityServerConstants.StandardScopes.Email,
​
        "api1", "api2.read_only"
    },
};

 



 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网