Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created May 13, 2020 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/8e45c8302225b2c48cb035a64b82668e to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/8e45c8302225b2c48cb035a64b82668e to your computer and use it in GitHub Desktop.
Startup for Web API protected using Azure AD B2C
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddProtectedWebApi(Configuration, "AzureAdB2C");
services.AddControllers();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseCors(builder =>
{
builder.WithOrigins("http://localhost:4200")
.AllowCredentials()
.AllowAnyMethod()
.AllowAnyHeader();
});
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment