We have several web applications, all of which will be adapted to use a single authentication endpoint based on IdentityServer4 and OpenId Connect.
I would like some argumented advice regarding the following (simplified) flows that I'm considering.
Cookies:
- User accesses app1 and hits Login
- User is taken to the IdP login page
- User logs-in and is taken back to app1
- app1 provides a link to app2, which is clicked by the user
- app2 takes her to the IdP login page
- IdP cookies haven't expired, and therefore, no user credentials are requested. Consequently, the user is auto-logged-in and taken back to the app2.
Token-based authentication:
- User accesses app1 and hits Login
- User is taken to the IdP login page
- User logs-in and is taken back to app1
- app1 provides a link to app2, which is clicked by the user
- app1 redirects the user to app2 but also provides the id_token obtained previously from the IdP (item 2.3 above)
- app2 verifies that the id_token is valid and automatically logs the user in.
Questions:
- Which one is better? (Cookies vs. Token "sharing")
- Is there a different (i.e. better) flow I should implement?