【发布时间】:2020-01-28 08:04:20
【问题描述】:
我有这样的配置
public class Config
{
public static IEnumerable<Client> GetClients(string[] originUris, string[] redirectUris, int tokenLifetime, int slientRefreshToken)
{
return new List<Client>
{
new Client
{
ClientId = "eFMS",
ClientName = "eFMS Services",
AccessTokenLifetime = tokenLifetime,
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
RequireClientSecret = false,
RequireConsent = false,
AlwaysSendClientClaims = true,
AllowAccessTokensViaBrowser = true,
AccessTokenType = AccessTokenType.Jwt,
AllowOfflineAccess = true,
UpdateAccessTokenClaimsOnRefresh = true,
RefreshTokenExpiration = TokenExpiration.Sliding,
SlidingRefreshTokenLifetime = slientRefreshToken,
RedirectUris = redirectUris,
AllowedCorsOrigins= originUris,
AlwaysIncludeUserClaimsInIdToken = true,
AllowedScopes =
{
"openid", "profile", "offline_access", "efms_scope"
},
}
};
}
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource("efms_api", "eFMS D&T API")
{
ApiSecrets = { new Secret("secret".Sha256()) }
}
};
}
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile() { Required = true },
new IdentityResource()
{
Name = "efms_scope",
Description = "eFMS D&T API",
DisplayName = "eFMS D&T API",
UserClaims =
{
"userId","workplaceId","userName","email"
}
}
};
}
}
当我在邮递员中使用用户名:admin 进行测试时,通过:123456 返回令牌 enter image description here
但是如果我对密码进行哈希处理,结果是“invalid_grant”,并且当我调试代码时,不会执行 Task ValidateAsync(ResourceOwnerPasswordValidationContext context) 函数。请帮我解决这个问题
【问题讨论】:
标签: .net asp.net-core identityserver4 password-hash