Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Startup
- {
- public void Configuration(IAppBuilder app)
- {
- ConfigureOAuth(app);
- HttpConfiguration config = new HttpConfiguration();
- WebApiConfig.Register(config);
- var tokenCorsPolicy = new CorsPolicy
- {
- AllowAnyOrigin = true,
- AllowAnyHeader = true,
- AllowAnyMethod = true
- };
- var corsOptions = new CorsOptions
- {
- PolicyProvider = new CorsPolicyProvider
- {
- PolicyResolver = request => Task.FromResult(request.Path.ToString().StartsWith("/token") ? tokenCorsPolicy : null)
- }
- };
- app.UseCors(corsOptions);
- app.UseWebApi(config);
- }
- public void ConfigureOAuth(IAppBuilder app)
- {
- OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
- {
- AllowInsecureHttp = true,
- TokenEndpointPath = new PathString("/token"),
- AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
- Provider = new SimpleAuthorizationServerProvider()
- };
- // Token Generation
- app.UseOAuthAuthorizationServer(OAuthServerOptions);
- app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement