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> 上面这篇文章虽然详细,但都是点到为止的介绍,并没有实际应用的示例,所以,后 ...
随机推荐
- C++获取工程路径、exe路径
编码过程中有时候会用到获取工程所在路径或者exe所在的路径信息,这里稍微记录下. 获取工程路径 char pBuf[MAX_PATH]; //存放路径的变量 GetCurrentDirectory(M ...
- ABP框架系列之五:(Unit Of Work-工作单元)
Introduction Connection and transaction management is one of the most important concepts in an appli ...
- Programming | 中/ 英文词频统计(MATLAB实现)
一.英文词频统计 英文词频统计很简单,只需借助split断句,再统计即可. 完整MATLAB代码: function wordcount %思路:中文词频统计涉及到对"词语"的判断 ...
- <Listener>HttpSessionListener和HttpSessionAttributeListener区别
一.HttpSessionListener HttpSessionListener是对Session的一个监听,主要监听关于Session的两个事件,即初始化和销毁.HttpSessionListen ...
- ansible教程
相关教程: 权威指南:http://www.ansible.com.cn/ 博客教程:https://www.w3cschool.cn/automate_with_ansible/ 视频教程: htt ...
- [算法专题] 二分搜索&排序数组
基础知识 二分非递归写法: int binary_search(const int a[], const int size, const int val) { int lower = 0; int u ...
- c++ 日志输出库 spdlog 简介(1)
参考文章: log库spdlog简介及使用 - 网络资源是无限的 - CSDN博客 http://blog.csdn.net/fengbingchun/article/details/78347105 ...
- 项目Alpha冲刺(团队5/10)
项目Alpha冲刺(团队5/10) 团队名称: 云打印 作业要求: 项目Alpha冲刺(团队) 作业目标: 完成项目Alpha版本 团队队员 队员学号 队员姓名 个人博客地址 备注 221600412 ...
- Java学习笔记33(集合框架七:Collections工具类)
数组有工具类,方面操作数组 集合也有工具类:Collections 常用方法示例: package demo; import java.util.ArrayList; import java.util ...
- LabVIEW(十一):条件结构的巧用
一.LabVIEW中条件结构使用起来并不是那么简便,主要体现在两点: 1.由隧道的产生引起的一些问题.(当箭头停留在隧道处时不显示为“自动索引隧道”,所以此隧道非彼隧道) 2.由多层结构判断引起的不易 ...