想要让客户端能够访问API资源,就需要在Identity Server中定义好API的资源。

Scope作用域:即API资源的访问范围限制。

作用域是一个资源 (通常也称为 Web API) 的标识符。

public static IEnumerable<ApiResource> GetApis()
{
return new[]
{
// simple API with a single scope (in this case the scope name is the same as the api name)
new ApiResource("api1", "Some API 1"), // expanded version if more control is needed
new ApiResource
{
Name = "api2", // secret for using introspection endpoint
ApiSecrets =
{
new Secret("secret".Sha256())
}, // include the following using claims in access token (in addition to subject id)
UserClaims = { JwtClaimTypes.Name, JwtClaimTypes.Email }, // this API defines two scopes
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"
}
}
}
};
}

.net core 中 identity server 4 之Topic --定义API资源的更多相关文章

  1. .net core 中 identity server 4 之Topic --定义Client

    客户端指能够从id4获取Token的角色. 客户端的共性: a unique client ID a secret if needed the allowed interactions with th ...

  2. .net core 中 Identity Server 4 Topic 之 Startup

    约定 简称 Id4. Id4在.net core 中的使用符合.net core 的约定架构,即Services来注册服务,middleware方式集成. 1. 配置服务 通过DI注入: public ...

  3. .net core 中 identity server 4 之Server简单示例

    Steps: 1.新建一个ASP.NET Core Web项目,SigmalHex.IdentityServer: 2.安装包 Install-Package IdentityServer4 3.St ...

  4. .net core 中 identity server 4 之术语

    id4的职责: 保护你的资源 通过本地 账户库(Account Store)或者外部身份提供其 认证用户 提供Session管理以及SSO 管理和认证客户端 发行身份及访问Token给客户端 验证To ...

  5. Identity Server 4 - Hybrid Flow - 保护API资源

    这个系列文章介绍的是Identity Server 4 的 Hybrid Flow, 前两篇文章介绍了如何保护MVC客户端, 本文介绍如何保护API资源. 保护MVC客户端的文章: https://w ...

  6. 使用PostMan Canary测试受Identity Server 4保护的Web Api

    在<Asp.Net Core: Swagger 与 Identity Server 4>一文中介绍了如何生成受保护的Web Api的Swagger文档,本文介绍使用PostMan Cana ...

  7. asp.net core 中 sql server 2017 数据库连接测试

    使用sql server 2017 进行连接: 配置appsettings.json文件 { "ConnectionStrings": { "DefaultConnect ...

  8. 第9章 使用客户端凭据保护API - Identity Server 4 中文文档(v1.0.0)

    快速入门介绍了使用IdentityServer保护API的最基本方案. 我们将定义一个API和一个想要访问它的客户端. 客户端将通过提供ClientCredentials在IdentityServer ...

  9. 第19章 定义资源 - Identity Server 4 中文文档(v1.0.0)

    您通常在系统中定义的第一件事是您要保护的资源.这可能是您的用户的身份信息,如个人资料数据或电子邮件地址,或访问API. 注意 您可以使用C#对象模型定义资源 - 或从数据存储加载它们.IResourc ...

随机推荐

  1. sleep(),wait(),yield(),notify()

    sleep(),wait(),yield() 的区别 sleep方法和yield方法是Thread类的方法,wait方法是Object的方法. sleep 方法使当前运行中的线程睡眼一段时间,进入不可 ...

  2. Swift-属性监听

    监听属性的改变(开发中使用很多) oc中长是重写set方法 swift通过属性监听器 class Dog: NSObject { var name:String?{ // 属性监听器 // 属性即将改 ...

  3. 测试——约跑APP

    项目名:约跑APP 用户需求规格说明书URL:http://www.cnblogs.com/liquan/p/6071804.html 组长博客URL:http://www.cnblogs.com/l ...

  4. 【Nginx】配置说明

    #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为当前主机的CPU总核心数. worker_processes 8; #全局错误日志定义类型,[ debug ...

  5. HSF源码剖析

    前言 HSF是一个分布式的远程服务调用框架,其实我更喜欢把分布式几个字去掉,因为HSF本身并不是一个单独的服务(指一个进程),他是附属在你的应用里的一个组件,一个RPC组件(远程过程调用——Remot ...

  6. js 变量定义的注意点

  7. Apache Hadoop YARN – ResourceManager--转载

    原文地址:http://zh.hortonworks.com/blog/apache-hadoop-yarn-resourcemanager/ ResourceManager (RM) is the ...

  8. 用Racket语言写了一个万花筒的程序

    用Racket语言写了一个万花筒的程序 来源:https://blog.csdn.net/chinazhangyong/article/details/79362394 https://github. ...

  9. Gradle及eclipse插件安装

    1.  下载Gradle Gradle需要jdk7或以上版本,使用Java –version命令进行测试:Gradle自带了Groovy库,所以无需再安装Groovy,已经安装的Groovy会被Gra ...

  10. 【JQuery】事件

    一.前言        接着上一章选择器的知识,继续啊jQuery的学习 二.内容 $(function(){}) 文档初始化加载 event.pageX 相对于文档左边缘的鼠标位置 event.pa ...