-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathStartup.cs
More file actions
39 lines (35 loc) · 1.53 KB
/
Startup.cs
File metadata and controls
39 lines (35 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Web;
using KriaSoft.AspNet.Identity.DbFirst;
using KriaSoft.AspNet.Identity.DbFirst.Security;
using KriaSoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using Microsoft.Owin.Security.OAuth;
using Owin;
[assembly: OwinStartup(typeof(Startup))]
namespace KriaSoft.AspNet.Identity.DbFirst
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Register UserManager in ApplicationDbContext in OWIN context
app.CreatePerOwinContext<ApplicationDbContext>(() => new ApplicationDbContext());
app.CreatePerOwinContext<UserManager<User, int>>(
(IdentityFactoryOptions<UserManager<User, int>> options, IOwinContext context) =>
new UserManager<User, int>(new UserStore(context.Get<ApplicationDbContext>(), "Example")));
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/token"),
Provider = new ApplicationOAuthProvider(
"self", () => HttpContext.Current.GetOwinContext().GetUserManager<UserManager<User, int>>()),
AuthorizeEndpointPath = new PathString("/api/account/authorize"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true
});
}
}
}