title: ADFS Single-Sign-On for SharePoint 2013 on-premises, Power BI and custom web app?
body: <h3>Scenario</h3>
  
  <p>There is one user store, namely an on-premises AD. ADFS provides authentication for SharePoint 2013 and Power BI.</p>
  
  <p>The custom web app needs to authenticate users from AD. The web app back-end also requires access to the SharePoint REST API.</p>
  
  <p>The objective is to achieve the above using a single sign on. If singed in to any one of the three applications, the user should not have to input credentials for any of the other two. As well, the custom web app displays content from SharePoint (iFrame and REST API) and Power BI (iFrame).</p>
  
  <p>We have tried the following two solutions but have come across an issue in either case.</p>
  
  <h3>Solution 1</h3>
  
  <ul>
  <li>User inputs credentials in the web app.</li>
  <li>The web app back-end uses these credentials to get a SAML token from ADFS.</li>
  <li>The web app back-end uses the SAML token to authenticate the user with SharePoint through forms-based authentication and retrieves a FedAuth cookie.</li>
  <li>The web app back-end uses the FedAuth cookie to make REST API requests to SharePoint</li>
  <li>The web app front-end uses the SAML token to authenticate the user with SharePoint through forms-based authentication. This allows SharePoint content in iFrames.</li>
  </ul>
  
  <blockquote>
    <p><strong>What doesn't work</strong>: Navigating to Power BI or including it in an iFrame will redirect the user to the ADFS sign in page. This is because the user has not been authenticated with ADFS in the browser yet.</p>
  </blockquote>
  
  <h3>Solution 2</h3>
  
  <ul>
  <li>ADFS SSO is used for the custom web app as well.</li>
  <li>Navigating to any of the three applications redirects the user to the ADFS sign in page</li>
  <li>The user inputs their credentials and get redirected back to the application with a SAML token.</li>
  <li>Navigating to any of the other two applications will redirect the user to ADFS, which will redirect back to the application with another SAML token without requiring the user to sign in again.</li>
  <li>This allows for both SharePoint and Power BI content to be included in the web app in iFrames.</li>
  </ul>
  
  <blockquote>
    <p><strong>What doesn't work</strong>: The web app can't make REST API request to SharePoint using the SAML token received from ADFS for the web app. We have tried to use that SAML token to request another one from ADFS for SharePoint on behalf of the user signed in. That did not work either. As well, SharePoint 2013 on-premises may not accept an on behalf of request.</p>
  </blockquote>
  
  <h3>Question</h3>
  
  <p>Is there a way to have SSO for all three applications while also having REST API access to SharePoint from the web app? The user should have to sign in only once, and preferably only in to the web app.</p>