damienbod / AspNetCoreMvcAngular

ASP.NET Core MVC with angular in MVC View OpenID Connect Hybrid Flow
https://damienbod.com/2017/05/02/using-angular-in-an-asp-net-core-view-with-webpack/
MIT License
58 stars 22 forks source link

WebAPI intergration scenario #2

Open sonphnt opened 7 years ago

sonphnt commented 7 years ago

Hi @damienbod

Thanks for a great contribution. Do you think we can add a web api core project here? The flow is:

MVC Angular will be redirected to IdentityServer login page. After successful login there, you will be navigated back to MVC angular.

Angular app need to interact with WebApi to do CRUD function on data. How can we get a valid access token from MVC, so Angular can pass it to Webapi?

Thanks

damienbod commented 7 years ago

A valid access token is returned in the cookie. You could change the flow or the middleware if you want to use the cookie directly, or you could just use the cookie.

Greetings Damien

sonphnt commented 7 years ago

Hi @damienbod

Is there any code showing the way get access token in cookies in Angular. And do we need any configuration between Angular and Webapi ?

Thanks

johnsonps08 commented 7 years ago

@damienbod, it would be really appreciated if you could answer the above question from @sonphnt.

damienbod commented 7 years ago

@johnsonps08 @sonphnt , sorry missed this. No the cookie is http only. If you require an access_token to access an API from a different server, you could use a different flow, or access the API from the server. I will look into this. I will check if access_token can be made public to the client, to access the API

damienbod commented 7 years ago

think this is possible using the connect/token API, will investigate

sonphnt commented 7 years ago

Yes, something as we have 3 servers Angular-Webapi-IdentityServer. Firstly, Angular will be redirected to IdentityServer back and forth to authenticate first. WebAPI talk to IdentityServer in background somehow. And then Angular will request to WebApi to retrieve data after being authenticated at step 1.

That would be nice if we could have a project setup for this scenario.

ncalarco commented 6 years ago

@damienbod were you ever able to investigate whether or not we can make a call out to the connect/token API?

Thank you!