Esempio n. 1
0
 public static CheckoutApi ConfiguredFromOptions(CheckoutApiOptions options)
 {
     return(CheckoutApi.Create(
                secretKey: options.SecretKey,
                publicKey: options.PublicKey,
                uri: options.GatewayUri
                ));
 }
Esempio n. 2
0
 public ConfigController(
     ILogger logger,
     IHostingEnvironment hostingEnvironment,
     IOptions <OktaWebClientOptions> options,
     IOptions <CheckoutApiOptions> apiOptions
     )
 {
     _logger             = logger?.ForContext <ConfigController>() ?? throw new ArgumentNullException(nameof(logger));
     _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
     _options            = options?.Value ?? throw new ArgumentNullException(nameof(options));
     _apiOptions         = apiOptions?.Value ?? throw new ArgumentNullException(nameof(apiOptions));
 }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = OktaDefaults.ApiAuthenticationScheme;
                options.DefaultChallengeScheme    = OktaDefaults.ApiAuthenticationScheme;
                options.DefaultSignInScheme       = OktaDefaults.ApiAuthenticationScheme;
            })
            .AddOktaWebApi(new OktaWebApiOptions()
            {
                OktaDomain = Configuration["Okta:OktaDomain"]
            });

            services.AddOptions()
            .Configure <OktaWebClientOptions>(Configuration.GetSection("OktaWebClient"))
            .Configure <CheckoutApiOptions>(Configuration.GetSection("CheckoutApiOptions"));

            services
            .AddMvcCore()
            .AddAuthorization()
            .AddJsonFormatters(serializerOptions =>
            {
                serializerOptions.NullValueHandling = NullValueHandling.Ignore;
                serializerOptions.ContractResolver  = new DefaultContractResolver()
                {
                    NamingStrategy = new SnakeCaseNamingStrategy()
                };
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            ConfigureHealthChecks(services);

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist/ClientApp";
            });


            var apiOptions = new CheckoutApiOptions();

            Configuration.Bind("CheckoutApiOptions", apiOptions);

            services.AddHttpClient();
            services.AddSignalR();
            services.AddTransient <HttpClient>(provider => provider.GetService <System.Net.Http.IHttpClientFactory>().CreateClient());
            services.AddSingleton <CheckoutApi>(_ => CheckoutApiFactory.ConfiguredFromOptions(apiOptions));
            services.AddSingleton <CheckoutApiOptions>(_ => apiOptions);
        }
Esempio n. 4
0
 public CheckoutController(IOptions <CheckoutApiOptions> apiOptions, CheckoutApi api, HttpClient client)
 {
     this.apiOptions = apiOptions.Value ?? throw new ArgumentNullException(nameof(apiOptions));
     this.api        = api ?? throw new ArgumentNullException(nameof(api));
     this.client     = client ?? throw new ArgumentNullException(nameof(client));
 }