title: OWIN and Azure AD HTTPS to HTTP Redirect Loop
body: <p>I am very new to OWIN :).  I am trying to have a page with an open public area which will allow anonymous over HTTP, and then a restricted section which will require authentication.  I'd like not to force the entire site to be HTTPS for general users.  </p>
  
  <p>The issue I have is that I receive the following loop:</p>
  
  <ol>
  <li><a href="http://example.com/authenticatedPage" rel="noreferrer">http://example.com/authenticatedPage</a> -> 302 Redirect to AD login</li>
  <li>Login to AD page HTTP 200.  Triggers open of the Azure AD link to site.</li>
  <li>Link to site identifies that this is an OWIN redirect and does a 302 redirect to <a href="http://example.com/authenticatedPage" rel="noreferrer">http://example.com/authenticatedPage</a></li>
  <li>Go to 1.</li>
  </ol>
  
  <p>I have tried 3 ways of intercepting the redirect in OWIN but nothing seems to work.  </p>
  
  <p>If I begin the session by browsing to <a href="https://example.com/" rel="noreferrer">https://example.com/</a> then click on the link to authenticatedPage, then the login works as I expect. i.e.</p>
  
  <ol>
  <li>Load <a href="https://example.com/authenticatedPage" rel="noreferrer">https://example.com/authenticatedPage</a> -> 302 redirect to AD</li>
  <li>Login to AD -> loads <a href="https://example.com/" rel="noreferrer">https://example.com/</a></li>
  <li>302 redirect to <a href="https://example.com/authenticatedPage" rel="noreferrer">https://example.com/authenticatedPage</a></li>
  </ol>
  
  <p>Is there anyway to fix this without marking my whole site as requiring SSL?</p>