Skip to content

Commit be67912

Browse files
author
DrEsteban
authored
Allowing AuthorizeForScopesAttribute to specify an alternate AuthenticationScheme name (#868)
1 parent f111f49 commit be67912

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Microsoft.Identity.Web/AuthorizeForScopesAttribute.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public class AuthorizeForScopesAttribute : ExceptionFilterAttribute
4343
/// </summary>
4444
public string? UserFlow { get; set; }
4545

46+
/// <summary>
47+
/// Allows specifying an AuthenticationScheme if OpenIdConnect is not the default challenge scheme.
48+
/// </summary>
49+
public string? AuthenticationScheme { get; set; }
50+
4651
/// <summary>
4752
/// Handles the <see cref="MsalUiRequiredException"/>.
4853
/// </summary>
@@ -115,7 +120,14 @@ public override void OnException(ExceptionContext context)
115120
}
116121
}
117122

118-
context.Result = new ChallengeResult(properties);
123+
if (AuthenticationScheme != null)
124+
{
125+
context.Result = new ChallengeResult(AuthenticationScheme, properties);
126+
}
127+
else
128+
{
129+
context.Result = new ChallengeResult(properties);
130+
}
119131
}
120132
}
121133

0 commit comments

Comments
 (0)