Exemplo n.º 1
0
        /// <summary>
        /// Gets the client secret for Cognito App Client.
        /// </summary>
        /// <param name="cognitoClientSecretData">The Cognito Client Secret Data.</param>
        /// <returns>The Client Secret.</returns>
        public async Task <string> GetClientSecretForAppClientAsync(CognitoClient cognitoClientSecretData)
        {
            var request = new DescribeUserPoolClientRequest
            {
                ClientId   = cognitoClientSecretData.ClientId,
                UserPoolId = cognitoClientSecretData.UserPoolId
            };
            var response = await this._amazonCognitoIdentityProvider.DescribeUserPoolClientAsync(request).ConfigureAwait(false);

            return(response.UserPoolClient.ClientSecret);
        }
Exemplo n.º 2
0
        public async Task GetTokenWithSessionId_VerifyTokenAndSessionId()
        {
            var configSettings = Options.Create(GetTestConfigSettings());
            var httpClient     = new HttpClient
            {
                Timeout = TimeSpan.FromSeconds(configSettings.Value.TokenRequestTimespanSecs)
            };
            var amazonCognitoIdentityProviderClient = new AmazonCognitoIdentityProviderClient();
            var awsCognitoHelper             = new AWSCognitoHelper(httpClient, amazonCognitoIdentityProviderClient);
            var awsCognitoClientSecretHelper = new AWSCognitoClientSecretHelper(configSettings);
            var fireBaseHelper = new FirebaseHelper();
            var jwtTokenHelper = new JwtTokenHelper(configSettings, httpClient);

            var client = configSettings.Value.Clients.First();
            var cognitoClientSecretData = new CognitoClient
            {
                ClientId   = client.Cognito.ClientApp.ClientId,
                UserPoolId = client.Cognito.ClientApp.UserPoolId
            };

            MockingHelper.SetFieldValue(awsCognitoClientSecretHelper, "_cognitoClientSecretDataArr", new[] { cognitoClientSecretData });
            cognitoClientSecretData.ClientSecret = await awsCognitoHelper.GetClientSecretForAppClientAsync(cognitoClientSecretData);

            var logger     = Mock.Of <ILogger <TokenController> >();
            var controller = new TokenController(configSettings,
                                                 logger,
                                                 awsCognitoHelper,
                                                 awsCognitoClientSecretHelper,
                                                 fireBaseHelper,
                                                 jwtTokenHelper)
            {
                CurrentClient = new Client
                {
                    ConfigClientData = client,
                    ExtraClientData  = new ExtraClientData()
                }
            };

            controller.CurrentClient.ConfigClientData.Cognito.ClientApp.ClientSecret = cognitoClientSecretData.ClientSecret;
            await TestIdToken(true, controller, jwtTokenHelper).ConfigureAwait(false);
        }
Exemplo n.º 3
0
 public AuthService(CognitoClient config, IContractProvider <RootObject, CognitoContractResolver> provider)
 {
     _config   = config;
     _provider = provider;
 }
 public AuthServiceAsyncFactory(CognitoClient config, IContractProvider <RootObject, CognitoContractResolver> provider)
 {
     _auth = new AuthService(config, provider);
 }