IdentityServer4-Resource定义-翻译
资源定义(Defining Resource)
通常,第一件事是定义那些你想保护的资源。这些资源可能是你的用户信息,比如个人数据,电子邮件或者对Api的访问。
Note:
你可以用C#实体类来定义资源或者加载从数据库中加载他们,都是通过对IResourceStore的实现来处理这些二级细节。此文档将在内存中进行实现。
定义身份资源(Defining identity resource)
身份资源通常都是指那些用户ID,名称,邮箱等信息。一个identity 资源有一个独一无二的名称,你能分配任意(arbitrary )的claim类型。这些claim将被包含在用户的token中。客户端将使用scope参数请求对identity resource的访问。
这个OpenID Connect规范指定了一组标准的身份资源。最低要求是,你为用户发行唯一ID的提供支持,也叫做subject id。这是通过暴露一个叫做OpenId的标准的身份资源来完成的。
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId()
};
}
这个IdentityResources类支持规范中所有的scopes 定义(比如,openid,email.profile,telephone,address)。如果你想支持这些,你可以在你的身份资源List中添加它们。
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Email(),
new IdentityResources.Profile(),
new IdentityResources.Phone(),
new IdentityResources.Address()
}
}
自定义身份资源
你也可以自定义身份资源。创建一个新的IdentityResource类,给它一个名称和一个可选的显示名称和描述,并在请求此资源时定义哪些用户声明应该包含在身份令牌中。
public static IEnumerable<IdentityResource> GetIdentityResources()
{
var customProfile =new IdentityResource(
name:"custom.Profile",
displayName:"cstProfile",
claimType:new[]{"name","email","status"}); return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
customProfile
};
}
有关身份资源设置的更多信息,请参阅reference 部分。
定义API resource
允许请求的access token访问哪些api,你需要定义这些api resource。
想得到关于APIs的accsee token,你需要以scope的身份注册它们。下面展示Resource类型的scope.
public static IEnumerable<ApiResource> GetApis()
{
return new[]
{ new ApiResource("api1","Some API 1"), new ApiResource
{
Name = "api2", ApiSecrets=
{
new Secret("secret".Sha256())
},
Scopes=
{
new Scope()
{
Name = "api2.full_access",
DisplayName = "Full access to API 2",
},
new Scope
{
Name = "api2.read_only",
DisplayName = "Read only access to API 2"
}
}
}
};
}
有关API资源设置的更多信息,请参阅reference部分。
Note:
由资源定义的用户声明由IProfileService可扩展性点加载。
IdentityServer4-Resource定义-翻译的更多相关文章
- IdentityServer4-客户端定义-翻译
客户端定义(Defining Client) 客户端可以从你的IDS服务器请求tokens. 通常,客户端需要遵循下面的通用设置: 一个唯一的Client ID 如果需要还可以提供密码 允许与toke ...
- laravel 定义翻译字符串
https://learnku.com/docs/laravel/5.6/localization/1376 // 全景链接$data['share_phone'] = trans('web.host ...
- 【翻译】IdentityServer4:基于资源的配置
这篇文章基于https://leastprivilege.com/2016/12/01/new-in-identityserver4-resource-based-configuration/进行翻译 ...
- 【初探Spring】------Spring IOC(三):初始化过程---Resource定位
我们知道Spring的IoC起到了一个容器的作用,其中装得都是各种各样的Bean.同时在我们刚刚开始学习Spring的时候都是通过xml文件来定义Bean,Spring会某种方式加载这些xml文件,然 ...
- BeanDefinition的Resource定位——3
1.我们重点看看AbstractRefreshableApplicationContext的refreshBeanFactory方法的实现,这个refreshBeanFactory被FileSyste ...
- BeanDefinition的Resource定位
1.以编程的方式使用DefaultListableBeanFactory时,首先定义一个Resource来定位容器使用的BeanDefiniton.这时使用的是ClassPathResource,这意 ...
- IOC容器初始化——BeanDefinition的Resource定位
以编程的方式使用DefaultListableBeanFactory时,首先定义一个Resource来定位容器使用的BeanDefinition.这是使用的是ClassPathResource,意味着 ...
- HTML5之appcache语法理解/HTML5应用程序缓存/manifest缓存文件官方用法翻译
习惯性的贴几个参考链接: W3School-HTML 5 应用程序缓存 官方 MDN window.applicationCache 接口文档 官方 MDN 用法示例 看所有的教程不如直接看最原始的官 ...
- IdentityServer4 实现 OAuth 2.0(密码模式 - HTTP Post 方式)
之前写了一篇文章:<IdentityServer4 实现 OpenID Connect 和 OAuth 2.0> 上面这篇文章虽然详细,但都是点到为止的介绍,并没有实际应用的示例,所以,后 ...
随机推荐
- 11. English vocabulary 英语词汇量
11. English vocabulary 英语词汇量 (1) The exact number of English words is not known.The large dictionari ...
- python模块:hmac
"""HMAC (Keyed-Hashing for Message Authentication) Python module. Implements the HMAC ...
- Notes : <Hands-on ML with Sklearn & TF> Chapter 1
<Hands-on ML with Sklearn & TF> Chapter 1 what is ml from experience E with respect to som ...
- line number is important in Exceptions.
行号作为debug信息 在出现异常时可以迅速定位 package ztest; public class Test { public static void main(String[] args) { ...
- 自己封装的简单DbDao
首先,DbDao是一个用来操作数据库的类.需要对数据库的驱动包 要操作数据库首先要获得链接,这时候就需要链接数据库的所有参数了,包括driver,url,user,password.(全部定义为pri ...
- Codeforces Round #512 (Div. 2) D. Vasya and Triangle
参考了别人的思路:https://blog.csdn.net/qq_41608020/article/details/82827632 http://www.cnblogs.com/qywhy/p/9 ...
- Vuejs——(8)Vuejs组件的定义
版权声明:出处http://blog.csdn.net/qq20004604 目录(?)[+] 本篇资料来于官方文档: http://cn.vuejs.org/guide/components ...
- 为什么需要micro-service构建平台
最近一直在做micro-service的开发平台建设.由于这是一个实验项目,目前所有工作都得靠自己操刀. 今天在总结用python开发一个web service时,偶有所得,这让我建设micro-se ...
- DevExpress--TreeList节点添加图片
这个过程相对来说比较简单,网上也有不少资料,但是自己在做过之后为了记住,算是给自己写一个博客吧. 下面直接上具体的流程 1.前提 控件使用的都是DevExpress和winform的原生控件两种: 2 ...
- 腾讯大数据之TDW计算引擎解析——Shuffle
转自 https://www.csdn.net/article/2014-05-19/2819831-TDW-Shuffle/1 摘要:腾讯分布式数据仓库基于开源软件Hadoop和Hive进行构建,T ...