Created
February 26, 2019 01:23
-
-
Save himadric/63e4c35394529c670c0a16dd934ceea6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Clients; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.AspNetCore.Authentication.JwtBearer; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Logging; | |
namespace SitecoreApi | |
{ | |
public class Startup | |
{ | |
private readonly ILogger<Startup> _logger; | |
public Startup(ILogger<Startup> logger) | |
{ | |
_logger = logger; | |
} | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services | |
.AddMvcCore() | |
.AddJsonFormatters() | |
.AddAuthorization(); | |
services.AddCors(); | |
services.AddDistributedMemoryCache(); | |
services.AddAuthentication("Bearer") | |
.AddJwtBearer("Bearer", options => | |
{ | |
options.Authority = Constants.SitecoreAuthority; | |
options.RequireHttpsMetadata = false; | |
options.Audience = "sitecore.profile.api"; | |
}); | |
} | |
public void Configure(IApplicationBuilder app) | |
{ | |
app.UseCors(policy => | |
{ | |
policy.WithOrigins( | |
"http://localhost:5002"); | |
policy.AllowAnyHeader(); | |
policy.AllowAnyMethod(); | |
policy.WithExposedHeaders("WWW-Authenticate"); | |
}); | |
app.UseAuthentication(); | |
app.UseMvc(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment