Exemple #1
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);
        }
Exemple #2
0
        public AntiForgery([NotNull] IClaimUidExtractor claimUidExtractor,
                           [NotNull] IDataProtectionProvider dataProtectionProvider,
                           [NotNull] IAntiForgeryAdditionalDataProvider additionalDataProvider,
                           [NotNull] IOptions <AntiForgeryOptions> antiforgeryOptions,
                           [NotNull] IHtmlEncoder htmlEncoder,
                           [NotNull] IOptions <DataProtectionOptions> dataProtectionOptions)
        {
            var config        = antiforgeryOptions.Options;
            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);
        }