/// <summary> /// Creates a new context object. /// </summary> /// <param name="context">The HTTP request context.</param> /// <param name="properties">The authentication properties of the challenge.</param> /// <param name="redirectUri">The initial redirect URI.</param> public OAuthRedirectToAuthorizationContext(HttpContext context, OAuthOptions options, AuthenticationProperties properties, string redirectUri) : base(context) { RedirectUri = redirectUri; Properties = properties; Options = options; }
/// <summary> /// Initializes a new <see cref="OAuthCreatingTicketContext"/>. /// </summary> /// <param name="context">The HTTP environment.</param> /// <param name="options">The options used by the authentication middleware.</param> /// <param name="backchannel">The HTTP client used by the authentication middleware</param> /// <param name="tokens">The tokens returned from the token endpoint.</param> public OAuthCreatingTicketContext( HttpContext context, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens) : this(context, options, backchannel, tokens, user : new JObject()) { }
/// <summary> /// Initializes a new <see cref="OAuthCreatingTicketContext"/>. /// </summary> /// <param name="context">The HTTP environment.</param> /// <param name="options">The options used by the authentication middleware.</param> /// <param name="backchannel">The HTTP client used by the authentication middleware</param> /// <param name="tokens">The tokens returned from the token endpoint.</param> public OAuthCreatingTicketContext( HttpContext context, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens) : this(context, options, backchannel, tokens, user: new JObject()) { }
/// <summary> /// Authenticate users using OAuth. /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/> passed to the configure method.</param> /// <param name="configureOptions">Configures the middleware options.</param> /// <returns>The updated <see cref="IApplicationBuilder"/>.</returns> public static IApplicationBuilder UseOAuthAuthentication([NotNull] this IApplicationBuilder app, [NotNull] Action<OAuthOptions> configureOptions) { var options = new OAuthOptions(); if (configureOptions != null) { configureOptions(options); } return app.UseOAuthAuthentication(options); }
/// <summary> /// Adds the <see cref="OAuthMiddleware{TOptions}"/> middleware to the specified <see cref="IApplicationBuilder"/>, which enables OAuth 2.0 authentication capabilities. /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/> to add the middleware to.</param> /// <param name="options">A <see cref="OAuthOptions"/> that specifies options for the middleware.</param> /// <returns>A reference to this instance after the operation has completed.</returns> public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app, OAuthOptions options) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } return app.UseMiddleware<OAuthMiddleware<OAuthOptions>>(options); }
/// <summary> /// Adds the <see cref="OAuthMiddleware{TOptions}"/> middleware to the specified <see cref="IApplicationBuilder"/>, which enables OAuth 2.0 authentication capabilities. /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/> to add the middleware to.</param> /// <param name="configureOptions">An action delegate to configure the provided <see cref="OAuthOptions"/>.</param> /// <returns>A reference to this instance after the operation has completed.</returns> public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app, Action<OAuthOptions> configureOptions) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (configureOptions == null) { throw new ArgumentNullException(nameof(configureOptions)); } var options = new OAuthOptions(); if (configureOptions != null) { configureOptions(options); } return app.UseOAuthAuthentication(options); }
/// <summary> /// Initializes a new <see cref="OAuthCreatingTicketContext"/>. /// </summary> /// <param name="context">The HTTP environment.</param> /// <param name="options">The options used by the authentication middleware.</param> /// <param name="backchannel">The HTTP client used by the authentication middleware</param> /// <param name="tokens">The tokens returned from the token endpoint.</param> /// <param name="user">The JSON-serialized user.</param> public OAuthCreatingTicketContext( HttpContext context, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens, JObject user) : base(context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (backchannel == null) { throw new ArgumentNullException(nameof(backchannel)); } if (tokens == null) { throw new ArgumentNullException(nameof(tokens)); } if (user == null) { throw new ArgumentNullException(nameof(user)); } TokenResponse = tokens; Backchannel = backchannel; User = user; Options = options; }