【IdentityServer4】数据库表介绍
主要分三个部分:操作、配置、用户
操作部分
DeviceCodes:设备码?
PersistedGrants:授权记录
配置部分
IdentityResources:身份资源信息
IdentityClaims:声明信息,一个身份资源信息对应一个或多个声明信息,
身份资源信息就是用来组织声明信息的,它们的关系类似角色和权限的关系,授权时选择的是身份资源信息,如下:
最终会将授权的身份资源信息关联的声明信息放入Token中
ApiClaims
ApiResources
public static IEnumerable<ApiResource> Apis =>
new List<ApiResource>{
new ApiResource("Order.WebApi", "订单服务"),
new ApiResource("Product.WebApi", "产品服务")
};
Clients:客户端
public static IEnumerable<Client> Clients =>
new List<Client> {
new Client
{
AllowedGrantTypes=GrantTypes.Hybrid,
ClientId="client",
ClientSecrets={new Secret("secret".Sha256())},
// where to redirect to after login
RedirectUris = { "http://localhost:5002/signin-oidc" },
// where to redirect to after logout
PostLogoutRedirectUris = { "http://localhost:5002/signout-callback-oidc" },
//客户端可以访问的范围
AllowedScopes={
"Order.WebApi",
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"roles"
},
AllowOfflineAccess = true
}
};
ClientCorsOrigins:客户端跨域域名
ClientGrantTypes:客户端授权类型
ClientScopes:客户端会话范围
ClientRedirectUris:客户端回调地址
ClientPostLogoutRedirectUris:客户端退出回调地址
ClientSecrets:客户端密钥
用户部分
用户部分主要包括3种类型的表:用户相关、角色相关、声明相关
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了