public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context and user and role manager to use a single instance per request
app.CreatePerOwinContext(BlogIdentityDbContext.Create);
app.CreatePerOwinContext<BlogUserManager>(BlogUserManager.Create);
app.CreatePerOwinContext<BlogRoleManager>(BlogRoleManager.Create);
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Configure the application for OAuth based flow
PublicClientId = "self";
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/api/account/login"),
Provider = new BlogOAuthAuthorizationServerProvider(PublicClientId),
AuthorizeEndpointPath = new PathString("/api/account/externalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(120),
AllowInsecureHttp = true
};
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
}
}