Skip to content

Commit c2a5303

Browse files
authored
docs: add guide on how to build a multi-application dashboard/portal (#3398)
1 parent 1bda1e5 commit c2a5303

File tree

7 files changed

+132
-2
lines changed

7 files changed

+132
-2
lines changed
428 KB
Loading
489 KB
Loading
40.1 KB
Loading
41.9 KB
Loading
43.8 KB
Loading
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: Multi-Application Dashboard
3+
description: Create a dashboard page with a list of applications a user can log in to.
4+
navcategory: developer
5+
section: extend
6+
subcategory: examples
7+
---
8+
9+
import Aside from 'src/components/Aside.astro';
10+
import Breadcrumb from 'src/components/Breadcrumb.astro';
11+
import IconButton from 'src/components/icon/Icon.astro';
12+
import InlineUIElement from 'src/components/InlineUIElement.astro';
13+
import {RemoteCode} from '@fusionauth/astro-components';
14+
15+
## Overview
16+
17+
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.
18+
19+
![Google app selector](/img/docs/extend/examples/multi-application-dashboard/googleGrid.png)
20+
21+
In this guide, you'll learn to make a similar page — a dashboard linking to all the applications in a FusionAuth tenant.
22+
23+
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 IdP-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 implications.
24+
25+
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 onward, authentication follows the standard OAuth Authorization Code grant.
26+
27+
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 applications. If you already have a FusionAuth installation with existing applications, you can skip ahead to [the section that creates the dashboard](#make-a-dashboard).
28+
29+
If you want to follow along with the full guide, you will need Docker installed.
30+
31+
## Download The Example Repository And Run FusionAuth
32+
33+
Use `git clone` to clone the repository at https://github.com/fusionauth/fusionauth-example-multiapp-dashboard, or download and unzip it.
34+
35+
Open a terminal in the directory containing the repository files.
36+
37+
Run the command below to start FusionAuth.
38+
39+
```sh
40+
docker compose up
41+
```
42+
43+
<Aside type="note">
44+
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.
45+
46+
```sh
47+
docker ps rm fa faDb; docker compose down -v
48+
```
49+
</Aside>
50+
51+
Leave FusionAuth running.
52+
53+
In a new terminal, run the commands below to start a web server for the Changebank app, which uses FusionAuth for authentication.
54+
55+
```sh
56+
cd bankApp
57+
docker compose up
58+
```
59+
60+
The Changebank app is now running at http://localhost:3000.
61+
62+
In a third terminal, run the commands below to start a web server for a second app that uses FusionAuth for authentication.
63+
64+
```sh
65+
cd insuranceApp
66+
docker compose up
67+
```
68+
69+
The app is called Changeinsurance, and is now running at http://localhost:3001.
70+
71+
Before making the dashboard, check that you can log in to all three applications. Either use an incognito browser window or don't enable <InlineUIElement>[Keep me signed in](/docs/lifecycle/authenticate-users/logout-session-management#fusionauth-sso)</InlineUIElement> when logging in, otherwise, you won't see the login form in the rest of this guide:
72+
- Browse to FusionAuth at http://localhost:9011/admin and log in with `[email protected]` and `password`.
73+
![FusionAuth](/img/docs/extend/examples/multi-application-dashboard/fa.png)
74+
- Browse to Changebank at http://localhost:3000 and log in with the same username and password.
75+
![Changebank](/img/docs/extend/examples/multi-application-dashboard/changebank.png)
76+
- Browse to Changeinsurance at http://localhost:3001 and log in with the same username and password.
77+
![Changeinsurance](/img/docs/extend/examples/multi-application-dashboard/changeinsurance.png)
78+
79+
If you enabled <InlineUIElement>Keep me signed in</InlineUIElement>, logging out of an application won't necessarily 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.
80+
81+
## Make A Dashboard
82+
83+
Now that you have applications up and running, let's build the dashboard.
84+
85+
Look at the current FusionAuth landing page at http://localhost:9011.
86+
87+
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.
88+
89+
Log in to your [FusionAuth web interface](http://localhost:9011/admin) and browse to <Breadcrumb>Customizations -> Themes</Breadcrumb>.
90+
91+
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 when you started FusionAuth up. Read about Kickstart [here](/docs/get-started/download-and-install/development/kickstart).
92+
93+
- Click the <IconButton name="edit" /> edit button in the Bank theme row's action column.
94+
- Select the <InlineUIElement>Index</InlineUIElement> page (fourth item in the list on the left).
95+
- Paste the code below into the text box.
96+
97+
<RemoteCode lang="html" url="https://raw.githubusercontent.com/fusionauth/fusionauth-example-multiapp-dashboard/refs/heads/main/theme/index.ftl" />
98+
99+
- Click the <IconButton name="save" /> save button at the top right.
100+
101+
Besides a little CSS for styling, the code above only adds links for the two applications. 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 while still protecting the application content.
102+
103+
To see the new landing page, browse to http://localhost:9011.
104+
![FusionAuth app dashboard](/img/docs/extend/examples/multi-application-dashboard/dashboard.png)
105+
106+
You can extend this to any number of applications, just like Google does.
107+
108+
### Partial Access
109+
110+
You can require application registration for users before access is allowed. Do so by first disabling the self-service registration setting under the <Breadcrumb>Registration</Breadcrumb> tab and enabling the <InlineUIElement>Require registration</InlineUIElement> setting in the <Breadcrumb>OAuth</Breadcrumb> tab of the application.
111+
112+
When this is configured, a user who is not registered to the Changebank or Changeinsurance application will not be able to access it, even though they can click on the link. They simply won't be logged in.
113+
114+
## Clean Up
115+
116+
To stop the running containers run the command below.
117+
118+
```sh
119+
docker compose down -v
120+
```
121+
122+
## Next Steps
123+
124+
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).

astro/src/content/json/exampleapps.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,16 +599,22 @@
599599
"description": "Node.js Express sample application for the Modeling Organizations guide.",
600600
"language": "javascript"
601601
},
602+
{
603+
"url": "https://github.com/FusionAuth/fusionauth-example-multiapp-dashboard",
604+
"name": "Multi-Application Dashboard",
605+
"description": "Node.js Express sample applications for the Multi-Application Dashboard guide.",
606+
"language": "javascript"
607+
},
602608
{
603609
"url": "https://github.com/fusionauth/fusionauth-example-terraform-deploy-fusionauth",
604610
"name": "Start Here Tutorial App",
605-
"description": "An express/JavaScript application used for a walkthrough of a FusionAuth setup",
611+
"description": "Use Terraform to deploy FusionAuth and its database.",
606612
"language": "config"
607613
},
608614
{
609615
"url": "https://github.com/FusionAuth/fusionauth-example-express-start-here",
610616
"name": "Start Here Tutorial App",
611-
"description": "Use Terraform to deploy FusionAuth and its database.",
617+
"description": "An express/JavaScript application used for a walkthrough of a FusionAuth setup",
612618
"language": "javascript"
613619
}
614620
]

0 commit comments

Comments
 (0)