Skip to main content

Azure Active Directory - How to create an application (part 1)

I’m starting a series of blog post that will be about Azure Active Directory (AAD). This blog posts will cover the following topics:

  • How to create an application for AAD
  • How to get access token for Office 365 from a native application (SL,WPF, Store)
  • How to get access token for Office 365 from a web application or Windows Phone 8
  • Multi-factor Authentication 

In this post we will talk about AAD and application over AAD. When we are working with AAD, we can manage users, groups and credentials similar with the Active Directory system that we have on-premises. Both of them are very similar, only the administration UI is a little different.
To be able to access different resources in the name of the user we need to authenticate the user in only one place. In this way, the 3rd parties’ application will not handle the user credentials. This is the most important thing that we should take into account.

This can be done using AAD because we have native support for Single Sign-On. When we are talking about Single Sign-On we should think to an application that don’t require user credentials from user, but it displays a page from WAAD tenant (AAD) where user can enter his own credentials. These page is not handled by the application, only the tenant has control over this page. After the authentication process ends, the application will receive a unique token from tenant that can be used by application to access in the name of the user specific resources for a limited time period.
From portal, we have the option to create to different types of application

  • Web Application
  • Native Client Application

You should know that the Web Application can be used with any application type, because we need to render an HTML page from AAD backend. This can be done in a web application, in a WPF application or in a Windows Phone application.
The native client application can be used with success for the type of application for which we have native support. By native support, we are referring to a library that can be used directly, without having to render a custom HTML page and so (more details in the next post of this series).
In both cases, you should know that you cannot customize the page where user credentials need to be entered. The only think that you can change is the logo. The scope of this limitation is to give the user the confident that the page where he enters his credentials is the real page and not a fake one.
Application
When you create the application on Azure portal, you will see that you have a unique client id. Using this unique client id, your application will be unique identified (we are referring to the application that access AAD and not the one that you want to develop).
Also, you will need to specify the redirect URI. This address will be used for OAuth 2.0 when the redirect is done. Don’t wary if you don’t have a real address. You only need to specify a valid one – http://localhost or http://bing.com should be fine.
The most important think is the “Permissions to other applications” section. Using this section you specify which resources can be accessed using  the token that will be generated for your application.
In this example we want to give access to Office 365 Exchange Online. In this case we will add “Office 365 Exchange Online” in the applications list of this section. For testing purpose, you can set all the permissions to TRUE. Don’t forget to save the changes.
From this moment anybody that will have a token from this application will be able to access the Exchange Account from Office 365.
All this options are valid for Native Client Application. For Web Application, there are some additional options that can be set.
There is a list of keys that can be automatically generated. The key list is useful when you will need to request an access token. You will need to provide this key. Be aware on one thing. The key value is displayed only when you create it. After that moment the key is not displayed anymore. You will be able only to delete it (remove).
Each application had an APP ID URI and a REPLY URL. For testing purpose you can set them to http://localhost/. APP ID URI represent the address of your application. The second one is the address that will be used by AAD to reply to the authentication request.
In the next post we will see what code we need to write to be able to get a token from a Silverlight, Console or Store application.

Comments

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(...

How to audit an Azure Cosmos DB

In this post, we will talk about how we can audit an Azure Cosmos DB database. Before jumping into the problem let us define the business requirement: As an Administrator I want to be able to audit all changes that were done to specific collection inside my Azure Cosmos DB. The requirement is simple, but can be a little tricky to implement fully. First of all when you are using Azure Cosmos DB or any other storage solution there are 99% odds that you’ll have more than one system that writes data to it. This means that you have or not have control on the systems that are doing any create/update/delete operations. Solution 1: Diagnostic Logs Cosmos DB allows us activate diagnostics logs and stream the output a storage account for achieving to other systems like Event Hub or Log Analytics. This would allow us to have information related to who, when, what, response code and how the access operation to our Cosmos DB was done. Beside this there is a field that specifies what was th...

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills)

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills) The idea that moving to the cloud reduces the costs is a common misconception. The cloud infrastructure provides flexibility, scalability, and better CAPEX, but it does not guarantee lower costs without proper optimisation and management of the cloud services and infrastructure. Idle and unused resources, overprovisioning, oversize databases, and unnecessary data transfer can increase running costs. The regional pricing mode, multi-cloud complexity, and cost variety add extra complexity to the cost function. Cloud adoption without a cost governance strategy can result in unexpected expenses. Improper usage, combined with a pay-as-you-go model, can result in a nightmare for business stakeholders who cannot track and manage the monthly costs. Cloud-native services such as AI services, managed databases, and analytics platforms are powerful, provide out-of-the-shelve capabilities, and increase business agility and innovation. H...