Browse Source

Remove OpenIddictModule

pull/247/head
Kévin Chalet 9 years ago
parent
commit
8e92e1467e
  1. 29
      src/OpenIddict.Core/OpenIddictBuilder.cs
  2. 17
      src/OpenIddict.Core/OpenIddictExtensions.cs
  3. 56
      src/OpenIddict.Core/OpenIddictModule.cs
  4. 5
      src/OpenIddict.Core/OpenIddictOptions.cs

29
src/OpenIddict.Core/OpenIddictBuilder.cs

@ -8,7 +8,6 @@ using System;
using System.ComponentModel;
using System.IdentityModel.Tokens.Jwt;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using AspNet.Security.OpenIdConnect.Extensions;
@ -206,34 +205,6 @@ namespace Microsoft.AspNetCore.Builder {
return this;
}
/// <summary>
/// Registers a new OpenIddict module. If a module with the same name already
/// exists, the new instance is ignored and this extension has no effect.
/// </summary>
/// <param name="name">The name of the OpenIddict module.</param>
/// <param name="position">The relative position of the OpenIddict module in the ASP.NET Core pipeline.</param>
/// <param name="registration">The delegate used to register the module in the ASP.NET Core pipeline.</param>
/// <returns>The<see cref="OpenIddictBuilder"/>.</returns>
public virtual OpenIddictBuilder AddModule(
[NotNull] string name, int position,
[NotNull] Action<IApplicationBuilder> registration) {
if (string.IsNullOrEmpty(name)) {
throw new ArgumentNullException(nameof(name));
}
if (registration == null) {
throw new ArgumentNullException(nameof(registration));
}
return Configure(options => {
if (options.Modules.Any(module => module.Name == name)) {
return;
}
options.Modules.Add(new OpenIddictModule(name, position, registration));
});
}
/// <summary>
/// Registers a new ephemeral key used to sign the tokens issued by OpenIddict: the key
/// is discarded when the application shuts down and tokens signed using this key are

17
src/OpenIddict.Core/OpenIddictExtensions.cs

@ -5,7 +5,6 @@
*/
using System;
using System.Linq;
using AspNet.Security.OpenIdConnect.Extensions;
using JetBrains.Annotations;
using Microsoft.Extensions.Caching.Distributed;
@ -109,21 +108,7 @@ namespace Microsoft.AspNetCore.Builder {
"client credentials, password and refresh token flows.");
}
// Get the modules registered by the application
// and add the OpenID Connect server middleware.
var modules = options.Modules.ToList();
modules.Add(new OpenIddictModule("OpenID Connect server", 0, builder => builder.UseOpenIdConnectServer(options)));
// Register the OpenIddict modules in the ASP.NET Core pipeline.
foreach (var module in modules.OrderBy(module => module.Position)) {
if (module?.Registration == null) {
throw new InvalidOperationException("An invalid OpenIddict module was registered.");
}
module.Registration(app);
}
return app;
return app.UseOpenIdConnectServer(options);
}
/// <summary>

56
src/OpenIddict.Core/OpenIddictModule.cs

@ -1,56 +0,0 @@
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System;
using System.Diagnostics;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Builder;
namespace OpenIddict {
/// <summary>
/// Represents an OpenIddict module.
/// </summary>
[DebuggerDisplay("{Name,nq}")]
public class OpenIddictModule {
/// <summary>
/// Initializes a new OpenIddict module.
/// </summary>
/// <param name="name">The name of the module.</param>
/// <param name="position">The position of the module in the ASP.NET Core pipeline.</param>
/// <param name="registration">The delegate used to register the module in the pipeline.</param>
public OpenIddictModule(
[NotNull] string name, int position,
[NotNull] Action<IApplicationBuilder> registration) {
Name = name;
Position = position;
Registration = registration;
}
/// <summary>
/// Initializes a new OpenIddict module.
/// </summary>
/// <param name="registration">The delegate used to register the module in the pipeline.</param>
public OpenIddictModule([NotNull] Action<IApplicationBuilder> registration) {
Registration = registration;
}
/// <summary>
/// Gets or sets the name of the module.
/// </summary>
public string Name { get; }
/// <summary>
/// Gets or sets the position of the module in the ASP.NET Core pipeline.
/// </summary>
public int Position { get; }
/// <summary>
/// Gets or sets the delegate used to register the
/// OpenIddict module in the ASP.NET Core pipeline.
/// </summary>
public Action<IApplicationBuilder> Registration { get; }
}
}

5
src/OpenIddict.Core/OpenIddictOptions.cs

@ -31,11 +31,6 @@ namespace OpenIddict {
/// </summary>
public ICollection<string> GrantTypes { get; } = new HashSet<string>(StringComparer.Ordinal);
/// <summary>
/// Gets the list of the OpenIddict modules registered in the application.
/// </summary>
public ICollection<OpenIddictModule> Modules { get; } = new List<OpenIddictModule>();
/// <summary>
/// Gets or sets a boolean determining whether client identification is required.
/// Enabling this option requires registering a client application and sending a

Loading…
Cancel
Save