Browse Source

Add a new UseCustomViews option to disable the built-in views/assets

pull/7/head
Bart Calixto 10 years ago
committed by Kévin Chalet
parent
commit
fb103fad11
  1. 21
      src/OpenIddict/OpenIddictExtensions.cs
  2. 6
      src/OpenIddict/OpenIddictOptions.cs

21
src/OpenIddict/OpenIddictExtensions.cs

@ -113,12 +113,13 @@ namespace Microsoft.AspNet.Builder {
owin.UseXXssProtection(options => options.EnabledWithBlockMode()); owin.UseXXssProtection(options => options.EnabledWithBlockMode());
}); });
#endif #endif
if (!instance.UseCustomViews) {
builder.UseStaticFiles(new StaticFileOptions { builder.UseStaticFiles(new StaticFileOptions {
FileProvider = new EmbeddedFileProvider( FileProvider = new EmbeddedFileProvider(
assembly: Assembly.Load(new AssemblyName("OpenIddict.Assets")), assembly: Assembly.Load(new AssemblyName("OpenIddict.Assets")),
baseNamespace: "OpenIddict.Assets") baseNamespace: "OpenIddict.Assets")
}); });
}
builder.UseCors(options => { builder.UseCors(options => {
options.AllowAnyHeader(); options.AllowAnyHeader();
@ -192,9 +193,11 @@ namespace Microsoft.AspNet.Builder {
// Update the Razor options to use an embedded provider // Update the Razor options to use an embedded provider
// extracting its views from the current assembly. // extracting its views from the current assembly.
.AddRazorOptions(options => { .AddRazorOptions(options => {
options.FileProvider = new EmbeddedFileProvider( if (!instance.UseCustomViews) {
assembly: typeof(OpenIddictOptions).GetTypeInfo().Assembly, options.FileProvider = new EmbeddedFileProvider(
baseNamespace: typeof(OpenIddictOptions).Namespace); assembly: typeof(OpenIddictOptions).GetTypeInfo().Assembly,
baseNamespace: typeof(OpenIddictOptions).Namespace);
}
}); });
// Register the sign-in manager in the isolated container. // Register the sign-in manager in the isolated container.

6
src/OpenIddict/OpenIddictOptions.cs

@ -79,5 +79,11 @@ namespace OpenIddict {
/// Setting this option to false in production is strongly encouraged to mitigate man-in-the-middle attacks. /// Setting this option to false in production is strongly encouraged to mitigate man-in-the-middle attacks.
/// </summary> /// </summary>
public bool AllowInsecureHttp { get; set; } public bool AllowInsecureHttp { get; set; }
/// <summary>
/// Set to <c>true</c> to allow you to use your own views/styles/scripts in your server.
/// When using custom views you MUST provide Razor views for Authorize, Logout, and SignIn actions.
/// </summary>
public bool UseCustomViews { get; set; }
} }
} }

Loading…
Cancel
Save