Add guest user to group during signup flow with azure ad b2b - azure

Apologies if this question is too general.
I have created a signup/signin flow in Azure AD External Identities, using a Google Identity Provider , and added my application to this user flow.
The flow itself works as expected, as during signup the user is created, however after inserting the password, I get the following error :
The signed in user is not assigned to a role for the application
This error makes sense, as during signup the guest user is not added to any group nor given any roles, which it needs to access the application.
My question is, is there a way to give the necessary roles/add the user to a default group during the signup/signin flow process? Or alternatively, set a default group for all guest users that are added to the AD?
Thank you

You can use Dynamic Group Membership. If the users meet the defined rules criteria, they will be automatically assigned to the group.
Note: Premium P1 license is needed to use this feature.
Reference:
Create Group Rules to assign users to the group
OR
You can also create a Powershell script to automatically assign new users to enterprise application.
Reference:
Add User To Azure AD Application Powershell

Related

Azure AD App Registration with multi-customer access

Hello friends and thank you for taking the time to read my question and for all potential answers.
I am building a customer application which allows several proprietors (business owners) to log-in and manage their business. I don't want to focus on the details of the app as it is not relevant (I think) because this is more of a qualitative question.
I am using Azure AD (App Registrations) for both the Blazor WASM and API. I am comfortable creating and utilizing those. What I am trying to understand is how to not allow customers to see each other's data by using purely just Azure AD.
Example:
Customer User A from business X logs into the app. They are redirected to myapp.com/Business-X
The Roles I have right now in Azure AD are User.Read, User.ReadWrite and User.Admin
Customer User B from business Y logs into the app and is redirected to myapp.com/Business-Y
Nothing is preventing User A from changing their URL to myapp.com/Business-Y and have the same role in another business' app. I understand that I can change my Roles in Azure AD to be User.Read.X, User.ReadWrite.X, User.Admin.X, User.Read.Y, User.ReadWrite.Y, User.Admin.Y etc. but imagine if I have hundreds of customer's let's say, that is unmanageable and my blazor code will just be a mess.
Is there a better/smarter way to do this? For example I can keep the current simplified roles and add users to a database where I map them to the business they have access to but is that secure? I suspect using a database to store this does not sound right because it feels that Azure AD can do this and I just don't know how.
Thank you again!
• Yes, you can surely do restrict the users access to a particular application registered in Azure AD by ensuring these applications are also registered as ‘Enterprise Applications’ in Azure AD. Once, these applications are shown up in ‘Enterprise Applications’ in Azure AD, then you can configure them to require assignment for a particular set of users only by ensuring that the required users only have access to that application. To enable user assignment and assign users for that application in Azure AD, you should have ‘Global Administrator, Application Administrator or Cloud Administrator’ directory roles assigned to your ID.
Please find the snapshots below for more information in this regard: -
Also, once you have configured the above, you should ensure to create a custom role at the directory-level and assign it the required permissions as then this role would be assigned to all the users and these users then individually can be assigned to the required application, thus ensuring that only specific users are allowed to access the assigned app.
Please note that tenant wide admin consent is granted to apps that would require assignment. Kindly refer to the below link for more information: -
https://learn.microsoft.com/en-us/azure/active-directory/develop/howto-restrict-your-app-to-a-set-of-users#update-the-app-to-require-user-assignment

Automate group creation and memberships in Azure B2C

Is it possible using Graph API or similar to automatically add users to a security group in Azure B2C?
The background is that during an Azure B2C user journey for signup/sign the user will access an application after successful authentication. But I would like to role assign based on the security group the user is a member of.
Therefore if a new user signs up, they could be defaulted to lets say "DefaultUsersGroup" and this will be present in their token thus giving them default access to the app. Otherwise if an existing user signs in, this will perform some logic to determine the group the user should be a member of and then grant them access dependant on their membership.
Thank you.
You can do this by introducing your own REST API/s during your user journey. Your API should then call MS Graph API to do the Group+Role assignment, and on sign in, the Role resolution based on group membership.
https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-rest-api-claims-exchange
This sample may also help
https://github.com/azure-ad-b2c/samples/tree/master/policies/relying-party-rbac

Azure AD Access

I just started working with Azure Active directory and i have one simple query.
I have a customer who is the admin of azure subscription and now if he wants to give access to another user who will be tasked to Create and Managing of Azure Active Directory (Like adding/deleting users, providing access to other application) what level of Role/permission needs to be assigned to this user.
Please let me know the steps for doing this from portal or any reference link please share
For just user management an "User Administrator" role would be sufficient. As far as the applications go it may vary depending on the level of access required and so on.
Check out the Azure AD roles here.
But at the subscription level it is better that the user has an "owner" role which provides all the administrative privileges.

User and organization management in Azure AD and Azure B2C

After a lot of research I am still confused about using Azure AD. Here is what I want to achieve.
We maintain users in following order in SQL Server
Organization
Team
User
There can be multiple organizations and a user can be belong to multiple organizations but his/her role will be different like Agent or Team leader or Team manager.
I want to move away from this structure and create the same in Azure AD and authenticate users via Identity provider. How to maintain same sort of structure in Azure AD?
I am looking for an solution with minimal code changes. Any thoughts on this??
You can use Groups in AAD to achieve something similar.
Currently, the following scenarios DO support nested groups:
The concept (you can add groups as members of other groups)
Group membership claims (when an app is configured to receive group membership claims in the token, nested groups the signed-in user is a member of are included)
Conditional access (when scoping a conditional access policy to a group)
Restricting access to self-serve password reset
Restricting which users can do Azure AD Join and device registration
The following scenarios DO NOT supported nested groups:
App role assignment (assigning groups to an app is supported, but groups nested within the directly assigned group will not have access), both for access and for provisioning
Group-based licensing (assigning a license automatically to all members of a group)
Office 365 Groups
See the product feedback page and add your suggestions if you need something more complex than what AAD currently supports.

Azure Active Directory - Assign to group

Is it possible to assign an application (as an Application or Service Principal) to a group programatically, via the graph client or API? (Including the app user credentials needed to allow access of the members of the group to the app)
I searched everywhere and couldn't find documentation for it.
Thanks
No, 'Applications' in Azure AD are used to segment authorization and settings within Azure AD. It creates a trust between Azure AD and your application. The Application is not a User.
Users are Azure AD entities that have identity and can be authorized to access resources (like an Application). Users can be added to groups. See the below link for the Azure AD graph API documentation:
https://msdn.microsoft.com/Library/Azure/Ad/Graph/api/groups-operations#AddGroupMembers
And the documentation on what a user entity looks like:
https://msdn.microsoft.com/Library/Azure/Ad/Graph/api/entity-and-complex-type-reference#UserEntity
Thanks for the answer emseetea, but we do have a little more than that.
Back to the original question - can you programmatically "assign a group to an application". The answer is yes, using appRoleAssignments on the service principal. The service principal represents an application instance, that typically gets provisioned as part of a consent grant. On this tenant specific app instance (service principal) you can attach tenant specific permissions and policy. Permissions get created as part of consent, but you can also programmatically assign an application role (defined by the application) to a user or group. If no application role is assigned, then you can make a "default" assignment. You can find a little more on this topic here http://blogs.msdn.com/b/aadgraphteam/archive/2014/12/12/announcing-the-new-version-of-graph-api-api-version-1-5.aspx which describes a little about this with some sample REST API calls.
This same operation is also possible through the client library. You can take a look at https://github.com/Azure-Samples/active-directory-dotnet-graphapi-console. Look at the section titled "#region Assign Direct Permission". This shows how to assign an app role to a user. You can do the same thing on a group too. If your app doesn't specify any app roles, set the appRoleAssignment.Id to a zero GUID.
Hope this helps,

Resources