Skip to content

Commit 8ae4256

Browse files
committed
Merged use case files
Merged use case files
1 parent 28e4835 commit 8ae4256

7 files changed

+47
-79
lines changed

articles/sessions/concepts/cookies.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,5 @@ Stateless cookies are self-contained; they include all session information that
5959
* [Session Layers](/sessions/concepts/session-layers)
6060
* [Session Lifetime](/sessions/concepts/session-lifetime)
6161
* [Logout](/logout)
62-
* [Use Cases: Sessions](/sessions/references/sample-use-cases-sessions)
63-
* [Use Cases: Sessions and Single-Page Apps](/sessions/references/sample-use-cases-sessions-spas)
62+
* [Session Use Cases](/sessions/references/sample-use-cases-sessions)
6463
* [Example: Short-lived session management workflow](/sessions/references/example-short-lived-session-mgmt)

articles/sessions/concepts/session-layers.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ Alternatively you may desire to also [log the users out of the Identity Provider
5656

5757
## Keep reading
5858

59-
* [Use Cases: Sessions](/sessions/references/sample-use-cases-sessions)
60-
* [Use Cases: Sessions and Single-Page Apps](/sessions/references/sample-use-cases-sessions-spas)
59+
* [Session Use Cases](/sessions/references/sample-use-cases-sessions)
6160
* [Example: Short-lived session management workflow](/sessions/references/example-short-lived-session-mgmt)
6261
* [Auth0 Ruby on Rails SDK Quickstarts: Session Handling](/quickstart/webapp/rails/02-session-handling)
6362
* [Auth0 Android SDK Quickstarts: Session Handling](/quickstart/native/android/03-session-handling)

articles/sessions/concepts/session-lifetime.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ Auth0 maintains a login session for any user who authenticates via an applicatio
6363
* [Sessions](/sessions)
6464
* [Session Layers](/sessions/concepts/session-layers)
6565
* [Logout](/logout)
66-
* [Use Cases: Sessions](/sessions/references/sample-use-cases-sessions)
67-
* [Use Cases: Sessions and Single-Page Apps](/sessions/references/sample-use-cases-sessions-spas)
66+
* [Session Use Cases](/sessions/references/sample-use-cases-sessions)
6867
* [Example: Short-lived session management workflow](/sessions/references/example-short-lived-session-mgmt)
6968
* [Auth0 Ruby on Rails SDK Quickstarts: Session Handling](/quickstart/webapp/rails/02-session-handling)
7069
* [Auth0 Android SDK Quickstarts: Session Handling](/quickstart/native/android/03-session-handling)

articles/sessions/index.md

-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ By default, when a user leaves a website or closes their browser, their session
2020
'sessions/concepts/cookies',
2121
'logout',
2222
'sessions/references/sample-use-cases-sessions',
23-
'sessions/references/sample-use-cases-sessions-spas',
2423
'sessions/references/example-short-lived-session-mgmt'
2524
] }) %>

articles/sessions/references/example-short-lived-session-mgmt.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,4 @@ See [Application-specific logout URLs](/sessions/concepts/session-lifetime#appli
9797
* [Cookies](/sessions/concepts/cookies)
9898
* [Session Lifetime](/sessions/concepts/session-lifetime)
9999
* [Logout](/logout)
100-
* [Use Cases: Sessions](/sessions/references/sample-use-cases-sessions)
101-
* [Use Cases: Sessions and Single Page Apps](/sessions/references/sample-use-cases-sessions-spas)
100+
* [Session Use Cases](/sessions/references/sample-use-cases-sessions)

articles/sessions/references/sample-use-cases-sessions-spas.md

-60
This file was deleted.

articles/sessions/references/sample-use-cases-sessions.md

+43-10
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ contentType: concept
77
useCase:
88
- build-an-app
99
---
10-
# Use Cases: Sessions
10+
# Session Use Cases
1111

12-
Auth0 maintains a login session for any user who authenticates via an application. When a user performs a new standard login, it resets the login session.
12+
## For SPAs using Authorization Code grant
1313

14-
When you build an application that requires authentication, you can use [sessions](/sessions) to determine if a user is authenticated each time a request is made. Let's look at an example.
14+
Auth0 maintains a login session for any user who authenticates via an application. When a user performs a new standard login, it resets the login session.
1515

16-
::: note
17-
This example is accurate for native apps, regular web apps, and single-page apps (SPAs) with a lightweight backend that are using the Authorization Code grant. For SPAs with no backend, see [Sample Use Cases: Sessions and Single-Page Apps](/sessions/references/sample-use-cases-sessions-spas).
18-
:::
16+
When you build an application that requires authentication, you can use [sessions](/sessions) to determine if a user is authenticated each time a request is made. These examples are for SPAs that have a lightweight backend and are using the Authorization Code grant (also, native apps and regular web apps.
1917

2018
Let's say you've built an OIDC-compliant e-commerce website called Storezero.io.
2119

@@ -25,7 +23,7 @@ When checking out, a user can optionally log in to the site, but to view the "My
2523

2624
Before checking out, a user wants to view their previous orders, so they navigate to the "All Orders" section in the "My Account" pages.
2725

28-
## User logs in with Username and Password
26+
### User logs in with username and password
2927

3028
1. Auth0's SDK redirects the user to the Auth0 Authorization Server (**/authorize** endpoint).
3129
2. Your Auth0 Authorization Server creates a session, then redirects the user to the login and authorization prompt.
@@ -40,7 +38,7 @@ Two sessions are created:
4038

4139
* The session on the Authorization Server (storezero.auth0.com): Allows the Authorization Server to know if a user is authenticated and optionally, tracks other information. For example, the Authorization Server can track whether a user has authenticated using [Multi-factor Authentication (MFA)](/multifactor-authentication). If so, the next time the user arrives at the Authorization Server, they won't need to see a login page or be prompted to use MFA again.
4240

43-
## User logs in with Identity Provider
41+
### User logs in with identity provider
4442

4543
Let's say that instead of using their username and password, the user decides to log in with Facebook.
4644

@@ -54,16 +52,51 @@ Let's say that instead of using their username and password, the user decides to
5452
8. The Authorization Server redirects the user back to the application, along with either an ID Token or code (depending on which flow you use).
5553
9. The application authenticates the user and updates it's local session to indicate that the user is logged in.
5654

57-
In addition to the two session created in the previous example, a third session is created:
55+
In addition to the two sessions created in the previous example, a third session is created:
5856

5957
* The session on Facebook's server (facebook.com): Allows Facebook to know if the user is authenticated and if so, provides a <dfn data-key="single-sign-on">[Single Sign-on (SSO)](/sso)</dfn> experience for the user. Since there’s a high probability that the user is already logged in to Facebook, if they choose to log in to storezero.io using Facebook, they will likely not be prompted to enter their credentials.
6058

59+
## For SPAs with no backend using the Implicit grant
60+
61+
When you build an application that requires authentication, you can use [sessions](/sessions) to determine if a user is authenticated each time a request is made. This example is accurate for SPAs that have no backend and are using the Implicit grant.
62+
63+
Let's say you've built an OIDC-compliant e-commerce website called Storezero.io.
64+
65+
![View Sample Web Site: Storezero.io](/media/articles/sessions/use-case-storezero.png)
66+
67+
When checking out, a user can optionally log in to the site, but to view the "My Account" pages, the user _must_ log in.
68+
69+
Before checking out, a user wants to view their previous orders, so they navigate to the "All Orders" section in the "My Account" pages.
70+
71+
### User logs in with identity provider
72+
73+
Let's say that the user decides to log in with Facebook.
74+
75+
1. Auth0's SDK redirects the user to the Auth0 Authorization Server (**/authorize** endpoint).
76+
2. Your Auth0 Authorization Server creates a session.
77+
3. Your Auth0 Authorization Server redirects the user to the login prompt.
78+
4. The user chooses to log in with Facebook.
79+
5. Your Auth0 Authorization Server redirects the user to Facebook's server.
80+
6. Facebook creates a session, then authenticates the user, and updates the session to indicate that the user is logged in.
81+
7. Facebook redirects the user back to the Authorization Server, where the Authorization Server updates its session to indicate that the user is logged in.
82+
8. The Authorization Server redirects the user back to the application, passing an ID Token and Access Token.
83+
9. The application authenticates the user.
84+
85+
Since we are using the Implicit Grant, the client (storezero.io) can consume the ID Token to authenticate the user and can use the Access Token to interact with the API (until it expires). So no local session is created to keep the user logged in.
86+
87+
### Keep the user logged in without a local session
88+
89+
Since we have no local session to keep the user logged in, we can use the session on the Authorization Server to determine whether to force the user to reauthenticate. We do this through [Silent Authentication](/api-auth/tutorials/silent-authentication).
90+
91+
We create a hidden iframe that redirects to the Authorization Server adding the `prompt=none` parameter, which tells the server not to prompt the user for any input. If the session on the Authorization Server has not expired, the transaction continues seamlessly, and the client gets a new Access Token through WMRM (Web Message Response Mode), which leverages postMessage.
92+
93+
If the session on the Authorization Server has expired or the user logs out, the redirect in the iframe will return an error, indicating that the application needs to redirect the user to the Authorization Server to reauthenticate.
94+
6195
## Keep reading
6296

6397
* [Sessions](/sessions)
6498
* [Session Layers](/sessions/concepts/session-layers)
6599
* [Cookies](/sessions/concepts/cookies)
66100
* [Session Lifetime](/sessions/concepts/session-lifetime)
67101
* [Logout](/logout)
68-
* [Use Cases: Sessions and Single Page Apps](/sessions/references/sample-use-cases-sessions-spas)
69102
* [Example: Application Sessions and SSO Sessions Workflow](/sessions/references/example-short-lived-session-mgmt)

0 commit comments

Comments
 (0)