public TwitterAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app, TwitterAuthenticationOptions options) : base(next, options) { this._logger = AppBuilderLoggerExtensions.CreateLogger <TwitterAuthenticationMiddleware>(app); if (string.IsNullOrWhiteSpace(Options.ConsumerSecret)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Microsoft.Owin.Resources.Exception_OptionMustBeProvided:{0}", new object[] { "ConsumerSecret" })); } if (string.IsNullOrWhiteSpace(Options.ConsumerKey)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Microsoft.Owin.Resources.Exception_OptionMustBeProvided:{0}", new object[] { "ConsumerKey" })); } if (Options.Provider == null) { Options.Provider = new TwitterAuthenticationProvider(); } if (Options.StateDataFormat == null) { IDataProtector protector = AppBuilderExtensions.CreateDataProtector(app, new string[] { typeof(TwitterAuthenticationMiddleware).FullName, Options.AuthenticationType, "v1" }); Options.StateDataFormat = new SecureDataFormat <RequestToken>(Serializers.RequestToken, protector, TextEncodings.Base64Url); } if (string.IsNullOrEmpty(Options.SignInAsAuthenticationType)) { Options.SignInAsAuthenticationType = AppBuilderSecurityExtensions.GetDefaultSignInAsAuthenticationType(app); } this._httpClient = new HttpClient(ResolveHttpMessageHandler(Options)); this._httpClient.Timeout = Options.BackchannelTimeout; this._httpClient.MaxResponseContentBufferSize = 0xa00000L; this._httpClient.DefaultRequestHeaders.Accept.ParseAdd("*/*"); this._httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft Owin Twitter middleware"); this._httpClient.DefaultRequestHeaders.ExpectContinue = false; }
/// <summary> /// Initializes a <see cref="TripItAuthenticationMiddleware"/> /// </summary> /// <param name="next">The next middleware in the OWIN pipeline to invoke</param> /// <param name="app">The OWIN application</param> /// <param name="options">Configuration options for the middleware</param> public TripItAuthenticationMiddleware( OwinMiddleware next, IAppBuilder app, TripItAuthenticationOptions options) : base(next, options) { _logger = app.CreateLogger <TripItAuthenticationMiddleware>(); if (string.IsNullOrWhiteSpace(Options.ConsumerSecret)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, "ConsumerSecret")); } if (string.IsNullOrWhiteSpace(Options.ConsumerKey)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, "ConsumerKey")); } if (Options.Provider == null) { Options.Provider = new TripItAuthenticationProvider(); } if (Options.StateDataFormat == null) { IDataProtector dataProtector = app.CreateDataProtector( typeof(TripItAuthenticationMiddleware).FullName, Options.AuthenticationType, "v1"); Options.StateDataFormat = new SecureDataFormat <RequestToken>( Serializers.RequestToken, dataProtector, TextEncodings.Base64Url); } if (String.IsNullOrEmpty(Options.SignInAsAuthenticationType)) { Options.SignInAsAuthenticationType = AppBuilderSecurityExtensions.GetDefaultSignInAsAuthenticationType(app); } _httpClient = new HttpClient(ResolveHttpMessageHandler(Options)); _httpClient.Timeout = Options.BackchannelTimeout; _httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB _httpClient.DefaultRequestHeaders.Accept.ParseAdd("*/*"); _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft Owin TripIt middleware"); _httpClient.DefaultRequestHeaders.ExpectContinue = false; }
public SinaAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app, SinaAuthenticationOptions options) : base(next, options) { this._logger = AppBuilderLoggerExtensions.CreateLogger <SinaAuthenticationMiddleware>(app); if (options.Provider == null) { options.Provider = new SinaAuthenticationProvider(); } if (this.Options.StateDataFormat == null) { this.Options.StateDataFormat = new PropertiesDataFormat(app.CreateDataProtector(typeof(SinaAuthenticationMiddleware).FullName, this.Options.AuthenticationType, "v1")); } if (string.IsNullOrEmpty(this.Options.SignInAsAuthenticationType)) { this.Options.SignInAsAuthenticationType = AppBuilderSecurityExtensions.GetDefaultSignInAsAuthenticationType(app); } this._httpClient = new HttpClient(ResolveHttpMessageHandler(this.Options)); this._httpClient.MaxResponseContentBufferSize = 10485760L; }