• IdentityServer4-客户端定义-翻译


    客户端定义(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/index.html" },
        PostLogoutRedirectUris = { "http://localhost:7017/index.html" },
        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"
        },
    };


  • 相关阅读:
    时间序列表示
    Resnet——深度残差网络(二)
    Resnet——深度残差网络(一)
    基于tensorflow2.0和cifar100的VGG13网络训练
    Android实战项目——家庭记账本(七)
    iOS-基于TCP连接<Scoket-客户端>
    Xcode更新到10.0之后遇到的那些坑:
    cell右侧的状态(accessoryType)
    2020最新cocoapods详细安装和使用
    AFNetworking上传一张或多张图片,并压缩图片节约占用内存
  • 原文地址:https://www.cnblogs.com/franhome/p/8996046.html
Copyright © 2020-2023  润新知