title: Share SPRING_SECURITY_CONTEXT between two applications
body: <p>I have two different Spring Boot Applications that run on localhost on different ports (8080, 8081) and different configs (application.yml). These apps use SSO with OAuth 2.0 to get authorization token from Authorization Server. I log in to my first application, get authorization and everything works great here. Now I need to share these authentication details with second Spring Boot App (on port 8081) to authorize second app in Authorization Server. Googled and found 2 aproaches: I can try to share <code>HttpSession</code> between two apps (but I think it's redundant) OR <code>HttpSessionSecurityContextRepository</code> as <code>SecurityContextRepository</code> which seems more convenient. The problem here is that I can't manage to do so and I'm still not sure that it's a good idea to share Security Context between 2 apps.</p>
  
  <p>What I tried for now:</p>
  
  <ol>
  <li>Share authorization token from first app via headers in GET request <em>(custom-built in accordance with specification for requests for Authorization Server)</em>, but it didn't work - second app doesn't take in mind this token.</li>
  <li>Share authorized cookie from first app to second, but it didn't work, too.</li>
  </ol>
  
  <p>I can't do authorization through Authorization Server on second app because it may be not a Spring Boot App with <code>@Controller</code> but any other app <em>without</em> HTML forms, so I need to authorize on first app <strong>(with UI)</strong>, get all the data which is needed to perform authorized requests and pass it to second app (third, fourth...) so they will be able to do authorized requests too.</p>
  
  <p>Thanks in advance!</p>