예제 #1
0
파일: AntiForgery.cs 프로젝트: Nakro/Mvc
 public AntiForgery([NotNull] IClaimUidExtractor claimUidExtractor,
                    [NotNull] IDataProtectionProvider dataProtectionProvider,
                    [NotNull] IAntiForgeryAdditionalDataProvider additionalDataProvider,
                    [NotNull] IOptionsAccessor<MvcOptions> mvcOptions)
 {
     var config = mvcOptions.Options.AntiForgeryOptions;
     var serializer = new AntiForgeryTokenSerializer(dataProtectionProvider.CreateProtector(_purpose));
     var tokenStore = new AntiForgeryTokenStore(config, serializer);
     var tokenProvider = new TokenProvider(config, claimUidExtractor, additionalDataProvider);
     _worker = new AntiForgeryWorker(serializer, config, tokenStore, tokenProvider, tokenProvider);
 }
예제 #2
0
        public AntiForgery([NotNull] IClaimUidExtractor claimUidExtractor,
                           [NotNull] IDataProtectionProvider dataProtectionProvider,
                           [NotNull] IAntiForgeryAdditionalDataProvider additionalDataProvider,
                           [NotNull] IOptions <MvcOptions> mvcOptions)
        {
            var config        = mvcOptions.Options.AntiForgeryOptions;
            var serializer    = new AntiForgeryTokenSerializer(dataProtectionProvider.CreateProtector(_purpose));
            var tokenStore    = new AntiForgeryTokenStore(config, serializer);
            var tokenProvider = new TokenProvider(config, claimUidExtractor, additionalDataProvider);

            _worker = new AntiForgeryWorker(serializer, config, tokenStore, tokenProvider, tokenProvider);
        }
예제 #3
0
        public AntiForgery([NotNull] IClaimUidExtractor claimUidExtractor,
                           [NotNull] IDataProtectionProvider dataProtectionProvider,
                           [NotNull] IAntiForgeryAdditionalDataProvider additionalDataProvider,
                           [NotNull] IOptions<MvcOptions> mvcOptions,
                           [NotNull] IHtmlEncoder htmlEncoder,
                           [NotNull] IOptions<DataProtectionOptions> dataProtectionOptions)
        {
            var config = mvcOptions.Options.AntiForgeryOptions;
            var applicationId = dataProtectionOptions.Options.ApplicationDiscriminator ?? string.Empty;
            config.CookieName = config.CookieName ?? ComputeCookieName(applicationId);

            var serializer = new AntiForgeryTokenSerializer(dataProtectionProvider.CreateProtector(_purpose));
            var tokenStore = new AntiForgeryTokenStore(config, serializer);
            var tokenProvider = new AntiForgeryTokenProvider(config, claimUidExtractor, additionalDataProvider);
            _worker = new AntiForgeryWorker(serializer, config, tokenStore, tokenProvider, tokenProvider, htmlEncoder);
        }
예제 #4
0
        public AntiForgery([NotNull] IClaimUidExtractor claimUidExtractor,
                           [NotNull] IDataProtectionProvider dataProtectionProvider,
                           [NotNull] IAntiForgeryAdditionalDataProvider additionalDataProvider,
                           [NotNull] IOptions <MvcOptions> mvcOptions,
                           [NotNull] IHtmlEncoder htmlEncoder,
                           [NotNull] IOptions <DataProtectionOptions> dataProtectionOptions)
        {
            var config        = mvcOptions.Options.AntiForgeryOptions;
            var applicationId = dataProtectionOptions.Options.ApplicationDiscriminator ?? string.Empty;

            config.CookieName = config.CookieName ?? ComputeCookieName(applicationId);

            var serializer    = new AntiForgeryTokenSerializer(dataProtectionProvider.CreateProtector(_purpose));
            var tokenStore    = new AntiForgeryTokenStore(config, serializer);
            var tokenProvider = new TokenProvider(config, claimUidExtractor, additionalDataProvider);

            _worker = new AntiForgeryWorker(serializer, config, tokenStore, tokenProvider, tokenProvider, htmlEncoder);
        }