Ejemplo n.º 1
0
        public BundleAwareJwtBearerHandler(IOptionsMonitor <JwtBearerOptions> options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock, IBundleHttpContextAccessor bundleHttpContextAccessor)
            : base(options, logger, encoder, dataProtection, clock)
        {
            EnsureArg.IsNotNull(bundleHttpContextAccessor, nameof(bundleHttpContextAccessor));

            _bundleHttpContextAccessor = bundleHttpContextAccessor;
        }
Ejemplo n.º 2
0
        public BundleAwareJwtBearerHandlerTests()
        {
            var jwtBearerOptions = new JwtBearerOptions();
            var options          = Substitute.For <IOptionsMonitor <JwtBearerOptions> >();

            options.CurrentValue.Returns(jwtBearerOptions);
            var logger         = NullLoggerFactory.Instance;
            var encoder        = UrlEncoder.Default;
            var dataProtection = Substitute.For <IDataProtectionProvider>();
            var clock          = Substitute.For <ISystemClock>();

            _bundleHttpContextAccessor = Substitute.For <IBundleHttpContextAccessor>();
            _httpContext = new DefaultHttpContext();

            _bundleAwareJwtBearerHandler = new BundleAwareJwtBearerHandler(options, logger, encoder, dataProtection, clock, _bundleHttpContextAccessor);
            _bundleAwareJwtBearerHandler.InitializeAsync(new AuthenticationScheme("jwt", "jwt", typeof(BundleAwareJwtBearerHandler)), _httpContext);
        }
Ejemplo n.º 3
0
        public BundleAwareJwtBearerHandler(
            IOptionsMonitor <JwtBearerOptions> options,
            ILoggerFactory logger,
            UrlEncoder encoder,
            ISystemClock clock,
            IBundleHttpContextAccessor bundleHttpContextAccessor,
            IAuditHelper auditHelper,
            IClaimsExtractor claimsExtractor)
            : base(options, logger, encoder, clock)
        {
            EnsureArg.IsNotNull(bundleHttpContextAccessor, nameof(bundleHttpContextAccessor));
            EnsureArg.IsNotNull(auditHelper, nameof(auditHelper));
            EnsureArg.IsNotNull(claimsExtractor, nameof(claimsExtractor));

            _bundleHttpContextAccessor = bundleHttpContextAccessor;
            _auditHelper     = auditHelper;
            _claimsExtractor = claimsExtractor;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UrlResolver"/> class.
        /// </summary>
        /// <param name="fhirRequestContextAccessor">The FHIR request context accessor.</param>
        /// <param name="urlHelperFactory">The ASP.NET Core URL helper factory.</param>
        /// <param name="httpContextAccessor">The ASP.NET Core HTTP context accessor.</param>
        /// <param name="actionContextAccessor">The ASP.NET Core Action context accessor.</param>
        /// <param name="bundleHttpContextAccessor">The bundle aware http context accessor.</param>
        public UrlResolver(
            RequestContextAccessor <IFhirRequestContext> fhirRequestContextAccessor,
            IUrlHelperFactory urlHelperFactory,
            IHttpContextAccessor httpContextAccessor,
            IActionContextAccessor actionContextAccessor,
            IBundleHttpContextAccessor bundleHttpContextAccessor)
        {
            EnsureArg.IsNotNull(fhirRequestContextAccessor, nameof(fhirRequestContextAccessor));
            EnsureArg.IsNotNull(urlHelperFactory, nameof(urlHelperFactory));
            EnsureArg.IsNotNull(httpContextAccessor, nameof(httpContextAccessor));
            EnsureArg.IsNotNull(actionContextAccessor, nameof(actionContextAccessor));
            EnsureArg.IsNotNull(bundleHttpContextAccessor, nameof(bundleHttpContextAccessor));

            _fhirRequestContextAccessor = fhirRequestContextAccessor;
            _urlHelperFactory           = urlHelperFactory;
            _httpContextAccessor        = httpContextAccessor;
            _actionContextAccessor      = actionContextAccessor;
            _bundleHttpContextAccessor  = bundleHttpContextAccessor;
        }
Ejemplo n.º 5
0
        public BundleAwareJwtBearerHandlerTests()
        {
            var jwtBearerOptions = new JwtBearerOptions();
            var options          = Substitute.For <IOptionsMonitor <JwtBearerOptions> >();

            options.CurrentValue.Returns(jwtBearerOptions);
            options.Get(Arg.Any <string>()).Returns(jwtBearerOptions);
            var logger  = NullLoggerFactory.Instance;
            var encoder = UrlEncoder.Default;
            var clock   = Substitute.For <ISystemClock>();

            _bundleHttpContextAccessor = Substitute.For <IBundleHttpContextAccessor>();
            _httpContext     = new DefaultHttpContext();
            _auditHelper     = Substitute.For <IAuditHelper>();
            _claimsExtractor = Substitute.For <IClaimsExtractor>();

            _bundleAwareJwtBearerHandler = new BundleAwareJwtBearerHandler(options, logger, encoder, clock, _bundleHttpContextAccessor, _auditHelper, _claimsExtractor);
            _bundleAwareJwtBearerHandler.InitializeAsync(new AuthenticationScheme("jwt", "jwt", typeof(BundleAwareJwtBearerHandler)), _httpContext);
        }
        public BundleHandler(IHttpContextAccessor httpContextAccessor, IFhirRequestContextAccessor fhirRequestContextAccessor, FhirJsonSerializer fhirJsonSerializer, FhirJsonParser fhirJsonParser, ITransactionHandler transactionHandler, IBundleHttpContextAccessor bundleHttpContextAccessor, ILogger <BundleHandler> logger)
        {
            EnsureArg.IsNotNull(httpContextAccessor, nameof(httpContextAccessor));
            EnsureArg.IsNotNull(fhirRequestContextAccessor, nameof(fhirRequestContextAccessor));
            EnsureArg.IsNotNull(fhirJsonSerializer, nameof(fhirJsonSerializer));
            EnsureArg.IsNotNull(fhirJsonParser, nameof(fhirJsonParser));
            EnsureArg.IsNotNull(transactionHandler, nameof(transactionHandler));
            EnsureArg.IsNotNull(bundleHttpContextAccessor, nameof(bundleHttpContextAccessor));
            EnsureArg.IsNotNull(logger, nameof(logger));

            _fhirRequestContextAccessor = fhirRequestContextAccessor;
            _fhirJsonSerializer         = fhirJsonSerializer;
            _fhirJsonParser             = fhirJsonParser;
            _transactionHandler         = transactionHandler;
            _bundleHttpContextAccessor  = bundleHttpContextAccessor;
            _logger = logger;

            // Not all versions support the same enum values, so do the dictionary creation in the version specific partial.
            _requests = GenerateRequestDictionary();

            _httpAuthenticationFeature = httpContextAccessor.HttpContext.Features.Get <IHttpAuthenticationFeature>();
            _router          = httpContextAccessor.HttpContext.GetRouteData().Routers.First();
            _requestServices = httpContextAccessor.HttpContext.RequestServices;
        }