BFF Management Endpoints Extensibility
The behavior of each management endpoint is defined in a service. When you add Duende.BFF to the service container, a default implementation for every management endpoint gets registered.
You can add your own implementation by overriding the default after calling AddBff()
.
The following endpoints are registered in the service container:
// management endpointsbuilder.Services.AddTransient<ILoginEndpoint, DefaultLoginEndpoint>();builder.Services.AddTransient<ISilentLoginEndpoint, DefaultSilentLoginEndpoint>();builder.Services.AddTransient<ISilentLoginCallbackEndpoint, DefaultSilentLoginCallbackEndpoint>();builder.Services.AddTransient<ILogoutEndpoint, DefaultLogoutEndpoint>();builder.Services.AddTransient<IUserEndpoint, DefaultUserEndpoint>();builder.Services.AddTransient<IBackchannelLogoutEndpoint, DefaultBackchannelLogoutEndpoint>();builder.Services.AddTransient<IDiagnosticsEndpoint, DefaultDiagnosticsEndpoint>();
The management endpoint services all inherit from the IBffEndpoint
, which provides a general-purpose mechanism to add custom logic to the endpoints.
public interface IBffEndpoint{ Task ProcessRequestAsync(HttpContext context, CancellationToken ct);}
You can customize the behavior of the endpoints either by implementing the appropriate interface. The default implementations can serve as a starting point for your own implementation.
// management endpointsbuilder.Services.AddTransient<ILoginService, DefaultLoginService>();builder.Services.AddTransient<ISilentLoginService, DefaultSilentLoginService>();builder.Services.AddTransient<ISilentLoginCallbackService, DefaultSilentLoginCallbackService>();builder.Services.AddTransient<ILogoutService, DefaultLogoutService>();builder.Services.AddTransient<IUserService, DefaultUserService>();builder.Services.AddTransient<IBackchannelLogoutService, DefaultBackchannelLogoutService>();builder.Services.AddTransient<IDiagnosticsService, DefaultDiagnosticsService>();
The management endpoint services all inherit from the IBffEndpointService
, which provides a general-purpose mechanism to add custom logic to the endpoints.
public interface IBffEndpointService{ Task ProcessRequestAsync(HttpContext context);}
You can customize the behavior of the endpoints either by implementing the appropriate interface or by extending the default implementation of that interface. In many cases, extending the default implementation is preferred, as this allows you to keep most of the default behavior by calling the base ProcessRequestAsync from your derived class.
Several of the default endpoint service implementations also define virtual methods that can be overridden to customize their behavior with more granularity.