-
Notifications
You must be signed in to change notification settings - Fork 1
/
Startup.cs
32 lines (27 loc) · 1023 Bytes
/
Startup.cs
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
using Owin;
using System.Web.Http;
using IdentityServer3.AccessTokenValidation;
using Microsoft.Owin.Security.Cookies;
//[assembly: OwinStartup("Startup", typeof(ApiIdentityNetFramework.Startup))]
namespace ApiIdentityNetFramework
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
//ConfigureAuth(app); configure IS4 here (you just need this)
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = "https://localhost:44332",
RequiredScopes = new[] { "api1" }
});
//configure web api
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
//require authentication for all controllers
config.Filters.Add(new AuthorizeAttribute());
app.UseWebApi(config);
}
}
}