IdentityServer4【Topic】之定义客户端
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】之定义客户端的更多相关文章
- IdentityServer4[3]:使用客户端认证控制API访问(客户端授权模式)
使用客户端认证控制API访问(客户端授权模式) 场景描述 使用IdentityServer保护API的最基本场景. 我们定义一个API和要访问API的客户端.客户端从IdentityServer请求A ...
- 第20章 定义客户端 - Identity Server 4 中文文档(v1.0.0)
客户端表示可以从您的身份服务器请求令牌的应用程序. 详细信息各不相同,但您通常会为客户端定义以下常用设置: 唯一的客户ID 如果需要的秘密 允许与令牌服务的交互(称为授权类型) 身份和/或访问令牌发送 ...
- SAP 定义客户端
SCC4 定义客户端 点击新建条目按钮 Client(客户端) R 200 Client Name(客户端名称) O City(城市) R Logical system(逻辑系统) R ...
- asp.net core IdentityServer4 实现 Client credentials(客户端凭证)
前言 OAuth 2.0默认四种授权模式(GrantType) 授权码模式(authorization_code) 简化模式(implicit) 密码模式(resource owner passwor ...
- IdentityServer Topics(3)- 定义客户端
客户端代表可以从您的身份服务器请求令牌的应用程序. 细节有所不同,但您通常为客户端定义以下常用设置: 一个唯一的客户端ID 一个密钥,如果需要 允许与令牌服务的交互(称为授权类型) 身份或访问令牌被发 ...
- IdentityServer4 学习笔记[1]-客户端授权
前言 本文内容来自IdentityServer4官网,官网有详细的介绍,并且有源码Demo 官网源码例子传送门 建立授权服务端 我们暂时不配置Https,选择空模板建立项目,项目建立后, 为了查看de ...
- Windows8安装Oracle11.2.0.1-0624,附带 DBCA建库、netca创建监听、配置PLSQL、定义客户端的环境变量 NLS_LANG、定义客户端的环境变量 TNS_ADMIN01
Windows8安装Oracle11.2.0.1 操作系统:Windows 8 企业版 64bit Oracle:11. ...
- 011 Socket定义客户端
引入命名空间: using System.Net; using System.Net.Sockets; using System.Threading;
- ASP.NET Core的身份认证框架IdentityServer4(7)- 使用客户端证书控制API访问
前言 今天(2017-9-8,写于9.8,今天才发布)一口气连续把最后几篇IdentityServer4相关理论全部翻译完了,终于可以进入写代码的过程了,比较累.目前官方的文档和Demo以及一些相关组 ...
随机推荐
- python3编写网络爬虫21-scrapy框架的使用
一.scrapy框架的使用 前面我们讲了pyspider 它可以快速的完成爬虫的编写 不过pyspider也有一些缺点 例如可配置化不高 异常处理能力有限对于一些反爬虫程度非常强的网站 爬取显得力不从 ...
- Python里面search()和match()的区别
转自https://www.cnblogs.com/aaronthon/p/9435967.html match()函数只检测字符串开头位置是否匹配,匹配成功才会返回结果,否则返回None searc ...
- 让ie8支持 placeholder 属性
一. ie8支持 placeholder 属性 /* * ie8支持 placeholder 属性 */ $(function(){ if( !('placeholder' in document. ...
- SQLAlchemy 嵌套事务的解决方案
sqlachemy 是python的orm框架,在使用一段时间后,我们通常会出现事务嵌套的情况,看到很多人写代码的时候,居然是session到处传递,这无疑是加大了代码之间的耦合度. 案例: def ...
- 更改django的时区
TIME_ZONE='Asia/Shanghai' datetime_obj.replace(tzinfo=(pytz.timezone("Asia/Shanghai"))).st ...
- Oracle查询数据库中所有表的记录数
1.Oracle查询数据库中所有表的记录数,但是有可能不准建议用第二种方式进行查询 select t.table_name,t.num_rows from user_tables t 2.创建orac ...
- ISCC:Please give me username and password!
地址:http://118.190.152.202:8017/ 题目说 给用户名和密码, 构造url为:118.190.152.202:8017/?username=sda&password= ...
- a,b,c为3个整型变量,在不引入第四个变量的前提下写一个算法实现 a=b b=c c=a?(异或解决值互换问题)
package com.Summer_0424.cn; /** * @author Summer * a,b,c为3个整型变量,在不引入第四个变量的前提下写一个算法实现 a=b b=c c=a? */ ...
- 对Android系统权限的认识
Android系统是运行在Linux内核上的,Android与Linux分别有自己的一套严格的安全及权限机制 Android系统权限相关的内容 (一)linux文件系统上的权限 -rwxr-x--x ...
- UIImageView - BNR
继续上节UINavigationController - BNR. 打开BNRDetailViewController.xib文件,向view中添加UIImageView对象,选中该对象,通过Attr ...