Defining Clients 定义客户端

客户端表示哪些可以从你的IdentityServer拿到token的应用。

除了一些可能会变化的细节之外,通常情况下你需要为一个客户端定义如下通用的设置:

  • 一个唯一的client id
  • 一个secret(如果需要的话)
  • 被允许与token service的交互(也叫做授权类型,grant type)
  • 一个网络位置,其中标识和/或访问令牌被发送到(称为重定向URI)的地方
  • 客户端被允许访问的范围(即资源)列表

在运行时,定义的clients(客户端列表)通过一个实现了IClientStore的对象来进行访问。允许从任何数据源加载他们(clients)。在这个文档中我们使用的是内存中的实现。你可以在StartUp类中的ConfigureService方法中调用AddInmemoryClients扩展方法来进行注册服务。

Defining a client for server to server communication 定义一个客户端作为服务到服务的通信

这个场景下不存在交互的用户,就是一个服务(也叫客户端)想要访问一个Api(也叫范围)。

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

Defining browser-based JavaScript client (e.g. SPA) for user authentication and delegated access and API  定义基于浏览器的JavaScript客户端(例如SPA),用于用户身份验证、委托访问和API

这种客户端从javascript利用所谓的implicit flow流程(属于OAuth2.0的范畴,共有四种流程分别是Aothorization code、Implicit、ResourceOwnerPassword、ClientCredential,请参考相应文档)来请求一个id token和access token:

var jsClient = new Client
{
ClientId = "js",
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"
}
};

Defining a server-side web application (e.g. MVC) for use authentication and delegated API access  定义一个服务器端web应用程序(例如MVC),用于使用身份验证和委托的API访问

交互式服务器端(或本机桌面/移动)应用程序使用混合流(Authorization code和Implicit混合)。这种流提供了最好的安全性,因为存取令牌仅通过反向通道(back-channel)调用传输(并且允许您访问刷新令牌):

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"
},
};

IdentityServer4【Topic】之定义客户端的更多相关文章

  1. IdentityServer4[3]:使用客户端认证控制API访问(客户端授权模式)

    使用客户端认证控制API访问(客户端授权模式) 场景描述 使用IdentityServer保护API的最基本场景. 我们定义一个API和要访问API的客户端.客户端从IdentityServer请求A ...

  2. 第20章 定义客户端 - Identity Server 4 中文文档(v1.0.0)

    客户端表示可以从您的身份服务器请求令牌的应用程序. 详细信息各不相同,但您通常会为客户端定义以下常用设置: 唯一的客户ID 如果需要的秘密 允许与令牌服务的交互(称为授权类型) 身份和/或访问令牌发送 ...

  3. SAP 定义客户端

    SCC4  定义客户端 点击新建条目按钮  Client(客户端) R 200 Client Name(客户端名称) O   City(城市) R   Logical system(逻辑系统) R   ...

  4. asp.net core IdentityServer4 实现 Client credentials(客户端凭证)

    前言 OAuth 2.0默认四种授权模式(GrantType) 授权码模式(authorization_code) 简化模式(implicit) 密码模式(resource owner passwor ...

  5. IdentityServer Topics(3)- 定义客户端

    客户端代表可以从您的身份服务器请求令牌的应用程序. 细节有所不同,但您通常为客户端定义以下常用设置: 一个唯一的客户端ID 一个密钥,如果需要 允许与令牌服务的交互(称为授权类型) 身份或访问令牌被发 ...

  6. IdentityServer4 学习笔记[1]-客户端授权

    前言 本文内容来自IdentityServer4官网,官网有详细的介绍,并且有源码Demo 官网源码例子传送门 建立授权服务端 我们暂时不配置Https,选择空模板建立项目,项目建立后, 为了查看de ...

  7. Windows8安装Oracle11.2.0.1-0624,附带 DBCA建库、netca创建监听、配置PLSQL、定义客户端的环境变量 NLS_LANG、定义客户端的环境变量 TNS_ADMIN01

    Windows8安装Oracle11.2.0.1                                         操作系统:Windows 8 企业版 64bit Oracle:11. ...

  8. 011 Socket定义客户端

    引入命名空间: using System.Net; using System.Net.Sockets; using System.Threading;

  9. ASP.NET Core的身份认证框架IdentityServer4(7)- 使用客户端证书控制API访问

    前言 今天(2017-9-8,写于9.8,今天才发布)一口气连续把最后几篇IdentityServer4相关理论全部翻译完了,终于可以进入写代码的过程了,比较累.目前官方的文档和Demo以及一些相关组 ...

随机推荐

  1. java操作elasticsearch实现批量添加数据(bulk)

    java操作elasticsearch实现批量添加主要使用了bulk 代码如下: //bulk批量操作(批量添加) @Test public void test7() throws IOExcepti ...

  2. (转)Spring Boot(九):定时任务

    http://www.ityouknow.com/springboot/2016/12/02/spring-boot-scheduler.html 在我们开发项目过程中,经常需要定时任务来帮助我们来做 ...

  3. UVA10570-Meeting with Aliens(枚举)

    Problem UVA1616-Caravan Robbers Accept: 531  Submit: 2490Time Limit: 3000 mSec Problem Description I ...

  4. [Python] 练习代码

    # from random import randrange # num = int(input('摇几次骰子: ')) # sides=int(input('筛子有几个面: ')) # sum=0 ...

  5. Python:Day09

    Ubantu忘记密码: 1.开机长按shift,进入界面后按e: 2.将红框中内改成如下并按F10重启: 3.输入passwd,然后用户名,然后重新输入密码: locale命令查看系统中是否有中文 a ...

  6. ansible-playbook 实战案例 全网备份 实时备份

    目录 ansible-playbook 基础介绍 1.YAML三板斧 2. ansible playbook 安装apache 示例 案例 全网备份 实时备份 环境规划 目录规划 base.yaml ...

  7. CF617E XOR and Favorite Number

    CF617E XOR and Favorite Number 已知一个序列 \(a_1,\ a_2,\ \cdots,\ a_n\) 和 \(k\) ,\(m\) 次询问给出 \(l,\ r\) ,求 ...

  8. Debug Hacks中文版——深入调试的技术和工具

    关键词:gdb.strace.kprobe.uprobe.objdump.meminfo.valgrind.backtrace等. <Debugs Hacks中文版——深入调试的技术和工具> ...

  9. Generative Adversarial Nets[Pre-WGAN]

    本文来自<towards principled methods for training generative adversarial networks>,时间线为2017年1月,第一作者 ...

  10. 2018年12月份GitHub上最热门的Java开源项目

    来自:开源最前线(ID:OpenSourceTop) 链接:https://www.itcodemonkey.com/article/12747.html 又到了公布 GitHub 上热门项目的时候啦 ...