Skip to content

Instantly share code, notes, and snippets.

@HenrikFrystykNielsen
Created March 28, 2014 15:33
Show Gist options
  • Save HenrikFrystykNielsen/9835526 to your computer and use it in GitHub Desktop.
Save HenrikFrystykNielsen/9835526 to your computer and use it in GitHub Desktop.
Gist of how to hook in additional OWIN authentication providers
using System.Web.Http;
using Autofac;
using Microsoft.WindowsAzure.Mobile.Service;
using Microsoft.WindowsAzure.Mobile.Service.Config;
using Owin;
namespace henrikntest09Service
{
public static class WebApiConfig
{
public static void Register()
{
// Use this class to set configuration options for your mobile service
ConfigOptions options = new ConfigOptions();
// Use this class to set WebAPI configuration options
HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options, (httpConfig, autofac) =>
{
autofac.RegisterInstance(new AuthOwinAppBuilder(httpConfig)).As<IOwinAppBuilder>();
}));
}
}
public class AuthOwinAppBuilder : OwinAppBuilder
{
public AuthOwinAppBuilder(HttpConfiguration config)
: base(config)
{
}
protected override void ConfigureAuthentication(IAppBuilder appBuilder, HttpConfiguration config)
{
base.ConfigureAuthentication(appBuilder, config);
// Add your own authentication modules
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment