.NET Core – Using multiple authentication schemes with a dedicated Authentication API [closed]

I'm trying to create a dedicated authentication API to which my other APIs will refer to when authenticating credentials. According to this link, I could do that using multiple authentication schemes, by using a similar piece of code below:

public void ConfigureServices(IServiceCollection services)
{
    // Code omitted for brevity

    services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
        .AddJwtBearer(options =>
        {
            options.Audience = "https://localhost:5000/";
            options.Authority = "https://localhost:5000/identity/";
        })
        .AddJwtBearer("AzureAD", options =>
        {
            ...
        });
}

Some questions I have about this:

  1. I'm guessing this code will go to my other APIs, and the options.Authority will have to change to the URL pointing towards my authentication API endpoint, right?
  2. If #1 is right, how should the identity endpoint of the authentication API look like, exactly?
  3. This is not in the code above, but what is the difference between options.Authority and the ValidIssuer of options.TokenValidationParameters? They kinda seem similar to me; don't they both point to the issuer of the JWT token for authorization? Should I use one over the other on my other APIs, as opposed to my authentication API?

Thank you for any help you can provide me!



Read more here: https://stackoverflow.com/questions/64886449/net-core-using-multiple-authentication-schemes-with-a-dedicated-authenticatio

Content Attribution

This content was originally published by Mark Malabanan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: