Skip to content

Commit

Permalink
Allowed to override the ClaimsToHeaders middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
kesskalli committed Dec 28, 2020
1 parent 3ef6abd commit 4fc2b4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/Ocelot/Middleware/OcelotPipelineConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public class OcelotPipelineConfiguration
/// </value>
public Func<HttpContext, Func<Task>, Task> AuthorizationMiddleware { get; set; }

/// <summary>
/// This allows the user to completely override the ocelot claims to headers middleware
/// </summary>
/// <value>
/// <placeholder>This allows the user to completely override the ocelot claims to headers middleware</placeholder>
/// </value>
public Func<HttpContext, Func<Task>, Task> ClaimsToHeadersMiddleware { get; set; }

/// <summary>
/// This allows the user to implement there own query string manipulation logic
/// </summary>
Expand Down
13 changes: 11 additions & 2 deletions src/Ocelot/Middleware/OcelotPipelineExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,17 @@ public static class OcelotPipelineExtensions
app.Use(pipelineConfiguration.AuthorizationMiddleware);
}

// Now we can run the claims to headers transformation middleware
app.UseClaimsToHeadersMiddleware();
// Now we can run the claims to headers transformation middleware.
// We allow the ocelot middleware to be overriden by whatever the
// user wants
if (pipelineConfiguration.ClaimsToHeadersMiddleware == null)
{
app.UseClaimsToHeadersMiddleware();
}
else
{
app.Use(pipelineConfiguration.ClaimsToHeadersMiddleware);
}

// Allow the user to implement their own query string manipulation logic
app.UseIfNotNull(pipelineConfiguration.PreQueryStringBuilderMiddleware);
Expand Down

0 comments on commit 4fc2b4e

Please sign in to comment.