Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oauth 2 token for Active Directory accounts

Tags:

I have used Owin in the past to create a token endpoint in my Mvc Web Api projects to provide oauth 2.0 tokens with "Resource Owner Password Credentials" grant type where access token provider would check a database user table to verify the validity of the credentials supplied by the mobile client (multiplatform App developed with Visual studio tool for Cordova).

In this project, the Web Api will be consumed by a multiplatform Mobile app used by Active Directory Windows domain accounts

I would like to use Owin Oauth 2.0 to grant an Access Token to these users but I don't know how to check the validity of these credentials.

What I was thinking is to put the /token endpoint behind "basic authentication" and in the code of the Access Token Provider get the user from the Identity that, in case of authenticated used, should be automatically created by the Asp.net pipeline.

Is it something that could work?

Do you know any better idea to use Oauth 2.0 for AD Windows Accounts?

Note:

I'm also investigating if Active Directory is able to provide an Oauth 2.0 endpoint by itself.

like image 706
systempuntoout Avatar asked Apr 12 '15 07:04

systempuntoout


People also ask

Does OAuth2 support Active Directory?

Azure Active Directory (Azure AD) supports all OAuth 2.0 flows.

What is Active Directory token?

An access token contains claims that you can use in Azure Active Directory B2C (Azure AD B2C) to identify the granted permissions to your APIs. When calling a resource server, an access token must be present in the HTTP request. An access token is denoted as access_token in the responses from Azure AD B2C.


2 Answers

Here is a pretty good walkthrough of how to use Active Directory Federation Services to obtain an OAuth2 token. https://technet.microsoft.com/en-us/library/dn633593.aspx. You'll have to follow all the links at the bottom to get the entire walkthrough.

Note that it refers to using Windows Azure AD Authentication Library for .NET. But according to that documentation, that library is used for both Azure Active Directory and on premises Active Directory.

As for the workflow, once authenticated you'll be able to obtain and present a bearer token to your WebAPI. Your WebAPI then "validates the signature of the token to ensure it was issued by AD FS, checks to see if the token is still valid and hasn’t expired and may possibly also validate other claims in the token. At this point, the client is either authorized and the information they requested is sent in the response or they are unauthorized and no data will be sent." - https://technet.microsoft.com/en-us/library/dn633593.aspx

like image 56
Brandon O'Dell Avatar answered Sep 20 '22 15:09

Brandon O'Dell


You could use ADFS 3.0 on top of AD which would provide you with OAuth 2.0 Authorization Server functionality: http://blog.scottlogic.com/2015/03/09/OAUTH2-Authentication-with-ADFS-3.0.html

Putting the token endpoint behind "basic authentication" does not help you because you'd be authenticating the client on the token endpoint, not the user. You could put the authorization endpoint behind "basic authentication" though.

like image 40
Hans Z. Avatar answered Sep 17 '22 15:09

Hans Z.