-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #1580. Added an opportunity to use several authentication provider keys. * Update src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs Co-authored-by: Raynald Messié <redbird_project@yahoo.fr> * #1580. Replaced AuthenticationProviderKeys type from the list to the array. * #1580. Added a doc how to use AuthenticationProviderKeys in a Route. * #1580. Amended the description how to use AuthenticationProviderKeys in a Route. * #1580. Added an opportunity to use several authentication provider keys. * Update src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs Co-authored-by: Raynald Messié <redbird_project@yahoo.fr> * #1580. Replaced AuthenticationProviderKeys type from the list to the array. * #1580. Added a doc how to use AuthenticationProviderKeys in a Route. * #1580. Amended the description how to use AuthenticationProviderKeys in a Route. * Quick review * #1580. Implemented review points. * #1580. Initialized result with AuthenticateResult.NoResult(). * #1580. Added @ggnaegi suggestions. * #1580. Brought back the idea not to allocate AuthenticateResult instance. * quick review * Return Auth result of the last key in the collection * review unit tests * Enable parallelization of unit tests * Fix messages * Disable parallelization for PollyQoSProviderTests * Switch off unstable test * Re-enable parallelization & Isolate unstable test * Reflection issue in middleware base: remove getting Type object * Switch off unstable test * Clean code * Make MiddlewareName as public property * Code review by @RaynaldM * AuthenticationMiddleware: Line & Branch coverage -> 100% * AuthenticationOptionsCreator: coverage -> 100% * Remove private helpers with one reference * RouteOptionsCreator: coverage -> 100% * FileAuthenticationOptions: Refactor ToString method * FileConfigurationFluentValidator: coverage -> 100% * RouteFluentValidator: Branch coverage -> 100% * TODO and Skip unstable test * Move acceptance tests to the separate folder * Review and refactor acceptance tests * Add AuthenticationSteps class. Choose inheritance over composition: less code * Add 'GivenIHaveATokenWithScope' to 'AuthenticationSteps' * Temporarily disable 'Should_timeout_per_default_after_90_seconds' test * Add CreateIdentityServer method * Add draft test * Update route validator to support multiple auth schemes * Acceptance tests * Revert "TODO and Skip unstable test" This reverts commit 1ec8564. * Revert "Make MiddlewareName as public property" This reverts commit 6f50c76. * Revert "Reflection issue in middleware base: remove getting Type object" * Clean up * Isolate unstable test * Mark old property as `Obsolete` * a tiny little bit of cleanup * Handling cases when principal or identity are null * Update Authentication feature docs * Convert back to block scoped namespace --------- Co-authored-by: Igor Polishchuk <ipolishchuk@controlit.eu> Co-authored-by: Raman Maksimchuk <dotnet044@gmail.com> Co-authored-by: Raynald Messié <redbird_project@yahoo.fr> Co-authored-by: Igor Polishchuk <mayorsheff@gmail.com> Co-authored-by: Guillaume Gnaegi <58469901+ggnaegi@users.noreply.github.com>
- Loading branch information
1 parent
f4803c2
commit c9510b1
Showing
25 changed files
with
1,873 additions
and
2,054 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
11 changes: 11 additions & 0 deletions
11
src/Ocelot/Authentication/Middleware/AuthenticationMiddlewareExtensions.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
|
||
namespace Ocelot.Authentication.Middleware; | ||
|
||
public static class AuthenticationMiddlewareExtensions | ||
{ | ||
public static IApplicationBuilder UseAuthenticationMiddleware(this IApplicationBuilder builder) | ||
{ | ||
return builder.UseMiddleware<AuthenticationMiddleware>(); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
src/Ocelot/Authentication/Middleware/AuthenticationMiddlewareMiddlewareExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,51 @@ | ||
namespace Ocelot.Configuration | ||
{ | ||
public class AuthenticationOptions | ||
{ | ||
public AuthenticationOptions(List<string> allowedScopes, string authenticationProviderKey) | ||
{ | ||
AllowedScopes = allowedScopes; | ||
AuthenticationProviderKey = authenticationProviderKey; | ||
} | ||
|
||
public List<string> AllowedScopes { get; } | ||
public string AuthenticationProviderKey { get; } | ||
} | ||
using Ocelot.Configuration.File; | ||
|
||
namespace Ocelot.Configuration | ||
{ | ||
public sealed class AuthenticationOptions | ||
{ | ||
public AuthenticationOptions(List<string> allowedScopes, string authenticationProviderKey) | ||
{ | ||
AllowedScopes = allowedScopes; | ||
AuthenticationProviderKey = authenticationProviderKey; | ||
AuthenticationProviderKeys = []; | ||
} | ||
|
||
public AuthenticationOptions(FileAuthenticationOptions from) | ||
{ | ||
AllowedScopes = from.AllowedScopes ?? []; | ||
AuthenticationProviderKey = from.AuthenticationProviderKey ?? string.Empty; | ||
AuthenticationProviderKeys = from.AuthenticationProviderKeys ?? []; | ||
} | ||
|
||
public AuthenticationOptions(List<string> allowedScopes, string authenticationProviderKey, | ||
string[] authenticationProviderKeys) | ||
{ | ||
AllowedScopes = allowedScopes ?? []; | ||
AuthenticationProviderKey = authenticationProviderKey ?? string.Empty; | ||
AuthenticationProviderKeys = authenticationProviderKeys ?? []; | ||
} | ||
|
||
public List<string> AllowedScopes { get; } | ||
|
||
/// <summary> | ||
/// Authentication scheme registered in DI services with appropriate authentication provider. | ||
/// </summary> | ||
/// <value> | ||
/// A <see langword="string"/> value of the scheme name. | ||
/// </value> | ||
[Obsolete("Use the " + nameof(AuthenticationProviderKeys) + " property!")] | ||
public string AuthenticationProviderKey { get; } | ||
|
||
/// <summary> | ||
/// Multiple authentication schemes registered in DI services with appropriate authentication providers. | ||
/// </summary> | ||
/// <remarks> | ||
/// The order in the collection matters: first successful authentication result wins. | ||
/// </remarks> | ||
/// <value> | ||
/// An array of <see langword="string"/> values of the scheme names. | ||
/// </value> | ||
public string[] AuthenticationProviderKeys { get; } | ||
} | ||
} |
Oops, something went wrong.