17 lines
618 B
C#
17 lines
618 B
C#
using Grpc.Core.Interceptors;
|
|
|
|
namespace MxGateway.Server.Security.Authorization;
|
|
|
|
public static class GrpcAuthorizationServiceCollectionExtensions
|
|
{
|
|
public static IServiceCollection AddGatewayGrpcAuthorization(this IServiceCollection services)
|
|
{
|
|
services.AddSingleton<GatewayGrpcScopeResolver>();
|
|
services.AddSingleton<IGatewayRequestIdentityAccessor, GatewayRequestIdentityAccessor>();
|
|
services.AddSingleton<GatewayGrpcAuthorizationInterceptor>();
|
|
services.AddGrpc(options => options.Interceptors.Add<GatewayGrpcAuthorizationInterceptor>());
|
|
|
|
return services;
|
|
}
|
|
}
|