Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What use are 'Scopes' in Azure B2C Authentication?

Tags:

azure-ad-b2c

I don't understand how the 'Scopes' in Azure B2C are supposed to be used. They are associated with an API, but not a user. I'm sure I'm missing something, but I see no practical use for something associated with an API. I've used and implemented Claims-based authentication based on a user's role in the database.

For example: ordinary users of an API should not have the authority to delete an object, but administrators should have the authority. Does someone have a practical example of how these B2C 'Scopes' can be used to limit a users access to the API?

like image 481
Quarkly Avatar asked Apr 15 '18 20:04

Quarkly


People also ask

What is scope for Azure B2C?

A scope is something the mobile application requests from the Azure AD B2C application as part of the authorization process. And it is a permission to the Azure AD B2C application. But it's not a user-level permission.

What are scopes in Azure?

A scope is a node in the Azure resource hierarchy where Azure AD users access and manage services. Most Azure resources are created and deployed into resource groups, which are part of subscriptions.

What role does the .default scope serve?

default scope offers an easier migration path, as the developer gets the same behavior from the v2 endpoint keeping the experience consistent.

What are scopes in Msal?

Scope Functions The main function of the scopes configuration, per the OAuth 2.0 Access Token Scope Reference, is to determine the permissions for which an application requests authorization on behalf of the user. Said function is both supported and covered by [email protected] and the Microsoft identity platform in general.


2 Answers

They are associated with an API, but not a user.

That is correct. I like to think of the association to the API as defining the 'surface area' of the API. For example, this API defines 2 scopes

  • read
  • write

Now, you could define two applications. One application that only has read permissions and one that has read and write permissions.

For the common use case of one Web App and one Web API it adds no value. I've been using a scope of no-op for such cases.


I've used and implemented Claims-based authentication based on a user's role in the database

You can use custom attributes to assign "role(s)" to the user. You can set them via the Azure AD Graph API to keep the setting of them secure. You can also set them during sign-up (this is much more involved though).

When you request an access token for that user, the custom attirbute(s) you defined and set will be readable in the API to check permission(s).


Comment Feedback

If I promote or demote a user, I need to change the endpoints (policies) they access at the client.

No need to change the policies. You would update the custom attribute for that user via the Azure AD Graph API.

My problem is that I'm mystified at the an authentication system that authorizes endpoints ("scopes") instead of users

Yeah, me too! I think it might have to do w/ the purpose of the product. B2C is about self-service sign-up, password reset and federating w/ other IDPs (like FB, Google, etc). Maybe Azure AD is a better solution when you want to control permissions on a user. Not sure, still learning!

I still don't see the practicality of splitting your API into several different parts based on the security. An API should be a collection of functionally related services

You don't split your API. You can split your app(s) that utilize the API. See above.


Documentation Reference: Requesting access tokens, GitHub Issue to improve the documentation.

like image 68
spottedmahn Avatar answered Oct 14 '22 02:10

spottedmahn


Roles and scopes provide the two halves for this user access control.

Roles -- such as Administrator, Member, and Guest -- determine whether an authenticated user is permitted to delete objects.

Scopes -- such as read, write, and delete -- determine whether an authorized application can delete objects on behalf of an authorizing/consenting user if this user, through their role assignment/s, is permitted to do so.

Azure AD B2C doesn't have any current support for managing roles and assignments of them to users.

It does, however, have support for managing scopes and assignments of them to applications.

like image 28
Chris Padgett Avatar answered Oct 14 '22 03:10

Chris Padgett