WebApi, secure Azure Active Directory, invoked from JavaScript

I have the following script:

1.- Azure web api project that I want to protect against using Azure AD (I am not against Token, cookie, no matter how much it matches the whole scenario)

2.- The Azure website at asp.net MVC, also protected by Azure AD. This website should call the web api controller with SSO (I use the same Azure AD in the whole scenario)

3.- Some JavaScript code running on a page in SharePoint Online also calls the web api controller in any safe way (Office 365 tenant also uses the same Azure AD). If you don’t know about SharePoint, let's say I have a SPA project where I can only use Javascript and html (without server side code).

Following some MS Azure AD samples and some blogs from Vittorio Bertocci, I can get points 1 and 2, working fine using OWIN and Oppen IDs. However, it seems impossible to reach point 3. Since I'm inside a page in SharePoint Online, I can only use javascript, not server-side code. I would like to get a valid token for the current user who is already registered in the SP, and remember that SP uses the same Azure AD as the api website. Can I call Azure AD and get a valid token, only from the client code?

I am open to any possible solution. I can do everything in a web avi project. If you think in a SharePoint application with appPart, and appPart calls the web api from the server-side code, I agree that this will work, but this is an option that is currently prohibited :(

.

+4
7

, , , , , , ; , , .

ADAL JS ( OAuth), SP, , ( ).

, , , /.

, , "" , . Azure Hosted Web API SharePoint Online JavaScript Office 365
  ADAL , / . (cookie) CORS () .

, , IE - . , IE IE.

+2

. Microsoft .

3) (.. HTML- JavaScript, SharePoint Online ) 1) ( - Api Azure).

, , SharePoint Online ( , JavaScript), Office 365/SharePoint Online . App Model, HTML/JavaScript- -. Web Api - "-".

:

cookie cookie ReadOnly . SharePoint Online ( appregnew.aspx). url (, https://cloudservice.customer.com/api/authentication/token) .

https://customer.sharepoint.com/sites/devassets/_layouts/15/appredirect.aspx?instance_id= {GUID} jQuery ajax . AppRedirect SPAuthToken, (, ), SharePoint context.Web.CurrentUser. , (.. jQuery ajax ).

, , .

. Refresh AccessToken , SharePoint. HTML UI - SharePoint Azure.

+4

ADAL.js, ​​ CORS API O365, script , Azure AD, -API.

http://www.andrewconnell.com/blog/adal-js-cors-with-o365-apis-files-sharepoint

+3

AAD OAuth2 ( OpenId Connect), AAD (), , , . , ! Cheers,

V.

update, , , : http://www.cloudidentity.com/blog/2015/02/19/introducing-adal-js-v1/ !

+1

, , HTML/JS, , SharePoint.

Azure AD (ADAL) HTML5. ( ) , -, ; , "-".

, , # ADAL OAuth. , , :

SharePoint

0

.

, SP-Hosted App, . SP SP Online, JS-, , SP- .

, , , , ( ) , , , apppart ( WSP). , , AJAX .

, , , . , , - - , , , .

Thanks again!

0
source

Read the following MSDN links for external data access settings for an application hosted in SharePoint -

0
source

Source: https://habr.com/ru/post/1547487/


All Articles