Skip to content

docs: add guide on how to build a multi-application dashboard/portal #3398

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

Merged
merged 34 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c0f57b5
starting dashboard article
Nov 11, 2024
ae98149
save
Nov 11, 2024
2b5cd99
save
Nov 11, 2024
557f3ee
make dashboard page in fa
Nov 12, 2024
d5c6038
introduction done
Nov 12, 2024
395a55c
save
Nov 12, 2024
9582e60
article complete
Nov 12, 2024
f19c2b5
edit
Nov 13, 2024
b86f066
text updates
rideam Nov 18, 2024
35911fd
add linux platform to docker command
Nov 18, 2024
d83db5b
Merge branch 'multiapplicationDashboard' into qa-multiapplicationDash…
rideam Nov 18, 2024
0faffa6
image updates
rideam Nov 18, 2024
37845fb
text updates
rideam Nov 18, 2024
f9d811d
text updates
rideam Nov 18, 2024
7c76cf0
Merge pull request #229 from ritza-co/qa-multiapplicationDashboard
rideam Nov 18, 2024
0d69470
text updates
rideam Nov 18, 2024
17b2e16
Edit: Multi-Application Dashboard
worktheclock Nov 21, 2024
cfbcbb5
Merge pull request #234 from ritza-co/edit-multi-application-dashboard
sixhobbits Nov 21, 2024
87a1af7
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Jan 31, 2025
20e9d1a
remove space
sixhobbits Feb 12, 2025
da836d1
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Feb 13, 2025
fe33852
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Feb 13, 2025
5b7948d
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Feb 13, 2025
b7fc2e1
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Feb 13, 2025
cd8aeb2
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Feb 13, 2025
6f93f19
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Feb 13, 2025
0d32ede
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Feb 13, 2025
8aa32e1
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Feb 13, 2025
c5064c2
Update astro/src/content/docs/extend/examples/multi-application-dashb…
sixhobbits Feb 13, 2025
1f5daca
Apply suggestions from code review
rideam Feb 13, 2025
341027c
feedback
rideam Feb 13, 2025
a5dc280
feedback
rideam Feb 13, 2025
7f10f57
feedback
rideam Feb 13, 2025
d691010
Merge branch 'main' into multiapplicationDashboard
rideam Feb 13, 2025
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
---
title: Multi-Application Dashboard
description: Create a dashboard page with a list of applications a user can log in to.
navcategory: developer
section: extend
subcategory: examples
---

import Aside from 'src/components/Aside.astro';
import Breadcrumb from 'src/components/Breadcrumb.astro';
import IconButton from 'src/components/icon/Icon.astro';
import InlineUIElement from 'src/components/InlineUIElement.astro';

## Overview

If you're using FusionAuth to manage many applications, you might want to provide your users with a central list of applications, so they know what's available. For example, Google does this for its apps.

![Google app selector](/img/docs/extend/examples/multi-application-dashboard/googleGrid.png)

In this guide, you'll learn to make a similar page — a dashboard linking to all the applications in a FusionAuth tenant.

In the language of authentication, FusionAuth is an identity provider (IdP) and your applications and websites are the service providers (SPs). One way to authenticate a user from a central dashboard is to use an identity-provider-initiated login. In other words, the dashboard will log the user in, and then redirect them to the selected app. In short, a service provider application will receive a login that it didn't initiate itself. This has security complexities and dangers.

This guide will demonstrate a simpler and safer way to authenticate users from a central dashboard by making each application link in the dashboard point to the application's login page. From that point onwards, authentication follows the standard OAuth Authorization Code Flow.

Check failure on line 24 in astro/src/content/docs/extend/examples/multi-application-dashboard.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'onwards'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'onwards'?", "location": {"path": "astro/src/content/docs/extend/examples/multi-application-dashboard.mdx", "range": {"start": {"line": 24, "column": 204}}}, "severity": "ERROR"}

The next section of this guide will show you how to make a dashboard for two existing FusionAuth applications in the same tenant. All this requires is customizing the theme for the index landing page of the FusionAuth site. The guide will first show you how to install FusionAuth and make two simple web application web servers. If you already have a FusionAuth installation with existing applications, you can skip ahead to the section that creates the dashboard.

If you want to follow along with the full guide, you will need Docker installed.

## Download The Example Repository And Run FusionAuth

Use `git clone` to clone the repository at https://github.com/fusionauth/fusionauth-example-multiapp-dashboard, or download and unzip it.
Copy link
Contributor

Choose a reason for hiding this comment

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

This repo doesn't exist?

Copy link
Contributor

Choose a reason for hiding this comment

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

When it does get moved over, we should add it to exampleapps.json as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the repo https://github.com/ritza-co/fusionauth-example-multiapp-dashboard

We have added it to exampleapps, assuming you keep the same name when moving it to your org

Copy link
Contributor

Choose a reason for hiding this comment

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


Open a terminal in the directory containing the repository files.

Run the command below to start FusionAuth.

```sh
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need spaces prepended, do we?

docker compose up
```

<Aside type="note">
If you have completed any FusionAuth tutorials before, you might need to first delete any existing FusionAuth containers with the same name and the database volumes. Run the command below to do that.

```sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about spacing in front of the triple backticks.

docker ps rm fa faDb; docker compose down -v
```
</Aside>

Leave FusionAuth running.

In a new terminal, run the commands below to start a web server for the Changebank app, which uses FusionAuth for authentication.

```sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing with the spaces in front of the backticks.

cd bankApp
docker run --platform=linux/amd64 --rm -v ".:/app" -w "/app" node:23-alpine3.19 sh -c "npm install"
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work on an ARM based chip, I'm guessing. What have you done in the past? can you create a docker compose file for these applications that is cross platform?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it should usually 'just work' through emulation I think (we've tested this on x64 and M1 machines), but yes in general we struggle a bit with figuring out how to do this nicely as we often see little niggles on different platforms with Docker.

That image is available on all platforms, so maybe we should just add a note at this point advising the reader to match their platform if they have issues?

docker run --platform=linux/amd64 --rm --network faNetwork -p 3000:3000 -v ".:/app" -w "/app" -e "PORT=3000" node:23-alpine3.19 sh -c "npm run start"
```

The Changebank app is available at http://localhost:3000.

To learn how to make a simple Node.js app that uses FusionAuth, read the [quickstart](/docs/quickstarts/quickstart-javascript-express-web).

In a third terminal, run the commands below to start a web server for a second app that uses FusionAuth for authentication. The app is called Changeinsurance, and is available at http://localhost:3001.

```sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing with the spaces in front of the backticks.

cd insuranceApp
docker run --platform=linux/amd64 --rm -v ".:/app" -w "/app" node:23-alpine3.19 sh -c "npm install"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comments about docker run.

docker run --platform=linux/amd64 --rm --network faNetwork -p 3001:3001 -v ".:/app" -w "/app" -e "PORT=3001" node:23-alpine3.19 sh -c "npm run start"
```

Before making the dashboard, check that you can log in to all three applications. Either use an incognito browser window or don't enable [Keep me signed in](/docs/lifecycle/authenticate-users/logout-session-management#fusionauth-sso) when logging in, otherwise, you won't see the login form in the rest of this guide:
- Browse to FusionAuth at http://localhost:9011/admin and log in with `[email protected]` and `password`.
![FusionAuth](/img/docs/extend/examples/multi-application-dashboard/fa.png)
- Browse to Changebank at http://localhost:3000 and log in with the same username and password.
![Changebank](/img/docs/extend/examples/multi-application-dashboard/changebank.png)
- Browse to Changeinsurance at http://localhost:3001 and log in with the same username and password.
![Changeinsurance](/img/docs/extend/examples/multi-application-dashboard/changeinsurance.png)

If you enabled <InlineUIElement>Keep me signed in</InlineUIElement>, logging out of an application won't log you out of FusionAuth. It will only delete the session of the application. Next time you try to log in, FusionAuth will see the FusionAuth authentication cookie in your browser and automatically log you in.

## Make A Dashboard

Look at the current FusionAuth landing page at http://localhost:9011.

In this section, you will change the FusionAuth landing page to display links to the two banking app web servers you started in the previous section.

Log in to your [FusionAuth web interface](http://localhost:9011/admin) and browse to <Breadcrumb>Customizations -> Themes</Breadcrumb>.

Notice there are three themes in the list. The first two are the default FusionAuth themes. The last one, <InlineUIElement>Bank theme</InlineUIElement>, was added by `kickstart.json` when you ran Docker compose. Read about Kickstart [here](/docs/get-started/download-and-install/development/kickstart).

- Click the <IconButton name="edit" /> edit button in the Bank theme row's action column.
- Select the <InlineUIElement>Index</InlineUIElement> page (fourth item in the list on the left).
- Paste the code below into the text box.
```html
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be remote code pulled from a github repo, not inline FTL.

[#ftl/]
[#-- @ftlvariable name="tenant" type="io.fusionauth.domain.Tenant" --]
[#-- @ftlvariable name="tenantId" type="java.util.UUID" --]
[#-- @ftlvariable name="theme" type="io.fusionauth.domain.Theme" --]
[#import "_helpers.ftl" as helpers/]

[@helpers.html]
[@helpers.head title="FusionAuth"/]
[@helpers.body]
[@helpers.header]
[#-- Custom header code goes here --]
[/@helpers.header]

[#if theme.type != "simple"]
[@helpers.main title="" rowClass="row center-xs" colClass="col-xs-12 col-sm-12 col-md-10 col-lg-10 col-xl-9"]
<div class="p-3 pb-5">
<div style="width: 180px;">
<img src="/images/logo-gray.svg">
</div>
<br />
<a href="http://localhost:3000/account" style="background: linear-gradient(to bottom right, palegreen, forestgreen);
color: white;
padding: 10px;
margin: 20px;
border-radius: 5px;
text-align: center;
width: 160px;
display: inline-block;
text-decoration: none;">
Changebank
</a>
<a href="http://localhost:3001/account" style="background: linear-gradient(to bottom right, skyblue, navy);
color: white;
padding: 10px;
margin: 20px;
border-radius: 5px;
text-align: center;
width: 160px;
display: inline-block;
text-decoration: none;">
Changeinsurance
</a>
</div>
[/@helpers.main]
[/#if]

[@helpers.footer]
[#-- Custom footer code goes here --]
[/@helpers.footer]
[/@helpers.body]
[/@helpers.html]
```
- Click the <IconButton name="save" /> save button at the top right.

Besides a little CSS for styling, the code above has only two changes: Adding hyperlink `<a href="http://localhost:3000/account">Changebank</a>` elements for the two applications. Note that the links don't point to the login page of the target application. Instead, they point to the logged-in main page. If the user isn't logged in to FusionAuth, they will be automatically redirected to the app's login page. If they are already logged in, they will be taken straight to the app. This saves the user time. (To see how this authentication check in the app works, look at `bankApp/routes/index.js` in the sample repository you downloaded.)

To see the new landing page, browse to http://localhost:9011.
![FusionAuth app dashboard](/img/docs/extend/examples/multi-application-dashboard/dashboard.png)

## Clean Up

To remove all the Docker images used in this guide, stop the running containers and run the commands below.

```sh
docker compose down -v
docker rmi postgres:16.0-bookworm fusionauth/fusionauth-app:1.51.2 node:23-alpine3.19
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to delete the images.

```

## Next Steps

To make a dashboard for your FusionAuth instance, all you need to do is make links in a custom theme for the FusionAuth landing page similar to the ones shown above. [FusionAuth themes](/docs/customize/look-and-feel/) use a template language called FTL. Read more about it [here](https://freemarker.apache.org/index.html).
Loading