You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.8 KiB
C#

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("orderApi", "WMS对外开放服务"){
Scopes={ "openapi" }
}
};
// new ApiResource[]
// {
// new ApiResource("orderApi","对外开放服务")
// {
// ApiSecrets ={ new Secret("orderApi secret".Sha256()) },
// Scopes = { "openApiScope" }
// },
// };
public static IEnumerable<ApiScope> ApiScopes =>
new ApiScope[]
{
new ApiScope("openapi"),
};
/// 客户端模式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", }
}
};
// /// <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"
// }
// };
// }
}