Beispiel #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOptions();
            services.Configure <AspNetCore.RequestsSignatureOptions>(options =>
            {
                options.Clients.Add(new RequestsSignatureClientOptions
                {
                    ClientId     = DefaultClientId,
                    ClientSecret = DefaultClientSecret,
                });
                var customClient = new RequestsSignatureClientOptions
                {
                    ClientId     = CustomClientId,
                    ClientSecret = CustomClientSecret,
                };
                foreach (var componentSource in CustomSignatureBodySourceComponents)
                {
                    customClient.SignatureBodySourceComponents.Add(componentSource);
                }

                options.Clients.Add(customClient);
            });
            services.AddMemoryCache();
            services.AddSingleton <INonceRepository, MemoryCacheNonceRepository>();
            services.AddRequestsSignatureValidation();
#if NETCOREAPP2_2
            services.AddMvc();
#endif

#if NETCOREAPP3_0
            services.AddControllers();
#endif
        }
Beispiel #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOptions();
            services.Configure <AspNetCore.RequestsSignatureOptions>(options =>
            {
                options.Clients.Add(new RequestsSignatureClientOptions
                {
                    ClientId     = DefaultClientId,
                    ClientSecret = DefaultClientSecret,
                });
                var customClient = new RequestsSignatureClientOptions
                {
                    ClientId     = CustomClientId,
                    ClientSecret = CustomClientSecret,
                };
                foreach (var componentSource in CustomSignatureBodySourceComponents)
                {
                    customClient.SignatureBodySourceComponents.Add(componentSource);
                }

                options.Clients.Add(customClient);
            });
            services.AddRequestsSignatureValidation();
#if NETCOREAPP2_2
            services.AddMvc();
#endif

#if NETCOREAPP3_0
            services.AddControllers();
#endif

            services
            .AddAuthentication(RequestsSignatureAuthenticationConstants.AuthenticationScheme)
            .AddRequestsSignature();
        }