Logging into Umbraco 7.3.0+ back-office using AD with ADFS
I need to authenticate back-office users in Umbraco 7.3.0 with our local test Active Directory (AD) server. Due to the introduction of Identity in Umbraco 7 it seems we need to make use of Active Directory Federation Services (ADFS) in order to authenticate against our AD.
I can successfully authenticate against our test AD in Umbraco 6.2.0 using ActiveDirectoryMembershipProvider, but can't do the same in ADFS.
Here is my code to to connect to the ADFS server from umbraco:
using System.Configuration;
using System.IdentityModel.Tokens;
using Microsoft.Owin.Security.ActiveDirectory;
using Owin;
using Umbraco.Web.Security.Identity;
namespace MyCompany.Membership.Umbraco.Extensions
{
public static class AdfsAuthExtensions
{
/// <summary>
/// Configure Active Directory Fedration Services so we can connect to LDAP connections.
/// </summary>
/// <param name="app">The app builder.</param>
/// <param name="caption">Sign in with caption.</param>
/// <param name="style">The button CSS class.</param>
/// <param name="icon">The button icon CSS class.</param>
public static void ConfigureBackOfficeActiveDirectoryFederationServicesAuthentication(
this IAppBuilder app,
string caption = "Active Directory",
string style = "btn-microsoft",
string icon = "fa-windows")
{
var options = new ActiveDirectoryFederationServicesBearerAuthenticationOptions
{
MetadataEndpoint = ConfigurationManager.AppSettings["AdfsMetadataEndpoint"],
TokenValidationParameters = new TokenValidationParameters() { ValidAudience = ConfigurationManager.AppSettings["AdfsAudience"] }
};
options.ForUmbracoBackOffice(style, icon);
app.UseActiveDirectoryFederationServicesBearerAuthentication(options);
}
}
}
My ADFS meta data URL (https://adfsserver/federationmetadata/2007-06/federationmetadata.xml) is visible from my dev machine but has an invalid SSL certificate.
The extension method is called like this:
using Microsoft.Owin;
using Owin;
using Umbraco.Core;
using Umbraco.Core.Security;
using Umbraco.Web.Security.Identity;
[assembly: OwinStartup("UmbracoCustomOwinStartup", typeof(UmbracoCustomOwinStartup))]
namespace MyCompany.Membership.Web
{
public class UmbracoCustomOwinStartup
{
public void Configuration(IAppBuilder app)
{
// Configure back office users membership provider
app.ConfigureUserManagerForUmbracoBackOffice(
ApplicationContext.Current,
MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider());
// Ensure OWIN is configured for Umbraco back office authentication
app
.UseUmbracoBackOfficeCookieAuthentication(ApplicationContext.Current)
.UseUmbracoBackOfficeExternalCookieAuthentication(ApplicationContext.Current);
// Configure additional back office authentication options
app.ConfigureBackOfficeActiveDirectoryFederationServicesAuthentication();
}
}
}
AuthenticationException: The remote certificate is invalid according to the validation procedure.
WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
So my question is:
Has anyone successfully connected to ADFS in Umbraco 7.3.0+?
Logging into Umbraco 7.3.0+ back-office using AD with ADFS
I need to authenticate back-office users in Umbraco 7.3.0 with our local test Active Directory (AD) server. Due to the introduction of Identity in Umbraco 7 it seems we need to make use of Active Directory Federation Services (ADFS) in order to authenticate against our AD.
I can successfully authenticate against our test AD in Umbraco 6.2.0 using ActiveDirectoryMembershipProvider, but can't do the same in ADFS.
Here is my code to to connect to the ADFS server from umbraco:
The config options are:
My ADFS meta data URL (https://adfsserver/federationmetadata/2007-06/federationmetadata.xml) is visible from my dev machine but has an invalid SSL certificate.
The extension method is called like this:
I have setup a "Relying Party" in ADFS with an identifier of https://testadfs.local.
My error that I'm getting is:
AuthenticationException: The remote certificate is invalid according to the validation procedure. WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
So my question is:
Thanks!
A quick update - I solved the invalid certificate issue. The solution was:
Now the federation metadata URL (https://adfsserver/federationmetadata/2007-06/federationmetadata.xml) shouldn't complain about an invalid cert.
I can now access the Umbraco 7 backoffice login screen but don't have an external provider button showing... almost there I think.
Anybody know how to add external providers so they show a login button?
Here is my new code but it's not working:
Hey me again :) I've managed to get the external provider button to display. My code is below:
The secret was using WS-Federation but now I'm missing Microsoft.IdentityServer dll on the server. Almost there...
Hi shanem,
I'm curious, have you finally managed to do this login work?
I didn't, sorry. I will look into it again when I have a moment and post my findings here.
Hi Shanem
Did you manage to get this up and running?
I created a related thread here with WS-Federation code: https://our.umbraco.org/forum/extending-umbraco-and-using-the-api//79201-account-auto-linking-not-working-with-owin-ad-fsws-federation-authentication
is working on a reply...