Web Api .net 框架
我有一个使用 IdentityServer4 .net core 1.1 完成的身份验证服务。
客户端设置如下:
new Client
{
ClientId = "client",
AllowedGrantTypes = GrantTypes.ClientCredentials,
ClientSecrets =
{
new Secret("secret".Sha256())
},
AllowedScopes = { "api1" }
},
// resource owner password grant client
new Client
{
ClientId = "ro.client",
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
ClientSecrets =
{
new Secret("secret".Sha256())
},
AllowedScopes = { "api1" }
},
// OpenID Connect hybrid flow and client credentials client (MVC)
new Client
{
ClientId = "mvc",
ClientName = "MVC Client",
AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
RequireConsent = true,
ClientSecrets =
{
new Secret("secret".Sha256())
},
RedirectUris = { "http://localhost:5002/signin-oidc" },
PostLogoutRedirectUris = { "http://localhost:5002/signout-callback-oidc" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
},
AllowOfflineAccess = true
},
// JavaScript Client
new Client
{
ClientId = "js",
ClientName = "JavaScript Client",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
RedirectUris = { "http://localhost/web/main.html#/redirectLogin#" },
PostLogoutRedirectUris = { "http://localhost/web" },
AllowedCorsOrigins = { "http://localhost" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
},
RequireConsent = false
}
我有一个使用 oidc-client 的带有 javascript 的前端应用程序。
在其中我可以使用以下设置向身份验证服务器进行身份验证:
var userManagerConfig = {
authority: "http://localhost:5000",
client_id: "js",
redirect_uri: "http://localhost/web/main.html#/redirectLogin#",
response_type: "id_token token",
scope: "openid profile api1",
post_logout_redirect_uri: "http://localhost/web",
};
var userManager = new Oidc.UserManager(userManagerConfig);
我还有一个用 .net Framework 4.6.1 制作的 api web。
在其中我想从前端接收身份验证并使用身份验证服务器来验证访问。
针对这种情况应该如何设置呢?