|
|
using IdentityServer4.Models;
|
|
|
|
|
|
namespace DS.WMS.OpenAuth;
|
|
|
|
|
|
public static class Config
|
|
|
{
|
|
|
public static IEnumerable<IdentityResource> IdentityResources =>
|
|
|
new IdentityResource[]
|
|
|
{
|
|
|
new IdentityResources.OpenId(),
|
|
|
new IdentityResources.Profile(),
|
|
|
new IdentityResources.Address(),
|
|
|
new IdentityResources.Phone(),
|
|
|
new IdentityResources.Email()
|
|
|
};
|
|
|
public static IEnumerable<ApiResource> ApiResources =>
|
|
|
new List<ApiResource> { new ApiResource("openapi", "WMS对外开放服务-openapi"){
|
|
|
Scopes={ "openapi","openapi" }
|
|
|
|
|
|
},
|
|
|
new ApiResource("hkapi", "WMS对外开放服务-hkapi"){
|
|
|
Scopes={ "hkapi","hkapi" }
|
|
|
},
|
|
|
};
|
|
|
// new ApiResource[]
|
|
|
// {
|
|
|
// new ApiResource("orderApi","对外开放服务")
|
|
|
// {
|
|
|
// ApiSecrets ={ new Secret("orderApi secret".Sha256()) },
|
|
|
// Scopes = { "openApiScope" }
|
|
|
// },
|
|
|
// };
|
|
|
public static IEnumerable<ApiScope> ApiScopes =>
|
|
|
new ApiScope[]
|
|
|
{
|
|
|
new ApiScope("openapi","openapi"),
|
|
|
new ApiScope("hkapi", "hkapi"),
|
|
|
};
|
|
|
/// 客户端模式(Client Credentials)
|
|
|
/// 可以将ClientId和ClientSecret视为应用程序本身的登录名和密码。
|
|
|
/// 它将您的应用程序标识到身份服务器,以便它知道哪个应用程序正在尝试与其连接。
|
|
|
public static IEnumerable<Client> Clients =>
|
|
|
new Client[]
|
|
|
{
|
|
|
// new Client
|
|
|
// {
|
|
|
// //客户端标识
|
|
|
// ClientId = "client",
|
|
|
// //没有交互用户,使用clientid/secret进行身份验证,适用于和用户无关,机器与机器之间直接交互访问资源的场景。
|
|
|
// AllowedGrantTypes = GrantTypes.ClientCredentials,
|
|
|
// //认证密钥
|
|
|
// ClientSecrets = { new Secret("secret".Sha256()) },
|
|
|
// //客户端有权访问的作用域
|
|
|
// AllowedScopes = { "openapi" }
|
|
|
// },
|
|
|
new Client
|
|
|
{
|
|
|
ClientId = "portClient",
|
|
|
ClientSecrets = new [] { new Secret("&L*1v8k".Sha512()) },
|
|
|
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
|
|
|
AllowedScopes = new [] { "openapi", }
|
|
|
},
|
|
|
new Client
|
|
|
{
|
|
|
ClientId = "hkportClient",
|
|
|
ClientSecrets = new [] { new Secret("&L^9v8k".Sha512()) },
|
|
|
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
|
|
|
AllowedScopes = new [] { "hkapi", }
|
|
|
}
|
|
|
};
|
|
|
// /// <summary>
|
|
|
// /// 定义哪些用户将使用这个IdentityServer
|
|
|
// /// </summary>
|
|
|
// /// <returns></returns>
|
|
|
// public static IEnumerable<TestUser> GetUsers()
|
|
|
// {
|
|
|
// return new[]
|
|
|
// {
|
|
|
// new TestUser
|
|
|
// {
|
|
|
// SubjectId="10000",
|
|
|
// Username = "ZongYu1119",
|
|
|
// Password = "12345"
|
|
|
// },
|
|
|
// new TestUser
|
|
|
// {
|
|
|
// SubjectId="10001",
|
|
|
// Username ="Admin",
|
|
|
// Password ="12345"
|
|
|
// }
|
|
|
// };
|
|
|
// }
|
|
|
} |