public void Setup()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddCoreDependencies();
            serviceCollection.AddDALDependencies();
            serviceCollection.AddApiServiceCollectionDependencies();

            serviceCollection.AddScoped <HttpMessageHandler>(provider => CreateMockedHttpClientHandler());

            var jwtAuthorizationConfig = new JwtAuthorization
            {
                JwkUrl             = "https://some-example-site.com",
                JwtValidationRules = new JwtValidationRules()
                {
                    ClientId           = "smittestopp",
                    SupportedAlgorithm = "RS256",
                    Issuer             = "https://dev-smittestopp-verification.azurewebsites.net"
                }
            };

            serviceCollection.AddSingleton(jwtAuthorizationConfig);

            serviceCollection.AddDbContext <DigNDB_SmittestopContext>(opts =>
                                                                      opts.UseInMemoryDatabase(Guid.NewGuid().ToString()));

            ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

            _jwtValidationService = serviceProvider.GetService <IJwtValidationService>();
        }
 public UploadKeysAuthorizationAttribute(IJwtValidationService jwtValidationService,
                                         IAnonymousTokenValidationService anonymousTokenValidationService,
                                         IOptions <AnonymousTokenKeyStoreConfiguration> anonymousTokenConfig)
 {
     _jwtValidationService            = jwtValidationService;
     _anonymousTokenValidationService = anonymousTokenValidationService;
     _anonymousTokenConfig            = anonymousTokenConfig.Value;
 }
예제 #3
0
 public AuthorizationAttribute(AppSettingsConfig appSettingsConfig, AuthOptions authOptions, IJwtValidationService jwtValidationService)
 {
     _appSettingsConfig    = appSettingsConfig;
     _authOptions          = authOptions;
     _jwtValidationService = jwtValidationService;
 }