EOS-WebAPI/Common/HttpAuthenticationChallengeContextExtensions.cs
Nidhi Bhargava d0ac8a7790 Code Commit
2025-09-04 17:30:22 +05:30

30 lines
994 B
C#

using System;
using System.Net.Http.Headers;
using System.Web.Http.Filters;
namespace VECV_WebApi.Common
{
public static class HttpAuthenticationChallengeContextExtensions
{
public static void ChallengeWith(this HttpAuthenticationChallengeContext context, string scheme)
{
ChallengeWith(context, new AuthenticationHeaderValue(scheme));
}
public static void ChallengeWith(this HttpAuthenticationChallengeContext context, string scheme, string parameter)
{
ChallengeWith(context, new AuthenticationHeaderValue(scheme, parameter));
}
public static void ChallengeWith(this HttpAuthenticationChallengeContext context, AuthenticationHeaderValue challenge)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
context.Result = new AddChallengeOnUnauthorizedResult(challenge, context.Result);
}
}
}