Repository navigation
Expand file tree
/
Copy pathOpenIdConnectAuthenticationHandlerForTestingAuthenticate.cs
More file actions
56 lines (49 loc) · 2.08 KB
/
Copy pathOpenIdConnectAuthenticationHandlerForTestingAuthenticate.cs
File metadata and controls
56 lines (49 loc) · 2.08 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Open Technologies, Inc. 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.AspNet.Authentication.OpenIdConnect;
namespace Microsoft.AspNet.Authentication.Tests.OpenIdConnect
{
/// <summary>
/// Allows for custom processing of ApplyResponseChallenge, ApplyResponseGrant and AuthenticateCore
/// </summary>
public class OpenIdConnectAuthenticationHandlerForTestingAuthenticate : OpenIdConnectAuthenticationHandler
{
private Func<Task> _applyResponseChallenge;
private Func<Task> _applyResponseGrant;
private Func<Task<AuthenticationTicket>> _authenticationCore;
public OpenIdConnectAuthenticationHandlerForTestingAuthenticate(Func<Task> applyResponseChallenge = null, Func<Task> applyResponseGrant = null, Func<Task<AuthenticationTicket>> authenticationCore = null )
: base()
{
_applyResponseChallenge = applyResponseChallenge;
_applyResponseGrant = applyResponseGrant;
_authenticationCore = authenticationCore;
}
protected override async Task ApplyResponseChallengeAsync()
{
if (_applyResponseChallenge != null)
await _applyResponseChallenge();
else
await base.ApplyResponseChallengeAsync();
}
protected override async Task ApplyResponseGrantAsync()
{
if (_applyResponseGrant != null)
await _applyResponseGrant();
else
await base.ApplyResponseGrantAsync();
}
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
{
if (_authenticationCore != null)
return await _authenticationCore();
else
return await base.AuthenticateCoreAsync();
}
public override bool ShouldHandleScheme(string authenticationScheme)
{
return true;
}
}
}