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

最新文章

  1. mybatis-mysql操作存储过程
  2. Springmvc中@RequestParam传值中文乱码解决方案
  3. SharePoint 2013 日历根据Category显示不同颜色
  4. ASP.NET高并发解决方案
  5. IOS插件管理器: alcatraz
  6. linux服务器批量部署应用系统shell脚本(Tomcat/jetty)
  7. WARNING: &#39;aclocal-1.14&#39; is missing on your system.
  8. JavaScript优化细节(一)
  9. linux 软件包管理介绍
  10. springCloud全家桶
  11. [转]QT子线程与主线程的信号槽通信-亲测可用!
  12. html 音乐 QQ播放器 外链 代码 播放器 外链 代码
  13. MAC下Myeclipse SVN插件安装
  14. git初始化项目 以及 git常用操作
  15. 使用scaleBitmap类缩放和拉伸
  16. Python中Gradient Boosting Machine(GBM)调参方法详解
  17. [工具] TreeSizeFree 查看每个文件夹的大小
  18. 《Python绝技:运用Python成为顶级黑客》 用Python实现免杀
  19. HDFS命令行工具
  20. 『JavaScript』核心

热门文章

  1. FCM算法的matlab程序
  2. CISCO静态路由配置
  3. JavaScript数据类型之数字类型
  4. Python中进程线程协程小结
  5. 《Java大学教程》—第18章 高级图形编程
  6. [Java] SpringMVC工作原理之三:ViewResolver
  7. python写测试接口
  8. oracle windows 新建用户授权 导出导入bmp文件
  9. 12个 Linux 中 grep 命令的超级用法实例
  10. 彻底理解js中的&amp;&amp;和||