mirror of
https://github.com/actions/runner.git
synced 2025-12-11 12:57:05 +00:00
36 lines
979 B
C#
36 lines
979 B
C#
using System;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using GitHub.Services.Common.Internal;
|
|
|
|
namespace GitHub.Services.Common
|
|
{
|
|
/// <summary>
|
|
/// Provides a common implementation for federated credentials.
|
|
/// </summary>
|
|
[Serializable]
|
|
public abstract class FederatedCredential : IssuedTokenCredential
|
|
{
|
|
protected FederatedCredential(IssuedToken initialToken)
|
|
: base(initialToken)
|
|
{
|
|
}
|
|
|
|
public override bool IsAuthenticationChallenge(IHttpResponse webResponse)
|
|
{
|
|
if (webResponse == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (webResponse.StatusCode == HttpStatusCode.Found ||
|
|
webResponse.StatusCode == HttpStatusCode.Redirect)
|
|
{
|
|
return webResponse.Headers.GetValues(HttpHeaders.TfsFedAuthRealm).Any();
|
|
}
|
|
|
|
return webResponse.StatusCode == HttpStatusCode.Unauthorized;
|
|
}
|
|
}
|
|
}
|