二、IDS4配置服务
它是根据定义配置服务Config.cs文件来生成客户端和API使用该服务所需的配置数据。
一、IDS4签名服务
1、为项目添加NuGet包。
2、IDS4服务制定的配置Config.cs。
using IdentityServer4.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; namespace ids4
{
//一、IDS4服务制定
public class Config
{
//1、定义API资源
public static IEnumerable<ApiResource> GetApis() //ApiResource是属于using IdentityServer4.Models;内的。
{
return new List<ApiResource>
{
new ApiResource("api1", "My API")
};
}
//2、定义客户端
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "client",
// no interactive user, use the clientid/secret for authentication
AllowedGrantTypes = GrantTypes.ClientCredentials,
// secret for authentication
ClientSecrets =
{
new Secret("secret".Sha256())
},
// scopes that client has access to
AllowedScopes = { "api1" }
}
};
}
}
}
3、Startup.cs内添加IDS4服务。
using IdentityServer4.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; namespace ids4
{
//二、添加IDS4服务
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
} public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
}); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); //1、注入服务添&加在最底部
var builder = services.AddIdentityServer()
//.AddInMemoryIdentityResources(Config.GetIdentityResources()) //注入GetIdentityResources资源。
.AddInMemoryApiResources(Config.GetApis()) //注入ApiResources资源对应定义的API资源。
.AddInMemoryClients(Config.GetClients()); //注入定义的客户端
} // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseIdentityServer();//2、添加服务&添加在顶部 if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
} app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy(); app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
4、运行服务器并浏览浏览器 http://localhost:5000/.well-known/openid-configuration 您应该会看到所谓的发现文档。客户端和API将使用它来下载必要的配置数据。

{
"issuer": "http://localhost:5000",
"authorization_endpoint": "http://localhost:5000/connect/authorize",
"token_endpoint": "http://localhost:5000/connect/token",
"userinfo_endpoint": "http://localhost:5000/connect/userinfo",
"end_session_endpoint": "http://localhost:5000/connect/endsession",
"check_session_iframe": "http://localhost:5000/connect/checksession",
"revocation_endpoint": "http://localhost:5000/connect/revocation",
"introspection_endpoint": "http://localhost:5000/connect/introspect",
"device_authorization_endpoint": "http://localhost:5000/connect/deviceauthorization",
"frontchannel_logout_supported": true,
"frontchannel_logout_session_supported": true,
"backchannel_logout_supported": true,
"backchannel_logout_session_supported": true,
"scopes_supported": ["api1", "offline_access"],
"claims_supported": [],
"grant_types_supported": ["authorization_code", "client_credentials", "refresh_token", "implicit", "urn:ietf:params:oauth:grant-type:device_code"],
"response_types_supported": ["code", "token", "id_token", "id_token token", "code id_token", "code token", "code id_token token"],
"response_modes_supported": ["form_post", "query", "fragment"],
"token_endpoint_auth_methods_supported": ["client_secret_basic", "client_secret_post"],
"subject_types_supported": ["public"],
"id_token_signing_alg_values_supported": ["RS256"],
"code_challenge_methods_supported": ["plain", "S256"]
}
二、IDS4配置服务的更多相关文章
- 【WCF全析(二)】--服务配置部署详解
上篇文章主要讨论了WCF的基本内容,其中包括WCF的术语.创建方法及WCF在开发过程中使用的意义,它不仅能够提供程序之间的通信,而且还能提供程序和数据间的通信,WCF提供了多样化的程序 ...
- 5、SAMBA服务二:配置实例
①:SAMBA服务一:参数详解 ②:SAMBA服务二:配置实例 5.2.3.Samba共享目录配置实例 1.允许匿名用户读取/it共享目录,修改/etc/samba/smb.conf,在最后添加以下内 ...
- 《深入理解Spring Cloud与微服务构建》学习笔记(二十)~配置中心Spring Cloud Config
本例重新创建项目,构建一个空的mavan工程. 一.Config Server 从本地读取配置文件 新建一个moudle config_server ,pom添加依赖 <dependency ...
- AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(二):配置WinClient分布式运行环境
一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...
- 第四十二章 微服务CICD(4)- jenkins + gitlab + webhooks + publish-over-ssh(2)
上一节完成了"当git客户端push代码到gitlab后,jenkins会立即去gitlab拉取代码并构建". 目的:本节完成jenkins自动构建之后,自动的将jar包部署到应用 ...
- 【WCF--初入江湖】03 配置服务
03 配置服务 数据库 生成数据库脚本: CREATE DATABASE [EmployeeDb]; CREATE TABLE [dbo].[T_Employee]( [Id] [,) NOT NUL ...
- mysql 5.6.20的安装、配置服务、设置编码格式
一.安装 安装环境 系统:Window 32 版本:Mysql 5.6.20 1. 首先从官网上http://dev.mysql.com/downloads/mysql/ ...
- WCF技术剖析之二十三:服务实例(Service Instance)生命周期如何控制[下篇]
原文:WCF技术剖析之二十三:服务实例(Service Instance)生命周期如何控制[下篇] 在[第2篇]中,我们深入剖析了单调(PerCall)模式下WCF对服务实例生命周期的控制,现在我们来 ...
- NFS 配置服务
NFS 配置服务 北京市海淀区 张俊浩 一.NFS.即网络文件系统(Network File System,NFS).一种使用于分散式文件系统的协议,由升阳公司开发.于1984年向外发布.功能是通过 ...
随机推荐
- 【leetcode】1027. Longest Arithmetic Sequence
题目如下: Given an array A of integers, return the length of the longest arithmetic subsequence in A. Re ...
- 进入cmd的另外的一种方式
按Shift键+鼠标右键 进入powershell ,进入的界面和普通的shell界面不一样
- 全文检索 使用最新lucene3.0.3+最新盘古分词 pangu2.4 .net 实例
开发环境 vs2015 winform 程序 1 首先需要下载对应的DLL 文章后面统一提供程序下载地址 里面都有 2 配置pangu的参数 也可以不配置 采用默认的即可 3 创建索引,将索引存放到本 ...
- MVC 无法将带 [] 的索引应用于“System.Dynamic.DynamicObject”类型的表达式
无法将带 [] 的索引应用于“System.Dynamic.DynamicObject”类型的表达式 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代 ...
- AppBar中自定义顶部导航
在上一篇里总结AppBar的一些简单用法,但是AppBar除了有前面那些样式属性外,还能实现类似底部的Tab切换. 首先下载并运行前面的项目: 然后在此基础上实现Tab切换. 常见属性 TabBar有 ...
- IntelliJ IDEA 装配FindBugs以及应用
IntelliJ IDEA 安装FindBugs以及应用 众所周知,项目越来越大,开发人员越来越多,我们的代码审查工作会变得越来越复杂,对代码质量控制难度也与日俱增,尽管经验丰富的程序员能审查能检查出 ...
- [hadoop](3) MapReduce:创建计数器、任务状态和写入日志
前言 本章主要讲述了如何在mapreduce任务中添加自定义的计数器,从所有任务中聚合信息,并且最终输出到mapreduce web ui中得到统计信息. 准备工作 数据集:ufo-60000条记录, ...
- flask-script实现自动刷新页面调试
本文flask==1.0.2 1.导入extension包 from flask_script import Manager 2.使用manager管理工具 app = Flask(__name__) ...
- IBatis.Net 下使用SqlBulkCopy 大批量导入数据 问题解决
SQLBulkCopy是继承SQLClient空间下的一个特殊类,它可以帮助我们以映射的方式把DataTable和DataReader数据大批量导入到数据库对应表中 public void Inert ...
- android7.0后对于file://的限制
错误信息: 04-18 14:56:58.283 4440 4440 W System.err: android.os.FileUriExposedException: file:///stora ...