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. 【系统】在windows中追加/删除虚拟打印机

    由于项目需要在windwos系统中添加多台虚拟打印机(能够正常打印出纸),查找了一下系统函数. 使用 rundll32 printui.dll,PrintUIEntry,在CMD中运行,在弹出框中得到 ...

  2. 罗大佑 光阴的故事 ZT 欧美经典歌曲100首(1-50)

    老俞 my idol ———————————————————————————————— 罗大佑 光阴的故事 歌曲光阴的故事为2008年入库,是罗大佑在2000-1-1发行的专辑<情歌精选> ...

  3. dia无法输入中文的解决

    安装dia后无法输入中文,解决如下: 修改/usr/bin/dia #dia-normal --integrated "$@" dia-normal "$@"

  4. libevent-signal(1)

    现在已经知道,libevent有三种事件类型,分别是时钟事件,信号事件,i/o事件.今天就分析一下信号事件,下面是一个简单的信号事件demo #include <sys/types.h> ...

  5. 一对一关联关系基于主键映射的异常 IdentifierGenerationException

    具体异常:org.hibernate.id.IdentifierGenerationException: attempted to assign id from null one-to-one pro ...

  6. springmvc使用map接收form表单的参数

    其实只需要在map前面加上@RequestParam参数即可,jsp的name等都不变 public String queryByCondition(@RequestParam Map<Stri ...

  7. CSU-ACM2018暑假集训6—BFS

    可以吃饭啦!!! A:连通块 ZOJ 1709 Oil Deposits(dfs,连通块个数) B:素数变换 打表+bfs POJ 3216 Prime Path(打表+bfs) C:水bfs HDU ...

  8. C++重载操作符operator

    operator是C++关键字,用于对C++进行扩展: 1.可以被重载的操作符:new,new[],delete,delete[],+,-,*,/,%,^,&,|,~,!,=,<,> ...

  9. 【JavaScript-基础-cookie从入门到进阶】

    cookie 关于cookie 用于方便服务端管理客户端状态提出的一种机制. document.cookie 客户端JavaScript可通过document.cookie方式获取非HTTPOnly状 ...

  10. Struts2+hibernate 结合,实现登陆校验

    完整的项目在github中,数据库使用postgresql,建表语句见项目文档. 下面我分块介绍一下struts2.hibernate.与页面部分的代码. Struts2 UserAction.jav ...