// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authentication.OAuth
{
///
/// Default implementation.
///
public class OAuthEvents : RemoteAuthenticationEvents, IOAuthEvents
{
///
/// Gets or sets the function that is invoked when the CreatingTicket method is invoked.
///
public Func OnCreatingTicket { get; set; } = context => TaskCache.CompletedTask;
///
/// Gets or sets the delegate that is invoked when the RedirectToAuthorizationEndpoint method is invoked.
///
public Func OnRedirectToAuthorizationEndpoint { get; set; } = context =>
{
context.Response.Redirect(context.RedirectUri);
return TaskCache.CompletedTask;
};
///
/// Invoked after the provider successfully authenticates a user.
///
/// Contains information about the login session as well as the user .
/// A representing the completed operation.
public virtual Task CreatingTicket(OAuthCreatingTicketContext context) => OnCreatingTicket(context);
///
/// Called when a Challenge causes a redirect to authorize endpoint in the OAuth middleware.
///
/// Contains redirect URI and of the challenge.
public virtual Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) => OnRedirectToAuthorizationEndpoint(context);
}
}