We're building a system that exposes APIs, subsets of which are accessible to different user types:
organization administrator
users can access relevant admin APIs that give them full access to their data. They are identified via email and a password that they control.device registrar
users can access certain APIs that should only be accessible to tablets deployed on-site at organizations. They are identified via an email and password that we control. There is a one-time setup process that the organization goes through to register a device, and it involves logging on with thedevice registrar
account and providing some additional metadata. From there, the device caches the OAuth token and automatically renews it using the refresh token.visitor
users can access APIs that are needed by the end consumer (i.e. the general public), but they must first provide - and prove access to - a mobile number. In other words, they provide a phone number and a OTP will prove they have access to that phone.
We are building this on top of IdentityServer4 using ASP.NET Core and Firestore. We already have IS4 integrated with Firestore and can already authenticate/authorize organization administrators. Each such user in our Firestore database looks like this:
Notice that we just store a set of claims for each user, and in this case it's just an organization ID that the user is an administrator for.
What I'm struggling with a bit is understanding how best to model our other use cases: registered devices and visitors. On the one hand it feels like I could simply use claims to distinguish the different cases; something like this:
- an
orgid
claim means that user is an organization administrator - a
regordid
claim means that user is able to register a device - a
phone
claim means that user is a visitor
But on the other hand, this feels a little fragile to me. What if, for example, we wanted both organization administrator
users and device registrar
users to have the orgid
claim? After all, that makes sense because device registrar
users are still tied to a specific organization.
On the other hand, is it "normal" to solve this by having some kind of "user type" claim?
Can anyone offer any design tips here?