Skip to content

MiddlewareExtensions

Class Reference

Provides a class to register ASP.NET Core Middleware SDK implementations with an IApplicationBuilder.

  • Namespace: TrimbleCloud.Tam.AspNet
  • Assembly: TrimbleCloud.Tam.AspNet.dll
public static class MiddlewareExtensions

This is a static class and provides extension methods for an IApplicationBuilder. Additional SDK classes must be registered with the IServiceCollection via AccessManagementExtensions.

Registers middleware with ASP.NET Core to provide authorization decisions before action taken on a call to a controller for example.

public static IApplicationBuilder UseAccessManagement(this IApplicationBuilder builder, string packageNamespace, string rule);

builder IApplicationBuilder The application builder for ASP.NET Core.

packageNamespace string The policy package namespace to use for decisions.

rule string The policy rule to use for decisions.

UseAccessManagement is designed to operate against a single package namespace, but ASP.NET core pipeline can be used to customize which package is used based upon conditional routing.

For example:

app.UseWhen(context => context.Request.Path.StartsWithSegments("/api"), appBuilder =>
{
app.UseAccessManagement("sample.authz", "allow");
});
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAccessManagement(environment, consumerKey, consumerSecret, applianceUrl);
var app = builder.Build();
app.UseAuthorization();
app.UseAccessManagement("sample.authz", "allow");
app.MapControllers();
app.Run();