首页 新闻 赞助 找找看

identityServer4 授权码模式 如何对接用户表

0
悬赏园豆:200 [已解决问题] 解决于 2021-07-21 15:23

identityServer4 授权码模式

在网上看的例子都是测试数据,或者是新建的User表。

我现在有User表,如何对接到上面,与客户端输入的账户密码进行验证

ufo233-的主页 ufo233- | 初学一级 | 园豆:85
提问于:2021-07-19 15:59

help

唉我干啥啊 2年前

me

唉我干啥啊 2年前
< >
分享
最佳答案
0

框架后面的数据库, 用户表等都是可以替换的, 参考文档:
https://identityserver4.readthedocs.io/en/latest/topics/signin.html?highlight=user#login-user-interface-and-identity-management-system

官方例子用的ASP.NET Core Identity参考:
https://identityserver4.readthedocs.io/en/latest/quickstarts/6_aspnet_identity.html#refaspnetidentityquickstart

Microsoft.AspNet.Identity 自定义使用现有的表—登录实现, 一篇可能过时的文档可以参考一下.
https://www.cnblogs.com/calvinK/p/4648138.html

Finally, notice the addition of the new call to AddAspNetIdentity<ApplicationUser>. AddAspNetIdentity adds the integration layer to allow IdentityServer to access the user data for the ASP.NET Core Identity user database. This is needed when IdentityServer must add claims for the users into tokens.

Note that AddIdentity<ApplicationUser, IdentityRole> must be invoked before AddIdentityServer.

参考一下AddAspNetIdentity里面的实现, 看看替换了哪些service, 照葫芦画瓢你可以替换就为你自己的任何实现就可以了.

收获园豆:200
czd890 | 专家六级 |园豆:14292 | 2021-07-20 12:05

老哥,我如何在api的服务端,获取请求的access token中的Scope的值啊

ufo233- | 园豆:85 (初学一级) | 2021-07-22 10:20

@唉我干啥啊: 解token, 然后应该有claim类似字段包含授权的scoeps. 如果你api已经授权了. 可以直接从httpcontext 的user 的claim拿到.

czd890 | 园豆:14292 (专家六级) | 2021-07-22 11:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册