Authenticate users with Office365 in MVC aplication - c#

I am developing MVC based web application and want to authenticate every users with their own Office365 account. Once signed in successfully, it should provide the details of that user. The users are not specific to my organization only, they can be from any organization.
I have tried below link to achieve the same.
http://graph.microsoft.io/en-us/docs/platform/aspnetmvc
The above link has a very first step to register the application in the azure active directory, but if i will do that then it will only authenticate users from my organization. But in my case, every user has to be authenticated by their own organization.
So i want to know that is it possible? If yes, then how do i achieve that?

Registering you application in your Azure Active Directory does not preclude you from authenticating external users.
With OAUTH you have 3 actors; the Application, the Provider and the User. Each of these actors needs to trust the others. The connection between the Provider and the User is the User Account (i.e. User ID). The connection between the Provider and the Application is the Application Account (i.e. App ID).
When you register your application in Azure Active Directory you are simply establishing an Application ID. The only requirement for the User account is that it also lives within an Azure Active Directory. This does not however have to be the same AAD.
If this is a public facing website, you may want to use the newer v2 endpoint instead. Under the covers it is very similar to the workflow you've been looking at but the registration and permissions process is far more straightforward.

Yes, it is possible you need to enable multi-tenancy on your app. On the app configuration page in the Windows Azure Portal you will find the toggle for "Application is Multi-tenant". For more information about multi-tenant apps: https://azure.microsoft.com/en-us/documentation/articles/active-directory-authentication-scenarios/#application-types-and-scenarios

Related

How to use Azure Ad multitenant for Sass Application

We want to build a Sass application. We separated individual servers/instances and DB for every customer.
Our sass model:
As part of our app, we want to use Azure Ad (Multitenant) for Identity management. We have a few cases:
Our few customers don't have organizational email then how can we manage them in Azure ad (they have maybe Gmail)
We decided to set application-level roles/permission for every API endpoint, for this scenario how to manage those roles/permission in the azure ad, Who is responsible for assigning those roles to every client's users after onboarding?
For every company, we have a users limit then how can we restrict a company's users (like only 5 users from a company able to use our application)
We have a special case like module-based permission for our customers. How can we manage this?
When an organization/company starts to use our application, If we want to give them an admin panel where they are able to manage their permission-related stuff, like adding or removing roles to their users, is it possible? (all roles/permissions are fixed from our side, they only assigned those roles to their users)
++Our few customers don't have organizational email then how can we manage them in Azure ad
->You can invite them into the tenant, then they can use their gmail account to sign in the tenant.
++set application-level roles/permission for every API endpoint ... how to manage... responsible for assigning ..
->I can't understand it but I think it's based on your requirement, user who has admin role may take the responsibility.
++have a users limit then how can we restrict a company's users...
->follow this document to set who can use the azure ad application you registered for the authentication to sign in the application.
++module-based permission for our customers
-> role management?
++adding or removing roles to their users, is it possible
-> if there's no admin panel for each company, then you may follow this answer to set role for users and validate if the access token contained correct role so that this user can access the page.
Let's assume you had an application which has a frontend app as the client and an web api project as the server. Then in the front app, you need to integrate msal lib to let users sign in with their user#xx.onmicrosoft.com account or gmail account. Then the frontend app need to generate access token and call api via it. The token should contain enough information so that the api can validate if the token had enough priority to get the data. And in the frontend app, you also need to control the page direct via the access token or id token.
Then here's the official sample document.
In the end, azure ad provides user management and sign in feature. It also provides api management feature. If you have any other questions, I recommend you creating a new question with more specific requirement.

Should I authenticiate with Azure Active Directory or Windows Active Directory or Other?

I'm building a C# .net Framework 4.6.1 WPF application that will run on azure virtual machines. I would like the application to online run on my domain/virtual machines and would like the experience for the user to be seamless(not requiring them to login in twice). Should I authenticate by grabbing credentials from windows AD(since it is managed from the Azure AD tenet) and if user is logged in and apart of the appropriate group allow access or pass those credentials to azure AAD single sign on and receive verification from that? Or should I be approaching this from a different angle entirely?
The idea about syncing your AD with azure AD is that users should be able to signin with the same account as their local accounts on services that are in Azure. So you can technically have any application in Azure using Azure AD as the mode of authentication and it should be single sign on for them. For eg I create a web application that has Azure AD as the mode of authentication and I am connected to the corporate network who's AD has been synced with Azure AD then you can just use Single Sign On. Please refer to this link to learn more about it Azure AD SSO

How to make a login page with two Azure Active Directories in the back?

I want to make an authentication page which allows a user to pick between two azure active directories. They can then enter their usernames and passwords and authenticate. Then they can use the application if authorised.
How would I go about implementing the authentication page? I don't completely understand how to implement a connection between two different active directories.
You could make your application multi-tenant by finding the "Multi-Tenanted"switch on the properties page of your application registration in the Azure portal and setting it to "Yes".
With a multi-tenant application, requests are sent to an endpoint that multiplexes across all Azure AD tenants: https://login.microsoftonline.com/common .When Azure AD receives a request on the /common endpoint, it signs the user in and as a consequence discovers which tenant the user is from. You don't need to let user choose which directory he want to login .
Please click here for more about how to sign in any Azure Active Directory (AD) user using the multi-tenant application pattern . And here is a code sample shows how to build a multi-tenant .Net MVC web application that uses OpenID Connect to sign up and sign in users from any Azure Active Directory tenant .
In addition ,if you want to restrict certain tenants when using multi-tenant applications on Azure AD , you can perform validation in your own code in application by checking the tenantID (tid) claim in JWT token .

User management with Azure Active Directory?

I am new to Azure Active Directory and I am bit confused about the concept and its capabilities.
I am developing an API and a native client application that will consume this API. I registered both the API and the client app in AAD and
I managed the authorization of the client application using my Admin credentials (Azure Account). But I still don't get it.
I want the users of my client application to be able to register to the app service and then use it.
Should I handle that myself within the API (user/password in database) ?
Or
programmatically create users in AAD when users signup for my application ?
Which solution is better if I plan to offer more APIs ?
If using AAD is the case I will be grateful if you provide explanations, useful links or code examples if possible.
Your question is quite broad, and is comprised of several questions, so it is hard to answer concisely.
If your users are already in your Azure AD, you should use that as the user store. If however, they are outside of your organization, you could use Azure AD B2C, which contains functionality for selfservice account creation. Or take a look at https://stackoverflow.com/a/16068340 for a suggestion on how to use AAD for public users.
If the users are already present in your AAD, and you haven't set up user assignment on the application in AAD, they can already log on to the application.
You can use role based security to grant users different levels of access to the API methods if you are interested in that.

Can Azure Active Directory be used as a Login Broker?

My company wants to develop something it calls a "Login Broker" for an on-premise desktop application also under development. The on-premise application will make significant use of Azure services (DocumentDb, Table Storage, Service Fabric, etc). Our goal is to be able to distribute the main application without it containing any knowledge of configuration values to reach Azure resources (endpoints, keys, etc). As a user logs in through the Login Broker, the desktop application then becomes aware of how to reach its resources, what permissions that user has within the application, and so on.
So far, my research has taken me in the direction of claims-based authentication (I'm very new to this area), which sounds correct in concept. Once a user logs in, the claims that we want to put into a token would be those specifics I mentioned above, plus we will undoubtedly have other claims that we don't know of yet that we want to assert.
My question is, does my company need to develop a custom login service / broker to authenticate users and deliver a configuration payload, or can Azure Active Directory serve this need in the way I described? Is this the kind of thing that AAD is suited for natively or would this wind up being a shoehorn that we'd rather avoid?
What you described looks like the federated identity, locally Microsoft has the Active Directory Federation Services, in cloud there are a few options:
1) Azure AD Access Control Services - https://azure.microsoft.com/en-us/documentation/articles/fundamentals-identity/#ac
2) Azure AD B2C - https://azure.microsoft.com/en-us/services/active-directory-b2c/
I would recommend to take a look at the Azure AD B2C.

Categories