У меня сервер идентификации в Azure, когда я пытаюсь развернуть ядро MVC asp .net в качестве клиента. ошибка неавторизованного клиента. что не так с моим конфигом ниже?
Клиент запуска MVC
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
services.AddAuthentication(options => {
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies")
.AddOpenIdConnect("oidc", options => {
options.SignInScheme = "Cookies";
options.Authority = Configuration.GetValue<string>("server:identityurl");
options.RequireHttpsMetadata = false;
options.ClientId = Configuration.GetValue<string>("server:clientid");
options.ClientSecret = Configuration.GetValue<string>("server:clientsecret");
options.ResponseType = Configuration.GetValue<string>("server:responsetype");
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add(Configuration.GetValue<string>("server:scope1"));
options.Scope.Add(Configuration.GetValue<string>("server:scope2"));
});
Appsetting.json & Appsetting.Development.Json
"server": {
"identityurl": "https://pdjayaauthapi.azurewebsites.net",
"clientid": "webapp2",
"clientsecret": "web123",
"responsetype": "code id_token",
"scope1": "masterdataapi",
"scope2": "offline_access"
}
Запуск Identity Server
public void ConfigureServices(IServiceCollection services)
{
var sqlConnectionString = Configuration.GetConnectionString("MySqlCon");
services.AddDbContext<PDJayaDB>(options =>
options.UseMySql(
sqlConnectionString,
b => b.MigrationsAssembly("PDJaya.Identity")
)
);
//my user repository
services.AddScoped<IUserRepository, UserRepository>();
services.AddSingleton<IConfiguration>(Configuration);
services.AddMvc();
// configure identity server with in-memory stores, keys, clients and resources
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients())
.AddTestUsers(Config.GetUsers())
.AddProfileService<ProfileService>();
//Inject the classes we just created
services.AddTransient<IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
services.AddTransient<IProfileService, ProfileService>();
}
и это мой конфиг сервера идентификации для определения клиента asp .net mvc.
Конфигурация Identity Server
новый клиент
ClientId = "webapp2",
ClientName = "web with openid",
AllowedGrantTypes = GrantTypes.Implicit,
ClientSecrets =
{
new Secret("web123".Sha256())
},
RedirectUris = { "http://pdjayaauthapi.azurewebsites.net/signin-oidc" },
PostLogoutRedirectUris = { "http://pdjayaauthapi.azurewebsites.net/signout-callback-oidc" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"masterdataapi",
"transactionapi"
},
AllowOfflineAccess = true