IdentityServer4 Clients
Clients 的定义
Client是指那些从 identityserver获取 token的应用
通常需要为client定义下面通用的设置
- 唯一的client id
- secret, 如果需要
- 允许交互的令牌服务(也叫做 grant type)
- 一个接收 identity 和/或 access token 的网络地址
- client 被允许访问的 一组 scope (也叫做resource)
Note 运行时,clients 通过 实现
IClientStore调用方法得到。这使得可以从任意的数据源获取client数据,比如 config 文件或者数据库。文档中使用 in-memory 版本的 client 存储方式。通过在ConfigureService中添加AddInmemoryClients扩展实现。
client for service to service communication 的定义
这个场景下没有用户操作- 一个service(aka client)试图和一个API(aka 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访问
这个 client 使用叫做 implicit 的流程从 JavaScript 请求 identity 和 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"
}
};
定义基于服务端web应用程序(例如MVC)来对用户进行身份验证和授权Api访问
服务端(或者 本地桌面/手机)应用程序使用 hybrid flow. 这种方式最安全,因为access tokens 仅使用后台通信,而且允许刷新token
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"
},
};
在 appsettings.json 中定义 clients
Asp.Net Core 配置文件
"IdentityServer": {
"IssuerUri": "urn:sso.company.com",
"Clients": [
{
"Enabled": true,
"ClientId": "local-dev",
"ClientName": "Local Development",
"ClientSecrets": [ { "Value": "<Insert Sha256 hash of the secret encoded as Base64 string>" } ],
"AllowedGrantTypes": [ "implicit" ],
"AllowedScopes": [ "openid", "profile" ],
"RedirectUris": [ "https://localhost:5001/signin-oidc" ],
"RequireConsent": false
}
]
}
AddInMemoryClients(configuration.GetSection("IdentityServer:Clients"))
IdentityServer4 Clients的更多相关文章
- IdentityServer4之Clients、Scopes、Claims与Token关联
IdentityServer4之Clients.Scopes.Claims与Token关联 参考 官方文档:client.identity_resource.api_resource:三类配置项介绍描 ...
- IdentityServer4 简单使用,包括api访问控制,openid的授权登录,js访问
写在前面 先分享一首数摇:http://music.163.com/m/song?id=36089751&userid=52749763 其次是:对于identityServer理解并不是特别 ...
- IdentityServer4 实现 OpenID Connect 和 OAuth 2.0
关于 OAuth 2.0 的相关内容,点击查看:ASP.NET WebApi OWIN 实现 OAuth 2.0 OpenID 是一个去中心化的网上身份认证系统.对于支持 OpenID 的网站,用户不 ...
- ASP.NET Core的身份认证框架IdentityServer4(8)- 使用密码认证方式控制API访问
前言 本文及IdentityServer这个系列使用的都是基于.net core 2.0的.上一篇博文在API项目中我使用了icrosoft.AspNetCore.Authentication.Jwt ...
- IdentityServer4实现Token认证登录以及权限控制
相关知识点 不再对IdentityServer4做相关介绍,博客园上已经有人出了相关的系列文章,不了解的可以看一下: 蟋蟀大神的:小菜学习编程-IdentityServer4 晓晨Master:Ide ...
- IdentityServer4 配置负载均衡
如果使用 IdentityServer4 做授权服务的负载均衡,默认情况下是不可以的,比如有两个授权服务站点,一个资源服务绑定其中一个授权服务(Authority配置),如果通过另外一个授权服务获取a ...
- 【ASP.NET Core分布式项目实战】(三)整理IdentityServer4 MVC授权、Consent功能实现
本博客根据http://video.jessetalk.cn/my/course/5视频整理(内容可能会有部分,推荐看源视频学习) 前言 由于之前的博客都是基于其他的博客进行开发,现在重新整理一下方便 ...
- .NET Core IdentityServer4实战 第三章-使用EntityFramework Core进行持久化配置
内容:本文带大家使用IdentityServer4进行使用使用EntityFramework Core进行配置和操作数据 作者:zara(张子浩) 欢迎分享,但需在文章鲜明处留下原文地址. 前两章内容 ...
- .NET Core IdentityServer4实战 第二章-OpenID Connect添加用户认证
内容:本文带大家使用IdentityServer4进行使用OpenID Connect添加用户认证 作者:zara(张子浩) 欢迎分享,但需在文章鲜明处留下原文地址. 在这一篇文章中我们希望使用Ope ...
随机推荐
- Android 神兵利器之通过解析网页获取到的API数据合集,可拿来就用
AppApis 前段时间,写了个做app的实战系列教程,其中一篇章提到了解析网页中的数据为己所用,看到大家的响应还不错,于是把自己以前解析过的网页数据都整理了下,开放出来,给更多的人使用,希望可以帮助 ...
- 谷歌好样的,把 www 也干掉了
谷歌好样的,把 www 也干掉了 继把 http 干掉后,这次 Chrome 76 连 https 和 www 都一起干掉了. 喜欢简洁,但这个功能演化过程可不简单. 最早觉得把 http 干掉很不方 ...
- BZOJ1085 luogu2324骑士精神题解
没有什么特别好的办法,只好用搜索去做 因为一次移动最多归位一个骑士 所以可以想到用IDA*,为了简化状态 我们用k,x,y,sum来表示移动了k步,空格在x,y,还用sum个没有归位的情况 然后枚举转 ...
- 【NS2】WiMAX_NS2说明文档(转载)
关于目前NS2中WiMAX模块的说明 (1)美国NIST(National Institute of Standards and Technology)版, 可以从NIST主页获得,2007.04 r ...
- input禁止复制、粘贴、剪切
<input type="text" autocomplete="off"> <!-- autocomplete="off" ...
- Python中并发前戏之操作系统
进程: 1.串行: 一个任务完完整整地运行完毕后,才能运行下一个任务 2.并发 看起来多个任务是同时运行的即可,单核也可以实现并发 3.并行: 真正意义上多个任务的同时运行,只有多核才实现并行 1.什 ...
- TextView.setTextColor(int); 括号里那个颜色int值的理解
原本以为是R.id里的东西,后来发现不是 http://dianhua1990627.blog.163.com/blog/static/2755558820132262150387/
- idea 使用优化
1.创建类的模板 /** * Copyright (C), 2015-${YEAR}, XXX有限公司 * FileName: ${NAME} * Author: ${USER} * Date: ${ ...
- Python基础:09函数式编程
Python支持一些函数式编程的特性.比如lambda. map().reduce().filter()函数. 一:匿名函数与lambda Python可以用lambda 关键字创造匿名函数.匿名函数 ...
- Python两个字典键同值相加的几种方法
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/Jerry_1126/article/de ...