-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathCasEvents.cs
41 lines (37 loc) · 1.76 KB
/
CasEvents.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
// ReSharper disable once CheckNamespace
namespace GSS.Authentication.CAS.AspNetCore
{
/// <summary>
/// Default CAS events implementation.
/// </summary>
public class CasEvents : RemoteAuthenticationEvents
{
/// <summary>
/// Gets or sets the function that is invoked when the CreatingTicket method is invoked.
/// </summary>
public Func<CasCreatingTicketContext, Task> OnCreatingTicket { get; set; } = _ => Task.CompletedTask;
/// <summary>
/// Gets or sets the delegate that is invoked when the RedirectToAuthorizationEndpoint method is invoked.
/// </summary>
public Func<RedirectContext<CasAuthenticationOptions>, Task> OnRedirectToAuthorizationEndpoint { get; set; } = context =>
{
context.Response.Redirect(context.RedirectUri);
return Task.CompletedTask;
};
/// <summary>
/// Invoked after the provider successfully authenticates a user.
/// </summary>
/// <param name="context"></param>
/// <returns>A <see cref="Task"/> representing the completed operation.</returns>
public virtual Task CreatingTicket(CasCreatingTicketContext context) => OnCreatingTicket(context);
/// <summary>
/// Called when a Challenge causes a redirect to authorize endpoint in the OAuth handler.
/// </summary>
/// <param name="context">Contains redirect URI and <see cref="AuthenticationProperties"/> of the challenge.</param>
/// <returns></returns>
public virtual Task RedirectToAuthorizationEndpoint(RedirectContext<CasAuthenticationOptions> context) => OnRedirectToAuthorizationEndpoint(context);
}
}