1-新建webapi  IdentityServer4服务器项目

E:\coding\netcore\IdentityServerSample>dotnet new webapi --name IdentityServerCenter

2-增加IdentityServer4 Nuget包, 按下Ctrl+p, 输入>nuget ,增加IdentityServer4包,然后再用dotnet restore保存

3-增加Config.cs类, 用于提供IdentityServer的ApiResource和Client

namespace IdentityServerCenter{
public class Config{
public static IEnumerable<ApiResource> GetResources(){
return new List<ApiResource>(){ new ApiResource("api","My Api")
};
} public static IEnumerable<Client> GetClients(){
return new List<Client>(){ new Client(){
ClientId="client",
AllowedGrantTypes=GrantTypes.ClientCredentials, ClientSecrets = {
new Secret("secret".Sha256())
},
AllowedScopes = {"api"}
}
};
}
}
}

4-在Startup.cs 启用时启用IdentifyServer

 public void ConfigureServices(IServiceCollection services)
{
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryApiResources(Config.GetResources())
.AddInMemoryClients(Config.GetClients()); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseIdentityServer(); //启用IdentityServer
}

5-在Progrom.cs启动类中设置启动的Url

 public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>().UseUrls("http://localhost:5000");

6-输入 http://localhost:5000/.well-known/openid-configuration进行测试IdentityServer4是否起作用,结果如下

8-IdentityServer4登录中心的更多相关文章

  1. 08.IdentityServer4登录中心

    08.IdentityServer4登录中心 IdentityServer就是一套Framework,实现了OAuth的授权 理解OAuth流程,学会怎么使用他 http://ruanyifeng.c ...

  2. 【ASP.NET Core分布式项目实战】(一)IdentityServer4登录中心、oauth密码模式identity server4实现

    本博客根据http://video.jessetalk.cn/my/course/5视频整理 资料 OAuth2 流程:http://www.ruanyifeng.com/blog/2014/05/o ...

  3. ASP.NET Core分布式项目-1.IdentityServer4登录中心

    源码下载 一.添加服务端的api 1.添加NUGet包 IdentityServer4 点击下载,重新生成 2.添加Startup配置 打开Startup文件 public class Startup ...

  4. Asp.Net Core 中IdentityServer4 授权中心之自定义授权模式

    一.前言 上一篇我分享了一篇关于 Asp.Net Core 中IdentityServer4 授权中心之应用实战 的文章,其中有不少博友给我提了问题,其中有一个博友问我的一个场景,我给他解答的还不够完 ...

  5. IdentityServer4 登录成功后,跳转到原来页面

    IdentityServer4 登录成功后,默认会跳转到Config.Client配置的RedirectUris地址http://localhost:5003/callback.html,用于获取 T ...

  6. Asp.Net Core 中IdentityServer4 授权中心之应用实战

    一.前言 查阅了大多数相关资料,查阅到的IdentityServer4 的相关文章大多是比较简单并且多是翻译官网的文档编写的,我这里在 Asp.Net Core 中IdentityServer4 的应 ...

  7. IdentityServer4 登录使用数据库

    业务场景: IdentityServer4 默认使用TestUser和UserStore,需要模拟和加载所有的用户数据,正式环境肯定不能这样实现,我们想从自己的数据库中读取用户信息,另外,因为 Ide ...

  8. 统一登录中心SSO 单点登录系统的构想

    什么是单点登录?我想肯定有一部分人“望文生义”的认为单点登录就是一个用户只能在一处登录,其实这是错误的理解.单点登录指的是多个子系统只需要登录一个,其他系统不需要登录了(一个浏览器内).一个子系统退出 ...

  9. IdentityServer4登陆中心

    1. 使用Vsual Studio Code 终端执行 dotnet new webapi --name IdentityServerSample 命令创建一个webapi 的 IdentitySer ...

随机推荐

  1. 设计模式:装饰器(Decorator)模式

    设计模式:装饰器(Decorator)模式 一.前言    装饰器模式也是一种非常重要的模式,在Java以及程序设计中占据着重要的地位.比如Java的数据流处理,我们可能看到数据流经过不同的类的包装和 ...

  2. 如何使git忽略某些文件或文件夹

    为什么要忽略某些文件或文件夹的变化? git作为一款项目文件变更版本管理软件,其主要功能之一就是追踪项目文件夹内各种文件及文件夹的变更情况.但是,在日常使用中,并非项目文件夹下的所有文件及文件夹变更都 ...

  3. 关于Hibernate多对多关联关系的更新问题。

    一个账套类Reckoning和账套项目类 AccountItem.这两个类是双向多对多关联关系. Reckoning.hbm.xml文件的配置如下 <set name="account ...

  4. MyBatis框架(6)动态sql

    本次全部学习内容:MyBatisLearning   什么是动态sql:     mybatis的核心,对sql进行灵活的操作,通过对表达式的判断,对sql灵活的拼接 在之前小案例的基础上我们先进行简 ...

  5. 几句代码简单实现IoC容器

    前言 最近在调试EasyNetQ代码的时候发现里面有一段代码,就是IoC容器的简单实现,跟着他的代码敲了一遍,发现了奇妙之处.当然也是因为我才疏学浅导致孤陋寡闻了.他的思路就是通过动态调用构造函数生成 ...

  6. java8的4大核心函数式接口

    //java8的4大核心函数式接口//1.Consumer<T>:消费性接口//需求:public void happy(double money, Consumer<Double& ...

  7. 给windows添加路由

    route add 10.0.0.0 mask 255.0.0.0 172.16.1.253 -p

  8. java中常见的math方法

    java.lang.Math :   绝对值: static int abs(int a)  static long abs(long a)  static float abs(float a)  s ...

  9. 课时18.h标签和p标签以及hr标签(掌握)

    如何在webstorm中利用快捷键创建一个新的html的文件? 同时按下键盘上的ctrl+alt+insert(windows) 同时按下键盘上的ctrl+alt+n(os) h标签系列(header ...

  10. java中exception和error有什么区别,运行时异常和一般异常有什么区别

    1.exception和error都是继承了throwable类,在java中只有throwable类型的实例才可以被抛出(throw)或者捕获(catch),它是异常处理机制的基本组成类型 2.ex ...