public void ConfigureServices()

in packages/ekyc-api/src/ekyc-api/Startup.cs [52:162]


        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy(name: Globals.CorsPolicyName,
                    builder =>
                    {
                        builder.WithOrigins(AllowedOrigins)
                            .AllowAnyMethod()
                            .AllowAnyHeader()
                            .DisallowCredentials();
                    });
            });

            services.AddCors();

            //   services.AddSingleton<IAmazonCognitoIdentityProvider>(cognitoIdentityProvider);
            //   services.AddSingleton<CognitoUserPool>(cognitoUserPool);

            services.AddTransient<IConfiguration>(sp =>
            {
                IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
                configurationBuilder.AddJsonFile("appsettings.json");
                return configurationBuilder.Build();
            });

            AWSSDKHandler.RegisterXRayForAllServices();

            services.AddDefaultAWSOptions(Configuration.GetAWSOptions());

            services.ConfigServices();

            services.AddLogging();


            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version = "v1",
                    Title = "eKYC API",
                    Description = "An API for eKYC prototyping",
                    TermsOfService = new Uri("https://example.com/terms"),
                    Contact = new OpenApiContact
                    {
                        Name = "Amazon Web Services",
                        Email = "opensource-codeofconduct@amazon.com",
                        Url = new Uri("https://aws.amazon.com")
                    },
                    License = new OpenApiLicense
                    {
                        Name = "Use under Amazon Software License",
                        Url = new Uri("https://aws.amazon.com/asl/")
                    }
                });
                // Set the comments path for the Swagger JSON and UI.    
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });

            string strRegion = System.Environment.GetEnvironmentVariable("AWSRegion");
            string strCognitoUserPoolId = System.Environment.GetEnvironmentVariable("CognitoPoolId");
            string strCognitoAppClientId = System.Environment.GetEnvironmentVariable("CognitoAppClientId");

            /*  services.AddAuthentication(options =>
                  {
                      options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                      options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                      options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
                  })
                  .AddCookie()
                  .AddOpenIdConnect(options =>
                  {
                      options.ResponseType = "code"; 
                      options.MetadataAddress = $"https://cognito-idp.{strRegion}.amazonaws.com/{strCognitoUserPoolId}/.well-known/openid-configuration"; 
                      options.ClientId = strCognitoAppClientId;
                      options.SaveTokens = true;
  
                  });*/

            /* services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
             {
                 options.SaveToken = true;
                 options.TokenValidationParameters = new TokenValidationParameters
                 {
                     ValidateIssuerSigningKey = true,
                     IssuerSigningKeyResolver = (s, securityToken, identifier, parameters) =>
                     {
                         // get JsonWebKeySet from AWS
                         var json = new WebClient().DownloadString(parameters.ValidIssuer + "/.well-known/jwks.json");
                         // serialize the result
                         return System.Text.Json.JsonSerializer.Deserialize<JsonWebKeySet>(json)?.Keys;
                     },
                     ValidateIssuer = true,
                     ValidIssuer = $"https://cognito-idp.{strRegion}.amazonaws.com/{strCognitoUserPoolId}",
                     ValidateLifetime = true,
                     LifetimeValidator = (before, expires, token, param) => expires > DateTime.UtcNow,
                     ValidateAudience = true,
                     ValidAudience = System.Environment.GetEnvironmentVariable("CognitoAppClientId")
                 };
             });*/

            services.AddControllers();

            var serviceProvider = services.BuildServiceProvider();

            //DocumentDefinition.ServiceProvider = serviceProvider;

            S3Utils.ServiceProvider = serviceProvider;
        }