1
votes

We are using IdentityServer as an openid provider for our web applications and APIs resources. I want to expose a secure api endpoint on identity server for editing users, somehow I can not get configuration working. my client is angular and I have a valid bearer token.

app.UseCors("AllowSpecificOrigin");
app.UseIdentity();
app.UseIdentityServer();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
   AuthenticationScheme = "Cookies"
});

JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
   {
      Authority = Configuration["AuthServerUrl"],
      ScopeName = "api",
      AutomaticAuthenticate = true,
      AutomaticChallenge = true,
      RequireHttpsMetadata = false
   });

any help will be appreciated.

1

1 Answers

0
votes

You can branch your application with using MapWhen like below:

         app.MapWhen(x => x.Request.Path.StartsWithSegments("/custom"), builder =>
         {
             builder.UseCookieAuthentication(new CookieAuthenticationOptions
             {
                AuthenticationScheme = "Cookies"
             });

             JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

             builder.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
             {
                 Authority = Configuration["AuthServerUrl"],
                 ScopeName = "api",
                 AutomaticAuthenticate = true,
                 AutomaticChallenge = true,
                 RequireHttpsMetadata = false
            });
            // .....
         });
         app.UseIdentity();
         app.UseIdentityServer();
         //...