Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add app suite use case #3391

Merged
merged 19 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions astro/src/content/docs/get-started/use-cases/app-suite.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: App Suite
description: Let your users log in once and then transparently be logged into others.
section: get started
subcategory: use cases
navOrder: 20
---
import ApplicationSwitchDiagram from 'src/diagrams/docs/get-started/use-cases/app-suite/application-switch.astro';
import AppSuiteDescription from 'src/content/docs/get-started/use-cases/_app-suite-description.mdx';
import Breadcrumb from 'src/components/Breadcrumb.astro';

## Overview

<AppSuiteDescription />

## Problem

You have multiple applications that you want to share across a common user base.
mooreds marked this conversation as resolved.
Show resolved Hide resolved
mooreds marked this conversation as resolved.
Show resolved Hide resolved

These applications may:

* be hosted at different domains or under different paths
* use SAML or OIDC for authentication
* be custom, commercial or open source
mooreds marked this conversation as resolved.
Show resolved Hide resolved
* be written using different technology stacks

You want to let your users log in once, and switch between applications without having to log in again. Users have different roles for each application.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

## Solution

With the app suite use case, after the user logs in to one application, they are logged in to all of them.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

You'll also have one customer profile and can view their login activity across the applications.

## Prerequisites

You have configured your application or applications to [delegate authentication to FusionAuth](/docs/get-started/use-cases/auth-service) via the Authorization Code grant and the hosted login pages.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

## Example Scenario

Suppose you have a thriving e-commerce business with multiple applications:
mooreds marked this conversation as resolved.
Show resolved Hide resolved

mooreds marked this conversation as resolved.
Show resolved Hide resolved
* an ecommerce store where people can buy clown costumes
mooreds marked this conversation as resolved.
Show resolved Hide resolved
* a virtual try-on app which lets you see yourself in the outfits before you buy
* a forum for discussion about the latest trends
* a ticketing system for customer support

All of these use FusionAuth for their login. Each is represented by a different application, but your users have to log in each time they switch between applications.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

## Actors/Components

* your user and their client application (mobile app or browser)
* two or more applications
* FusionAuth

This use case is built on cookies and redirects to FusionAuth. The redirect is typically transparent to the end user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This use case is built on cookies and redirects to FusionAuth. The redirect is typically transparent to the end user.
This use case is built on cookies and redirects to FusionAuth. The redirect is typically transparent to the end user (read: they won't notice it, but will appreciate the seamless integration).


## Implementation Steps

This is a two step implementation process to ensure customers can access all the applications. Steps to take:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is a two step implementation process to ensure customers can access all the applications. Steps to take:
This is a two step implementation process to ensure customers can access all the applications. Don't worry -- it's a quick process as there are only two steps to take:


* Ensure that end users have their FusionAuth SSO session enabled when they first authenticate.
mooreds marked this conversation as resolved.
Show resolved Hide resolved
* Have applications to forward users to FusionAuth when they are not logged in to the application.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

### Force SSO Session Creation

The easiest way to force the SSO session to be created for each user authentication is to modify the login page of the theme. Rather than allow the user to check or uncheck the `rememberDevice` checkbox, which is the default setting, update the theme to always have that set to the value of `true`.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

To do so, update the `OAuth Authorize` template. This is the login page.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

Here's a sample FreeMarker block to replace the default `rememberDevice` checkbox.

```
[@hidden name="rememberDevice" value="true"/]
```

mooreds marked this conversation as resolved.
Show resolved Hide resolved
The duration of this SSO session is controlled in the tenant settings.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

### Forward Unauthenticated Users

Whenever a user accesses an application and is not logged in, forward them to the login URL for FusionAuth.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

Since your applications are already delegating authentication to FusionAuth, use the same logic to create the login URL.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

Here's a diagram of a user switching between the clownwear ecommerce store and the forum.

<ApplicationSwitchDiagram alt="An example of an application switch." />
mooreds marked this conversation as resolved.
Show resolved Hide resolved

If a user is browsing the ecommerce store, then clicks on the forum link, they will transparently be logged in to the forum application.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

Their client will get a token associated with the forum application, including the roles the user has for that application and claims such as the audience claim (`aud`) set correctly.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

## Expected Outcome

Users switch between your applications transparently and securely.

## Edge Cases

SSO login works across all apps in a tenant, including those the user isn't registered for. After bouncing to FusionAuth, the user will be authenticated, but the `applicationId` and `roles` claims will be missing from the access token. Your applications should check these claims when determining whether a user is authorized for an application. [Read more about authentication and authorization](/docs/get-started/core-concepts/authentication-authorization).
mooreds marked this conversation as resolved.
Show resolved Hide resolved

When your user logs out, destroy the SSO session as each application session. You can do that using API calls or with FusionAuth's Front-Channel logout. [Read more about logout](/docs/lifecycle/authenticate-users/logout-session-management).
mooreds marked this conversation as resolved.
Show resolved Hide resolved

Any applications that have self-service registration enabled will automatically register users for with default roles when the user is bounced to that application.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

If an application only wants to allow logins from a certain identity provider or impose other conditions, you'll need extra integration work. For example, imagine there's a time tracking app for your clownwear ecommerce store that employees log in to using Google Workspace federation. You don't want customers to be able to view this application. One way you can prevent this with a [login validation lambda](/docs/extend/code/lambdas/login-validation).
mooreds marked this conversation as resolved.
Show resolved Hide resolved

This use case only works with FusionAuth hosted login pages. If you use the Login API, you need to build your SSO. See this [GitHub issue for more details](https://github.com/fusionauth/fusionauth-issues/issues/1515).
mooreds marked this conversation as resolved.
Show resolved Hide resolved

If one application, such as the ecommerce app, requires authentication checks such as multi-factor authentication, additional self-serve required profile attributes, or registration verification, and others do not, users will be prompted when visiting the ecommerce application.
mooreds marked this conversation as resolved.
Show resolved Hide resolved

## Other Example Scenarios

Any set of applications which share customer or user accounts are a good fit for this use case.

mooreds marked this conversation as resolved.
Show resolved Hide resolved
* Multiple affiliated online games
* An office suite with an online word processor, spreadsheet and presentation software
* Travel booking software, where you might have one application for booking flights, another for hotels and a third for car rental

## Additional Documentation

* [Single sign-on guide](/docs/lifecycle/authenticate-users/single-sign-on)
* [Logout and session guide](/docs/lifecycle/authenticate-users/logout-session-management)
* [Theme customization](/docs/customize/look-and-feel/)

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Auth as a Service
description: Delegate your authentication to FusionAuth.
section: get started
subcategory: use cases
navOrder: 10
---
import LoginBefore from 'src/diagrams/quickstarts/login-before.astro';
import LoginAfter from 'src/diagrams/quickstarts/login-after.astro';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Authorization Hub
description: Integrate with third party platforms, using FusionAuth to safely store refresh tokens.
section: get started
subcategory: use cases
navOrder: 100
---
import Aside from 'src/components/Aside.astro';
import StoreRefreshTokensDiagram from 'src/diagrams/docs/get-started/use-cases/authorization-hub/store-refresh-token.astro';
Expand Down Expand Up @@ -42,7 +43,7 @@ This is an example of [the Third-Party Service Authorization Mode](/docs/lifecyc

## Prerequisites

You have configured your application or applications to delegate authentication to FusionAuth via the Authorization Code grant and the hosted login pages.
You have configured your application or applications to [delegate authentication to FusionAuth](/docs/get-started/use-cases/auth-service) via the Authorization Code grant and the hosted login pages.

You can also implement this use case without using the hosted login pages, using the FusionAuth APIs. The API you'd use is the `Complete the Login` [Identity Provider APIs](/docs/apis/identity-providers/), but that implementation is beyond the scope of this document.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
import Diagram from "src/components/mermaid/SequenceDiagram.astro";
const { alt } = Astro.props;

//language=Mermaid
const diagram = `
sequenceDiagram
participant User as Logged In User/Browser
participant Ecommerce as Ecommerce Store
mooreds marked this conversation as resolved.
Show resolved Hide resolved
participant Forum
participant FusionAuth

User ->> Ecommerce : Request Page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
User ->> Ecommerce : Request Page
User ->> E-commerce : Request Page

Ecommerce ->> User : Return Page
mooreds marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ecommerce ->> User : Return Page
E-commerce ->> User : Return Page

User ->> Ecommerce : Click On Forum Link
mooreds marked this conversation as resolved.
Show resolved Hide resolved
User ->> Forum : Request Page
Forum ->> Forum : Attempt To Verify User
Forum ->> User : Redirect To FusionAuth
User ->> FusionAuth : Request Login Page
FusionAuth ->> FusionAuth : Verify User Has Active SSO Session
FusionAuth ->> User : Return Forum Redirect URL With Authorization Code
User ->> Forum : Requests Redirect URL
Forum ->> FusionAuth : Requests Tokens
FusionAuth ->> Forum : Returns Tokens
Forum ->> Forum : Examines Tokens, Determines User Is Logged In
Forum ->> User : Returns Forum Page
`;
---
<Diagram code={diagram} alt={alt} />