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 ...
随机推荐
- hdu1564 简单博弈
多画几个图可以发现规律: #include<stdio.h> int main() { int i,n; while(scanf("%d",&n)!=EOF) ...
- oralce GROUPING
/*从上面的结果中我们很容易发现,每个统计数据所对应的行都会出现null, 如何来区分到底是根据那个字段做的汇总呢,grouping函数判断是否合计列!*/ select decode(groupin ...
- vue element 给指数的div加loading
const loading = this.$loading({ lock: true, text: 'Loading', spinner: 'el-icon-lo ...
- pytorch nn.Embedding
pytorch nn.Embeddingclass torch.nn.Embedding(num_embeddings, embedding_dim, padding_idx=None, max_no ...
- 20182019-acmicpc-asia-dhaka-regional F .Path Intersection 树链剖分
直接进行树链剖分,每次对路径区间内的所有点值+1,线段树进行维护,然后查询线段树的最大值的个数!!! 查询线段树区间最大值个数,可以先维护区间和,在维护区间最值,如果区间和等于区间最值乘以区间长度,那 ...
- iptables 规则(Rules)
iptables的每一条规则(rule),都是由两部分组成的,第一部分包含一或多个「过滤条件」其作用是检查包是否符合处理条件(所有条件都必须成立才算数) :第而部分称为「目标」,用於決定如何处置符合条 ...
- 如何编程实现快速获取一个整型数中的bit流中1的个数
int one_in_unsigned(unsigned n) { n =(n & ) & 0x55555555); n =(n & ) & 0x33333333); ...
- laravel 中使用tinker注入数据到数据库
- python项目管理
Python 通常没有对应 Java 的 Ant / Maven 这样的 build tool,有一个用于打包的 setuptools / distutils 但也并不完全等价.如果是用来管理依赖包, ...
- js切割字符串
var time_str= '2019-9-10 13:18:20'; var t = time_str.substr(2,8); console.log(t); 输出 19-9-10