This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
/
ChallengeResult.cs
65 lines (55 loc) · 1.95 KB
/
ChallengeResult.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// 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.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Mvc.Actions;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc
{
public class ChallengeResult : ActionResult
{
public ChallengeResult()
: this(new string[] { })
{
}
public ChallengeResult(string authenticationScheme)
: this(new[] { authenticationScheme })
{
}
public ChallengeResult(IList<string> authenticationSchemes)
: this(authenticationSchemes, properties: null)
{
}
public ChallengeResult(AuthenticationProperties properties)
: this(new string[] { }, properties)
{
}
public ChallengeResult(string authenticationScheme, AuthenticationProperties properties)
: this(new[] { authenticationScheme }, properties)
{
}
public ChallengeResult(IList<string> authenticationSchemes, AuthenticationProperties properties)
{
AuthenticationSchemes = authenticationSchemes;
Properties = properties;
}
public IList<string> AuthenticationSchemes { get; set; }
public AuthenticationProperties Properties { get; set; }
public override async Task ExecuteResultAsync([NotNull] ActionContext context)
{
var auth = context.HttpContext.Authentication;
if (AuthenticationSchemes.Count > 0)
{
foreach (var scheme in AuthenticationSchemes)
{
await auth.ChallengeAsync(scheme, Properties);
}
}
else
{
await auth.ChallengeAsync(Properties);
}
}
}
}