ASP.NET Core分布式项目实战(业务介绍,架构设计,oAuth2,IdentityServer4)--学习笔记
任务4:第一章计划与目录
- 敏捷产品开发流程
- 原型预览与业务介绍
- 整体架构设计
- API 接口设计 / swagger
- Identity Server 4 搭建登录
- 账号 API 实现
- 配置中心
任务5:业务介绍
项目背景:基于人脉关系的金融行业项目
用户:
1、账号:
- 基本资料维护
- 登录
2、管理自己的项目
- 创建
- 分享(可见权限范围)
- 置顶
- 查看项目进展
3、引入别人的项目
- 查看好友的项目
- 查看二度人脉的项目
- 查看系统推荐的项目
- 查看别人的项目
- 参与别人的项目
4、消息:
- 聊天消息
- 系统消息
5、好友:
- 添加好友(导入通信录,手机号搜索好友)
任务6:架构设计

任务7:oAuth2介绍
OAuth是一个关于授权(authorization)的开放网络标准
四种授权方式:
- 授权码模式
- 简化模式
- 密码模式
- 客户端模式
理解OAuth 2.0:
https://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html
任务8:IdentityServer4登录中心
新建项目
dotnet new webapi --name IdentityServerCenter
添加 Nuget 包:IdentityServer4
VS Code 如何安装 nuget:
https://blog.csdn.net/qq_36051316/article/details/84106418
安装失败原因及解决方案:
vscode解决nuget插件不能使用的问题:
https://www.cnblogs.com/lori/p/11651079.html
Visual Studio 连接不上NuGet 官方程序包源的解决办法:
https://blog.csdn.net/weixin_34161083/article/details/85764761
配置 Startup 配置
添加引用
using IdentityServer4;
注册服务
services.AddIdentityServer()
.AddDeveloperSigningCredential();
使用服务
app.UseIdentityServer();
在 Program.cs 中配置启动端口
webBuilder.UseUrls("http://localhost:5000");
添加配置类 Config.cs,初始化 IdentityServer4
using System.Collections;
using System.Collections.Generic;
using IdentityServer4.Models;
namespace IdentityServerCenter
{
public class Config
{
public static IEnumerable<ApiResource> GetResource()
{
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"},
}
};
}
}
}
更改 IdentityServer4 配置
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryApiResources(Config.GetResource())
.AddInMemoryClients(Config.GetClients());
启动程序
dotnet run
访问地址
http://localhost:5000/.well-known/openid-configuration
结果如下( json 格式化)
{
"issuer": "http://localhost:5000",
"jwks_uri": "http://localhost:5000/.well-known/openid-configuration/jwks",
"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": [
"api",
"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"
],
"id_token_signing_alg_values_supported": [
"RS256"
],
"subject_types_supported": [
"public"
],
"code_challenge_methods_supported": [
"plain",
"S256"
],
"request_parameter_supported": true
}
可以看到四种授权方式:
"grant_types_supported": [
"authorization_code",
"client_credentials",
"refresh_token",
"implicit",
"urn:ietf:params:oauth:grant-type:device_code"
],
课程链接
http://video.jessetalk.cn/course/explore


本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
欢迎转载、使用、重新发布,但务必保留文章署名 郑子铭 (包含链接: http://www.cnblogs.com/MingsonZheng/ ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。
如有任何疑问,请与我联系 (MingsonZheng@outlook.com) 。
ASP.NET Core分布式项目实战(业务介绍,架构设计,oAuth2,IdentityServer4)--学习笔记的更多相关文章
- 【ASP.NET Core分布式项目实战】(三)整理IdentityServer4 MVC授权、Consent功能实现
本博客根据http://video.jessetalk.cn/my/course/5视频整理(内容可能会有部分,推荐看源视频学习) 前言 由于之前的博客都是基于其他的博客进行开发,现在重新整理一下方便 ...
- 【ASP.NET Core分布式项目实战】(二)oauth2 + oidc 实现 server部分
本博客根据http://video.jessetalk.cn/my/course/5视频整理(内容可能会有部分,推荐看源视频学习) 资料 我们基于之前的MvcCookieAuthSample来做开发 ...
- ASP.NET Core分布式项目实战
ASP.NET Core开发者成长路线图 asp.net core 官方文档 https://docs.microsoft.com/zh-cn/aspnet/core/getting-started/ ...
- 【笔记目录2】ASP.NET Core分布式项目实战
当前标签: ASP.NET Core分布式项目实战 共2页: 上一页 1 2 11.ClientCredential模式总结 GASA 2019-03-11 12:59 阅读:26 评论:0 10. ...
- 【笔记目录1】ASP.NET Core分布式项目实战
当前标签: ASP.NET Core分布式项目实战 共2页: 1 2 下一页 35.Docker安装Mysql挂载Host Volume GASA 2019-06-20 22:02 阅读:51 评论 ...
- ASP.NET Core分布式项目实战-目录
前言 今年是2018年,发现已经有4年没有写博客了,在这4年的时光里,接触了很多的.NET技术,自己的技术也得到很大的进步.在这段时光里面很感谢张队长以及其他开发者一直对.NET Core开源社区做出 ...
- 【ASP.NET Core分布式项目实战】(一)IdentityServer4登录中心、oauth密码模式identity server4实现
本博客根据http://video.jessetalk.cn/my/course/5视频整理 资料 OAuth2 流程:http://www.ruanyifeng.com/blog/2014/05/o ...
- 【ASP.NET Core分布式项目实战】(五)Docker制作dotnet core控制台程序镜像
Docker制作dotnet core控制台程序镜像 基于dotnet SDK 新建控制台程序 mkdir /home/console cd /home/console dotnet new cons ...
- 【ASP.NET Core分布式项目实战】(六)Gitlab安装
Gitlab GitLab是由GitLabInc.开发,使用MIT许可证的基于网络的Git仓库管理工具,且具有wiki和issue跟踪功能.使用Git作为代码管理工具,并在此基础上搭建起来的web服务 ...
- 【ASP.NET Core分布式项目实战】(四)使用mysql/mysql-server安装mysql
Docker安装Mysql 拉取镜像 docker pull mysql/mysql-server 运行mysql docker run -d -p : --name mysql01 mysql/my ...
随机推荐
- 元素scroll系列属性
scroll翻译过来,就是滚动的,我们使用scroll系列的相关属性可以动态的得到该元素的大小.滚动距离等. scroll系列属性 作用 element.scrollTop 返回被卷上去的上侧距离,返 ...
- 如何通过canvas实现电子签名
想要实现一个电子签名,可以支持鼠标签名,还能类似书法效果线条有粗有细,同时可以导出成图片. 一.实现连贯的划线 1)首先需要注册鼠标下压.鼠标放开.鼠标移出和鼠标移动事件,通过鼠标下压赋值downFl ...
- apache-jmeter-5.6.3版本报错:errorlevel=1的解决办法
一.背景: 今天遇到了apache-jmeter-5.6.3版本,下载解决后,打开bin下的:jmeter.bat报错 二.解决方法: 尝试解决了jmeter.bat的内存占用还是没有解决 最终发现 ...
- python global函数的使用
1.在全局变量与局部变量均存在时自定义的函数优先使用局部变量,自定义函数并不能改变全局变量的值. 查看运行结果: 2.在没有局部变量时,使用全局变量,且函数内部不能改变全局变量的值 查看运行结果: ...
- 小白学标准库之 mux
本文介绍第三方库 gorilla/mux,相比于 Go 自带的 net/http 它能提供更为强大的路由处理功能. mux 表示 HTTP request multiplexer (HTTP 请求多路 ...
- GoLang 指针初探
1. 内置类型和引用类型 Go 中内置类型包括数值类型,字符串类型和布尔类型.引用类型包括切片,映射,通道,接口和函数类型.其中,引用类型表示创建的变量包含一个指向底层数据结构的指针和一组管理底层数据 ...
- 【MCU】单片机如何检测市电通断?(应用甚广~)
[来源]https://mp.weixin.qq.com/s/TQKtEbxS8WSo3D1MecdMIw
- [转帖]centos6 free 和 centos 7的free 的差异与对比
目录 一 centos6 free 常用参数和含义 centos6 free 命令示例 free 值讲解 计算公式 二 centos7 free 常用的参数 centos7 free 命令示例 计算公 ...
- [转帖]是的你没看错,HTTP3来了
https://www.jianshu.com/p/288ce6a8ab88 简介 很多小伙伴可能还沉浸在HTTP1.1的世界无法自拔,但是时代的洪流已经带领我们来到了HTTP3的世界了.是的,你在桥 ...
- [转帖]从CPU指令集自主到信息技术产业自主
https://zhuanlan.zhihu.com/p/365210753 现代信息技术的应用都是以计算机为基础,CPU是计算机中的信息处理中枢.CPU指令集是CPU逻辑电路与操作系统和应用程序交流 ...