I have both -
External users who authenticate in via ASP.Net Identity and Internal/Extranet users who authenticate via AzureAD which is backed by an ADFS deployment on-premises.
When a user clicks a link or navigates directly to a page in the web application I would like to detect if that user has already authenticated with our ADFS either through one of our
Sharepoint sites, internally or similar. If true they should be directed to Azure AD with the correct domain_hint
to enable seamless single sign-on, otherwise they should be directed to a Login Screen within the application.
Currently when the application receives an unauthorized request the user is directed to a login screen where they select an authentication workflow regardless of whether they have already authenticated with a trusted federated Azure AD tenant either through Sharepoint, internally or similar.
public class DetritusAuthorise : AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(System.Web.Mvc.AuthorizationContext filterContext)
{
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary
{
{"action", nameof(Controllers.AccountController.Login)},{"controller", "Account"}
});
}
}
Example Scenario
A user is logged into a share point site then clicks a link to the web application.
I am using OWIN OpenIDConnect
and CookieAuthentication
. I can see there are adfs.ourcompany.com
, sharepoint.ourcompany.com
etc cookies in the browser however I cannot access/detect them in the request processed by the AuthorizeAttribute
.
How can I detect if a request is coming from a user who is already authenticated with our ADFS?