ASP.NET Core分布式项目实战(业务介绍,架构设计,oAuth2,IdentityServer4)--学习笔记...
任務(wù)4:第一章計(jì)劃與目錄
敏捷產(chǎn)品開(kāi)發(fā)流程
原型預(yù)覽與業(yè)務(wù)介紹
整體架構(gòu)設(shè)計(jì)
API 接口設(shè)計(jì) / swagger
Identity Server 4 搭建登錄
賬號(hào) API 實(shí)現(xiàn)
配置中心
任務(wù)5:業(yè)務(wù)介紹
項(xiàng)目背景:基于人脈關(guān)系的金融行業(yè)項(xiàng)目
用戶:
1、賬號(hào):
基本資料維護(hù)
登錄
2、管理自己的項(xiàng)目
創(chuàng)建
分享(可見(jiàn)權(quán)限范圍)
置頂
查看項(xiàng)目進(jìn)展
3、引入別人的項(xiàng)目
查看好友的項(xiàng)目
查看二度人脈的項(xiàng)目
查看系統(tǒng)推薦的項(xiàng)目
查看別人的項(xiàng)目
參與別人的項(xiàng)目
4、消息:
聊天消息
系統(tǒng)消息
5、好友:
添加好友(導(dǎo)入通信錄,手機(jī)號(hào)搜索好友)
任務(wù)6:架構(gòu)設(shè)計(jì)
任務(wù)7:oAuth2介紹
OAuth是一個(gè)關(guān)于授權(quán)(authorization)的開(kāi)放網(wǎng)絡(luò)標(biāo)準(zhǔn)
四種授權(quán)方式:
授權(quán)碼模式
簡(jiǎn)化模式
密碼模式
客戶端模式
理解OAuth 2.0:
https://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html
任務(wù)8:IdentityServer4登錄中心
新建項(xiàng)目
dotnet new webapi --name IdentityServerCenter添加 Nuget 包:IdentityServer4
VS Code 如何安裝 nuget:
https://blog.csdn.net/qq_36051316/article/details/84106418
安裝失敗原因及解決方案:
vscode解決nuget插件不能使用的問(wèn)題:
https://www.cnblogs.com/lori/p/11651079.html
Visual Studio 連接不上NuGet 官方程序包源的解決辦法:
https://blog.csdn.net/weixin_34161083/article/details/85764761
配置 Startup 配置
添加引用
using IdentityServer4;注冊(cè)服務(wù)
services.AddIdentityServer().AddDeveloperSigningCredential();使用服務(wù)
app.UseIdentityServer();在 Program.cs 中配置啟動(dòng)端口
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());啟動(dòng)程序
dotnet run訪問(wèn)地址
http://localhost:5000/.well-known/openid-configuration結(jié)果如下( 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 }可以看到四種授權(quán)方式:
"grant_types_supported": ["authorization_code","client_credentials","refresh_token","implicit","urn:ietf:params:oauth:grant-type:device_code"],課程鏈接
http://video.jessetalk.cn/course/explore
相關(guān)文章
ASP.NET Core分布式項(xiàng)目實(shí)戰(zhàn)(課程介紹,MVP,瀑布與敏捷)--學(xué)習(xí)筆記
ASP.NET Core快速入門 -- 學(xué)習(xí)筆記匯總
總結(jié)
以上是生活随笔為你收集整理的ASP.NET Core分布式项目实战(业务介绍,架构设计,oAuth2,IdentityServer4)--学习笔记...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 给 EF Core 查询增加 With
- 下一篇: 你复工了吗?啥感受?