/// <summary>
 /// 
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="configuration"></param>
 /// <param name="cache"></param>
 /// <param name="healthService"></param>
 /// <param name="policyServerRuntimeClient"></param>
 public HealthCheckHostedService(ILogger<HealthCheckHostedService> logger, IConfiguration configuration, IMemoryCache cache, IHealthService healthService, IPolicyServerRuntimeClient policyServerRuntimeClient) {
     this.logger = logger;
     this.configuration = configuration;
     this.cache = cache;
     this.healthService = healthService;
     this.policyServerClient = policyServerRuntimeClient;
 }
示例#2
0
    /// <summary>
    /// Invoke
    /// </summary>
    /// <param name="context">The context.</param>
    /// <param name="client">The client.</param>
    /// <returns></returns>
    public async Task Invoke(HttpContext context, IPolicyServerRuntimeClient client)
    {
        if (context.User.Identity.IsAuthenticated)
        {
            var policy = await client.EvaluateAsync(context.User);

            var roleClaims       = policy.Roles.Select(x => new Claim("role", x));
            var permissionClaims = policy.Permissions.Select(x => new Claim("permission", x));
            var id = new ClaimsIdentity("PolicyServerMiddleware", "name", "role");
            id.AddClaims(roleClaims);
            id.AddClaims(permissionClaims);
            context.User.AddIdentity(id);
        }
        await _next(context);
    }
示例#3
0
 /// <summary>
 /// Initialize the controller
 /// </summary>
 /// <param name="db"></param>
 /// <param name="svc"></param>
 public ReportArgumentQueryController(IDatabaseContext db, ISqlReportService svc, IPolicyServerRuntimeClient policyClient) : base(db, svc, policyClient)
 {
     this.policyClient = policyClient;
 }
 public ValuesController(IPolicyServerRuntimeClient client, IAuthorizationService authz)
 {
     _client = client;
     _authz  = authz;
 }
 public MedicationRequirementHandler(IPolicyServerRuntimeClient client)
 {
     _client = client;
 }
 public PermissionHandler(IPolicyServerRuntimeClient client)
 {
     _client = client;
 }
 /// <summary>
 /// Initialize the base controller        /// </summary>
 /// <param name="db"></param>
 /// <param name="svc"></param>
 /// <param name="policyClient"></param>
 public ReportController(IDatabaseContext db, ISqlReportService svc, IPolicyServerRuntimeClient policyClient) : base(db, svc, policyClient)
 {
 }
 /// <summary>
 /// Authorization controller
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="client"></param>
 /// <param name="configuration"></param>
 public AuthorizationController(ILogger <AuthorizationController> logger, IPolicyServerRuntimeClient client, IConfiguration configuration)
 {
     this.logger        = logger;
     this.policyClient  = client;
     this.configuration = configuration;
 }
示例#9
0
 /// <summary>
 /// Initialize the base controller
 /// </summary>
 /// <param name="db"></param>
 /// <param name="svc"></param>
 public BaseController(IDatabaseContext db, ISqlReportService svc, IPolicyServerRuntimeClient policyClient)
 {
     this.db           = db;
     this.svc          = svc;
     this.policyClient = policyClient;
 }