我使用IdentityServer4(v2.2.1)与.Net Core 2.0和Asp.Net核心身份.我的解决方案中有三个项目.
我正在尝试在我的Web API上实现基于角色的授权,以便任何客户端都可以将访问令牌传递给Web API以访问资源.
目前我可以在MVC应用程序控制器上实现Roles基础授权,但我无法为WEB API Controller传递/配置相同的权限.
以下是Identity Server Files:Config.cs
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
//SCOPE - Resource to be protected by IDS
new ApiResource("TCSAPI", "TCS API")
{
UserClaims = { "role" }
}
};
}
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "TCSIdentity",
ClientName = "TCS Mvc Client Application .",
AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
RequireConsent = false,
ClientSecrets =
{
new Secret("secret".Sha256()) …Run Code Online (Sandbox Code Playgroud) 我正在使用身份服务器4。事实上,它仍然可以正常工作,一切正常。但是当我尝试打电话时
var client = new HttpClient();
// discover endpoints from metadata
var disco = client.GetDiscoveryDocumentAsync(IDPBaseURL).Result;
it gives me error
http://xxx.x.x.xx:8080/.well-known/openid-configuration: HTTPS required.
Run Code Online (Sandbox Code Playgroud)
它可以在Visual Studio和本地IIS部署中使用。但是我仅在服务器上部署时才遇到此错误。
任何的想法?