abp icon indicating copy to clipboard operation
abp copied to clipboard

Create local Identity User after external login (AAD) from angular

Open luisp88 opened this issue 6 years ago • 6 comments

I already have the AAD login success, put the token in http request (via local storage access_token) and everything works fine. The problem is that when AAD is used, no local identity is created and it passes the [Authorized] but I doesnt have any user permissions, so I need to create and "assign" to the local user. Adds the authentication (api): image Adds the AAD prompt (angular): image When obtained the token, set to local storage and it uses automatically in requests headers (that's why Authorized is passed ok): image

luisp88 avatar Mar 16 '20 14:03 luisp88

I already checked #2815 but that uses .cshtml pages

luisp88 avatar Mar 16 '20 14:03 luisp88

It seems that it only needs the access_token in localStorage and it is not validating anything in backend (removed the AddAzureAd or AddAzureADBearer and behaviour is the same) image Someone has this already working?

luisp88 avatar Mar 16 '20 15:03 luisp88

Hello @luisp88,

Did you solve the problem? If not, can you give me more information about your project structure? (tiered etc)

gterdem avatar Apr 08 '20 22:04 gterdem

@gterdem thanks for your concern. I'm using abp template: EFCore angular, all backend projects in same solution (identityserver is in the same backend project). My angular project (using import { MsalGuard } from '@azure/msal-angular';) redirect to MS login and authenticate the user in its tenant OK, but the backend isn't authenticating the calls Localstorage after MS Login: image Http requests is sending bearer in header: image But api logs shows: AuthenticationScheme: Bearer was not authenticated. image

My code (based on your documentation): image

I have two azure app registration configured, one for angular and one for backend. The frontapp has the callbackUrl since it will be doing the authentication and what I think is that the backendapp will be checking the token when angular makes endpoint calls.

luisp88 avatar Apr 22 '20 15:04 luisp88

If I use /account/login's AzureActiveDirectory button, I can login and go thru my custom sign in manager (getexternallogin, etc), so I think it is something to do with the call from angular to API. I was passing in auth bearer the rawIdToken from MS, but I think I need to do something else to get the actual access token before calling my API? If someone could guide me I would appreciate it a lot. Thanks in advance

luisp88 avatar Apr 22 '20 22:04 luisp88

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 29 '20 09:07 stale[bot]