简体   繁体   中英

IdentityServer4 Quickstart for IdentityServer as Identity/api endpoints and MVC client

I'm running asp.net core 3.1 and IdentityServer4 following the quick start and guides.

I'm a bit lost when implementing IS end points and api endpoints in the same project. I want the server to host IS authentication/login urls, apis and mvc client. I want to issue bearer tokens which will be used by the IS host/mvc client and client credential clients.

I have gone through the quick starts and gotten the MVC client and the console client to authenticate with my identity server host, but when I try to use my identity server host to authenticate and then go to one of the view controllers, I just get a circular workflow back through authentication.

I believe it's because my account controller login post method isn't issuing the bearer token. I'm thinking there's a call I need make to identity server during login to get it to set the bearer cookie. (It's also possible I'm just missing something on my view controller to tell it it's part of the group to allow access?)

I have this in which allows the client credentials from the console app to work:

    services.AddAuthentication("Bearer")
    .AddJwtBearer("Bearer", options =>
        {
            options.Authority = Constants.HostUrl;
            options.RequireHttpsMetadata = false;
             options.Audience = "api";
        });

But if I remove it, then the login workflow through the host identity server works and I can access my view and api controllers.

Is there a quick start that I'm missing that shows the identity server also being the mvc client?

Thanks

when I try to use my identity server host to authenticate to itself, I just get a circular workflow back through authentication.

Well, what does it mean for itself ? Do you try to ask for token for the service that is used to host the REST API ?

It looks like you have some kind of client (like background service whatever) and is trying to get token for that client. Is it so?

Seems that you can use the client credentials flow However this requires clientid and secret to be stored somewhere. Here is some documentation .

You can use Identity server's Windows Authentication feature also

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM