Skip to content

Commit bde386d

Browse files
authored
Merge pull request #1421 from FusionAuth/segmenting-users
Segmenting users
2 parents bda1141 + 6226d44 commit bde386d

File tree

1 file changed

+123
-1
lines changed

1 file changed

+123
-1
lines changed

site/docs/v1/tech/core-concepts/users.adoc

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The User itself is easy enough to understand, it represents your end user, your
1616
* <<User Sessions>>
1717
* <<What Makes a User Active>>
1818
* <<User Search>>
19+
* <<Segmenting Users>>
1920

2021
Here's a brief video covering some aspects of users:
2122

@@ -32,7 +33,7 @@ Users have sessions in FusionAuth. Sessions are equivalent to refresh tokens. Th
3233

3334
These appear in the administrative user interface under the [breadcrumb]#Sessions# tab (you may need to scroll if your screen is small):
3435

35-
image::core-concepts/user-session.png[User session screen in the adminstrative user interface.,width=1200,role=bottom-cropped]
36+
image::core-concepts/user-session.png[User session screen in the administrative user interface.,width=1200,role=bottom-cropped]
3637

3738
There are two primary types of sessions/tokens shown in this table:
3839

@@ -140,3 +141,124 @@ The following screenshot shows an Elasticsearch JSON query being constructed to
140141
image::core-concepts/user-search-json-query.png[User Search with JSON Query.,width=1200]
141142

142143
To learn more about the Elasticsearch search engine in general, view the link:/docs/v1/tech/core-concepts/search[search core concepts section].
144+
145+
== Segmenting Users
146+
147+
Often you want to segment or separate your users.
148+
You have four options to do so in FusionAuth.
149+
They each have different tradeoffs.
150+
The options are:
151+
152+
* Tenants
153+
* Applications and Registrations
154+
* Groups
155+
* Entities and Grants
156+
157+
//TODO table?
158+
159+
=== Tenants
160+
161+
Each FusionAuth tenant is a logical grouping of users, configuration and applications.
162+
Users are tenant scoped.
163+
This means a user with the same identifier (email, username, etc) in two different tenants is a different user.
164+
They can have different passwords, different identity provider links and different attributes.
165+
You can search for users across tenants using the User Search API.
166+
167+
An example use case is a private label todo SaaS application, where you want a user to sign up for two or more different instances of your SaaS and not know that there is a shared identity store behind them.
168+
For example, richard@piedpiper.com can sign up for the Pied Piper Todo application and the Hooli Todo Application with the same email address, but different passwords, MFA methods and more.
169+
170+
One issue is that if you have admin users, such as customer support representatives, which need cross-tenant access, you can't keep their accounts in sync.
171+
One option is to set up an administrative identity server, whether that is a second instance of FusionAuth, Google GSuite, or Azure AD.
172+
Have the customer service representatives authenticate with it.
173+
174+
Learn more about link:/docs/v1/tech/core-concepts/tenants[Tenants].
175+
176+
=== Applications and Registrations
177+
178+
Applications in FusionAuth represent something you can log in to.
179+
They are tenant scoped.
180+
You associate a user with an application via a registration.
181+
You may also optionally associate one or more roles with each user's registration.
182+
183+
An example use case is a single company, where you have a forum, a todo application and an accounting application.
184+
If you have three users, Richard, Monica and Jared, you can grant Richard access to all three applications, Monica access to the forum and todo applications, and Jared access to the accounting application.
185+
186+
Prohibit a user from logging into an application for which they are not registered by checking the claims in the token or enabling the [field]#Require registration# setting for the application.
187+
188+
Applications also may have associated Identity Providers, such as Google or OIDC providers.
189+
When so configured, a user may log in to an application with the Identity Provider.
190+
191+
Every user object contains an array of application registrations.
192+
You can search for all users with a given registration.
193+
194+
Learn more about link:/docs/v1/tech/core-concepts/applications[Applications].
195+
196+
=== Groups
197+
198+
Groups are a way to group users in FusionAuth.
199+
They are tenant scoped.
200+
They may have application roles associated with them.
201+
Users with a registration for an application as well as a group membership will assume those roles upon login.
202+
203+
Group membership is boolean in nature.
204+
A user is either in a group or out of a group.
205+
206+
An example use case is a forum moderators group.
207+
The forum application can get the group memberships of any user.
208+
If the user is a member of the moderators group, the application can provide a 'flag' button on the forum software.
209+
210+
Every user object contains an array of group memberships.
211+
You can search for all users with a given group memberships.
212+
213+
One issue is that to get the group names of memberships for a user, you must use FusionAuth's proprietary APIs.
214+
Group names are not included in the user object.
215+
216+
Learn more about link:/docs/v1/tech/core-concepts/groups[Groups].
217+
218+
=== Entities and Grants
219+
220+
Entities and grants allow you to model fine grained permissions in a flexible manner.
221+
Entities are things, while grants are expressions of permissions granted to a user or thing to another thing.
222+
Entities have configurable permissions.
223+
Entities are a good fit when you have users that may need access to different assets which can't be easily modeled as applications.
224+
225+
An example use case which could be modeled using entities is GitHub organizations.
226+
A user can belong to zero or more GitHub organizations and have different access levels in each one.
227+
But a user logs in to GitHub, not to a GitHub organization.
228+
Additionally, permissions will vary between organizations.
229+
A user may be an admin in one GitHub organization and have read-only access in another one.
230+
To implement this, you'd represent each GitHub organization as an entity in FusionAuth, and grant users permissions to each organization of which they are a member.
231+
232+
It is very common to have an interstitial page when using entities.
233+
(This page is custom built and is not provided by FusionAuth.)
234+
The user logs in to an application, and is then presented with a list of entities to which they've been granted permissions.
235+
The user selects an entity and then acts within the confines of that entity.
236+
237+
You can search for all users granted access to a given entity.
238+
You can search for all entities for which a user has a grant.
239+
240+
One issue is that to search for grants on a user, you must use FusionAuth's proprietary APIs.
241+
Additionally, since entities cannot be 'logged into', they don't have any relationship with external Identity Providers.
242+
243+
Learn more about link:/docs/v1/tech/core-concepts/entity-management[Entities and Grants].
244+
245+
==== Entities Compared to Applications
246+
247+
Entities, grants and permissions are analogous to applications, registrations and roles, but you can't log into an entity.
248+
249+
Entities may also be useful if you have two or more applications in FusionAuth, but you want to group access in an orthogonal way while still allowing users to assume different roles.
250+
251+
Suppose you have a point of sales application and a scheduling application for your retail chain.
252+
You have ten stores.
253+
You want to allow employees to log in to each of these applications, but you want to limit them to access only stores where they are currently working.
254+
But if they move between stores to cover for a shift or because of a transfer, you want to handle that use case as well.
255+
This means you can't use tenants to model stores.
256+
257+
You could model the point of sales and scheduling applications as applications.
258+
Each store would be an entity, and after the user has logged into an application, you'd show them the stores to which they'd have access.
259+
260+
You could also provide different roles in different stores.
261+
The scheduling software could know that Richard would have access to the scheduling application as a manager for store A but only as an employee for store B.
262+
263+
If you were to model this using only applications, you'd have to have twenty applications in FusionAuth (two for each store) and keeping those configurations synchronized might be difficult.
264+
And if you added more applications or stores, you'd face a combinatorial explosion of applications.

0 commit comments

Comments
 (0)