예제 #1
0
 public AuthServerConnect(HttpClient httpClient, IConfiguration config, IDiscoveryCache discoveryCache, ILogger <AuthServerConnect> logger)
 {
     _httpClient     = httpClient;
     _config         = config;
     _discoveryCache = discoveryCache;
     _logger         = logger;
 }
예제 #2
0
 public AutomaticSilentRenewMiddleware(IDiscoveryCache discoveryCache, RequestDelegate next, IOptions <AuthConfiguration> authConfig)
 {
     _next           = next;
     _clientId       = authConfig.Value.ClientId;
     _clientSecret   = authConfig.Value.ClientSecret;
     _discoveryCache = discoveryCache;
 }
예제 #3
0
 public AssessmentController(IDiscoveryCache discoveryCache, ProdDbContext dbContext, IReferenceService referenceService, IHubContext <MessageHub> hubContext) : base(discoveryCache, dbContext)
     //public AssessmentController(IDiscoveryCache discoveryCache, ProdDbContext dbContext, IReferenceService referenceService) : base(discoveryCache, dbContext)
 {
     _dbContext        = dbContext;
     _referenceService = referenceService;
     _hubContext       = hubContext;
 }
예제 #4
0
 public TokenRefresher(HttpClient httpClient,
                       IDiscoveryCache discoveryCache,
                       ILogger <TokenRefresher> logger)
 {
     _httpClient     = httpClient;
     _discoveryCache = discoveryCache;
     _logger         = logger;
 }
예제 #5
0
 public BouncerService(
     IDiscoveryCache discoveryCache,
     ILogger <BouncerService> logger,
     IHttpClientFactory httpClientFactory)
 {
     this.discoveryCache    = discoveryCache;
     this.logger            = logger;
     this.httpClientFactory = httpClientFactory;
 }
예제 #6
0
 public TenantServices(
     IHttpClientFactory httpClientFactory,
     Tenant tenant,
     IDiscoveryCache discoveryCache)
 {
     _httpClientFactory = httpClientFactory;
     _tenant            = tenant;
     _discoveryCache    = discoveryCache;
 }
 public AccessTokenValidationFilter(
     IMemoryCache memoryCache,
     IDiscoveryCache discoveryCache,
     IHttpClientFactory httpClientFactory)
 {
     this.memoryCache       = memoryCache;
     this.discoveryCache    = discoveryCache;
     this.httpClientFactory = httpClientFactory;
 }
예제 #8
0
 public PostConfigureTokenHandlerOptions(
     IHttpClientFactory httpClientFactory,
     IDistributedCache distributedCache = null,
     IDiscoveryCache discoveryCache     = null)
 {
     _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
     _distributedCache  = distributedCache;
     _discoveryCache    = discoveryCache;
 }
예제 #9
0
 public AccountController(ILogger <AccountController> logger, HttpClient httpClient,
                          IDiscoveryCache discoveryCache, IConfiguration configuration, ISendingManager sendingManager, ITagReplacer tagReplacer)
 {
     _logger         = logger;
     _httpClient     = httpClient;
     _discoveryCache = discoveryCache;
     _configuration  = configuration;
     _sendingManager = sendingManager;
     _tagReplacer    = tagReplacer;
 }
 public ConnectController(
     ILogFactory logFactory,
     IUserSessionManager userSessionManager,
     IDiscoveryCache discoveryCache
     )
 {
     _log = logFactory.CreateLog(this);
     _userSessionManager = userSessionManager;
     _discoveryCache     = discoveryCache;
 }
예제 #11
0
 public Worker(
     IConfiguration configuration,
     ILogger <Worker> logger
     )
 {
     _configuration = configuration;
     _logger        = logger;
     _disco         = new DiscoveryCache(_configuration.GetValue <string>("IdentityServer"));
     _httpClient    = new HttpClient();
 }
예제 #12
0
 private void Setup(IDiscoveryCache cache)
 {
     _restClient = new MockRestClient();
     _cache      = cache;
     _discovery  = new MobileConnect.Discovery.Discovery(cache, this._restClient);
     _config     = new MobileConnectConfig()
     {
         ClientId = "1234567890", ClientSecret = "1234567890", DiscoveryUrl = "http://localhost:8080/v2/discovery/"
     };
 }
예제 #13
0
        async Task <IDiscoveryCache> GetDiscoveryCacheAsync()
        {
            if (_discoveryCache == null)
            {
                var(fresh, value) = await GetValueAsync();

                _discoveryCache = new DiscoveryCache(value.Authority, () => _httpClientFactory.CreateClient());
            }
            return(_discoveryCache);
        }
예제 #14
0
 public TokenRefresher(
     HttpClient httpClient,
     IDiscoveryCache discoveryCache,
     AuthServiceSettings authServiceSettings,
     ILogger <TokenRefresher> logger)
 {
     _httpClient          = httpClient;
     _discoveryCache      = discoveryCache;
     _authServiceSettings = authServiceSettings;
     _logger = logger;
 }
예제 #15
0
 public RealtimeClient(
     IConfiguration configuration,
     ILogger <RealtimeClient> logger,
     IMediator mediator
     )
 {
     _configuration = configuration;
     _logger        = logger;
     _mediator      = mediator;
     _disco         = new DiscoveryCache(_configuration.GetValue <string>("IdentityServer"));
 }
예제 #16
0
        internal TokenClient([NotNull] HttpClient client, [NotNull] ILogger <TokenClient> logger, [NotNull] TokenClientOptions tokenClientOptions, [NotNull] IDateTimeProvider dateTimeProvider)
        {
            _client             = client ?? throw new ArgumentNullException(nameof(client));
            _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
            _tokenClientOptions = tokenClientOptions ?? throw new ArgumentNullException(nameof(tokenClientOptions));
            _dateTimeProvider   = dateTimeProvider ?? throw new ArgumentNullException(nameof(dateTimeProvider));

            _discoveryCache = new DiscoveryCache(_tokenClientOptions.AuthorityUrl, () => client, new DiscoveryPolicy
            {
                RequireHttps = _tokenClientOptions.RequireHttps
            });
        }
예제 #17
0
        //[TestCase("r2-ref")]
        public async Task MobileConnectWebInterfaceShouldWorkEndToEnd(string configKey)
        {
            RestClient      restClient     = new RestClient();
            IDiscoveryCache cache          = null;
            IDiscovery      discovery      = new GSMA.MobileConnect.Discovery.Discovery(cache, restClient);
            IAuthentication authentication = new GSMA.MobileConnect.Authentication.Authentication(restClient);

            var testConfig             = TestConfig.GetConfig(configKey);
            MobileConnectConfig config = new MobileConnectConfig()
            {
                DiscoveryUrl = testConfig.DiscoveryUrl,
                ClientId     = testConfig.ClientId,
                ClientSecret = testConfig.ClientSecret,
                RedirectUrl  = testConfig.RedirectUrl
            };

            MobileConnectRequestOptions blankOptions  = new MobileConnectRequestOptions();
            MobileConnectWebInterface   mobileConnect = new MobileConnectWebInterface(discovery, authentication, config);

            //Attempt discovery
            var request = new HttpRequestMessage();
            var status  = await mobileConnect.AttemptDiscoveryAsync(request, testConfig.ValidMSISDN, null, null, true, blankOptions);

            Assert.AreEqual(MobileConnectResponseType.StartAuthorization, status.ResponseType);

            var discoveryResponse = status.DiscoveryResponse;
            var encryptedMsisdn   = status.DiscoveryResponse.ResponseData.subscriber_id;
            var state             = "zmxncbvalskdjfhgqpwoeiruty";
            var nonce             = "qpwoeirutyalskdjfhgzmxncbv";

            //Start Authorization
            request = new HttpRequestMessage();
            status  = mobileConnect.StartAuthorization(request, discoveryResponse, encryptedMsisdn, state, nonce, blankOptions);

            Assert.AreEqual(MobileConnectResponseType.Authorization, status.ResponseType);

            //Inconclusive at this point because the sandbox no longer allows us to follow redirects easily
            Assert.Inconclusive("Can't follow redirects in sandbox");

            //Authorization
            request = new HttpRequestMessage();
            var redirectedUrl = await FollowRedirects(status.Url, _basicRequestHeaders, testConfig.RedirectUrl);

            Assert.That(() => redirectedUrl.AbsoluteUri.StartsWith(testConfig.RedirectUrl));
            Assert.AreEqual(state, HttpUtils.ExtractQueryValue(redirectedUrl.Query, "state"));

            //Handle auth redirect and request token
            request = new HttpRequestMessage();
            status  = await mobileConnect.HandleUrlRedirectAsync(request, redirectedUrl, discoveryResponse, state, nonce);

            Assert.AreEqual(MobileConnectResponseType.Complete, status.ResponseType);
            Assert.IsNotEmpty(status.TokenResponse.ResponseData.AccessToken);
        }
예제 #18
0
        public PortalCryptoAlgorithm(
            IHttpContextAccessor httpContextAccessor,
            IDiscoveryCache discoveryCache,
            IDataProtectionProvider dataProtectionProvider,
            EncryptionSetting encryptionSetting)
        {
            _httpContextAccessor = httpContextAccessor;
            _discoveryCache      = discoveryCache;
            _encryptionSetting   = encryptionSetting;

            _dataProtector = dataProtectionProvider.CreateProtector(nameof(PortalCryptoAlgorithm));
        }
 public ServiceRegistryCacheAdapter(IServiceRegistry primaryRegistry, IDiscoveryCache cache, int cacheRefreshIntervalMinutes)
 {
     _PrimaryRegistry = primaryRegistry;
     _PersistentCache = cache;
     try {
         _CacheEntries = _PersistentCache.LoadAllEntries().ToList();
     }
     catch {
         _CacheEntries = new List <DiscoveryCacheEntry>();
     }
     _CacheRefreshIntervalMinutes = cacheRefreshIntervalMinutes;
 }
 public PrivateKeyJwtTokenHandler(ILogger <PrivateKeyJwtTokenHandler> logger,
                                  IPrivateKeyJwtGenerator tokenGenerator,
                                  IHttpClientFactory httpClientFactory,
                                  IDiscoveryCache discoveryCache,
                                  IClientAccessTokenCache clientAccessTokenCache)
 {
     _logger                 = logger;
     _tokenGenerator         = tokenGenerator;
     _httpClientFactory      = httpClientFactory;
     _discoveryCache         = discoveryCache;
     _clientAccessTokenCache = clientAccessTokenCache;
 }
        public AnonymousAccessTokenProvider(
            IDistributedCache distributedCache,
            IDiscoveryCache discoveryCache,
            HttpClient httpClient,
            IdentitySetting identitySetting)
        {
            _distributedCache = distributedCache;
            _discoveryCache   = discoveryCache;
            _httpClient       = httpClient;
            _identitySetting  = identitySetting;

            Key += Environment.GetEnvironmentVariable("COMPUTERNAME");
        }
예제 #22
0
        public JwtValidatorService(AuthConfig authConfig, IDiscoveryCache b2CDiscoveryCache, ILogger <JwtValidatorService> logger, IHttpContextAccessor httpContextAccessor)
        {
            this.b2CDiscoveryCache = b2CDiscoveryCache;
            this.logger            = logger;
            this.currentContext    = httpContextAccessor.HttpContext;
            this.handler           = new JwtSecurityTokenHandler();

            this.tokenValidationParameters = new TokenValidationParameters
            {
                ValidIssuer         = authConfig.Authority,
                ValidAudiences      = new[] { authConfig.Audience },
                RequireSignedTokens = true
            };
        }
        public void Setup(RestClient client)
        {
            _restClient     = client;
            _cache          = new ConcurrentDiscoveryCache();
            _discovery      = new GSMA.MobileConnect.Discovery.Discovery(_cache, _restClient);
            _authentication = new GSMA.MobileConnect.Authentication.Authentication(_restClient);

            _config = new MobileConnectConfig()
            {
                DiscoveryUrl = _testConfig.DiscoveryUrl,
                ClientId     = _testConfig.ClientId,
                ClientSecret = _testConfig.ClientSecret,
                RedirectUrl  = _testConfig.RedirectUrl,
            };

            _mobileConnect = new MobileConnectInterface(_discovery, _authentication, _config);
        }
 public AccountController(
     SignInManager <AppUser> signInManager,
     UserManager <AppUser> userManager,
     IIdentityServerInteractionService interaction,
     IAuthenticationSchemeProvider schemeProvider,
     IClientStore clientStore,
     //IEventService events,
     IDiscoveryCache discoveryCache)
 {
     _userManager    = userManager;
     _interaction    = interaction;
     _schemeProvider = schemeProvider;
     _clientStore    = clientStore;
     //_events = events;
     this.discoveryCache = discoveryCache;
     _signInManager      = signInManager;
 }
 public CallbackController(
     IUserSessionManager userSessionManager,
     ILogFactory logFactory,
     IClientSessionsClient clientSessionsClient,
     IHttpClientFactory httpClientFactory,
     IDiscoveryCache discoveryCache,
     IroncladSettings ironcladSettings,
     ILykkeSessionManager lykkeSessionManager)
 {
     _clientSessionsClient = clientSessionsClient;
     _userSessionManager   = userSessionManager;
     _log = logFactory.CreateLog(this);
     _httpClientFactory   = httpClientFactory;
     _discoveryCache      = discoveryCache;
     _ironcladSettings    = ironcladSettings;
     _lykkeSessionManager = lykkeSessionManager;
 }
예제 #26
0
        public void Setup()
        {
            _restClient     = new RestClient();
            _cache          = new ConcurrentDiscoveryCache();
            _discovery      = new GSMA.MobileConnect.Discovery.Discovery(_cache, _restClient);
            _authentication = new GSMA.MobileConnect.Authentication.Authentication(_restClient);

            _testConfig = TestConfig.GetConfig(TestConfig.DEFAULT_TEST_CONFIG);
            _config     = new MobileConnectConfig()
            {
                DiscoveryUrl = _testConfig.DiscoveryUrl,
                ClientId     = _testConfig.ClientId,
                ClientSecret = _testConfig.ClientSecret,
                RedirectUrl  = _testConfig.RedirectUrl,
            };

            _mobileConnect = new MobileConnectWebInterface(_discovery, _authentication, _config);
        }
 public ResourcesController(
     IUserSessionManager userSessionManager,
     IUserSessionRepository userSessionRepository,
     IClientAccountClient clientAccountClient,
     IHttpClientFactory httpClientFactory,
     IDiscoveryCache discoveryCache,
     IClientSessionsClient clientSessionsClient,
     IroncladSettings ironcladSettings,
     LifetimeSettings lifetimeSettings,
     ILykkeSessionManager lykkeSessionManager)
 {
     _ironcladSettings      = ironcladSettings;
     _lifetimeSettings      = lifetimeSettings;
     _lykkeSessionManager   = lykkeSessionManager;
     _userSessionRepository = userSessionRepository;
     _clientAccountClient   = clientAccountClient;
     _userSessionManager    = userSessionManager;
     _httpClientFactory     = httpClientFactory;
     _discoveryCache        = discoveryCache;
     _clientSessionsClient  = clientSessionsClient;
 }
 public HomeController(IHttpClientFactory httpClientFactory, IDiscoveryCache discoveryCache)
 {
     _httpClientFactory = httpClientFactory;
     _discoveryCache    = discoveryCache;
 }
예제 #29
0
 public AuthorizeApiController(IDiscoveryCache discoveryCache, ProdDbContext dbContext)
 {
     _discoveryCache = discoveryCache;
     _dbContext      = dbContext;
 }
예제 #30
0
 public HomeController(ILogger <HomeController> logger, IHttpClientFactory httpClientFactory, IDiscoveryCache discoveryCache)
 {
     _logger            = logger;
     _httpClientFactory = httpClientFactory;
     _discoveryCache    = discoveryCache;
 }