Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.Identity.Client.AuthScheme.Bearer
{
internal class BearerAuthenticationOperation : IAuthenticationOperation

Check failure on line 11 in src/client/Microsoft.Identity.Client/AuthScheme/Bearer/BearerAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuildandRunIntegrationTestsOnLinux)

src/client/Microsoft.Identity.Client/AuthScheme/Bearer/BearerAuthenticationOperation.cs#L11

src/client/Microsoft.Identity.Client/AuthScheme/Bearer/BearerAuthenticationOperation.cs(11,52): Error CS0737: 'BearerAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'BearerAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.

Check failure on line 11 in src/client/Microsoft.Identity.Client/AuthScheme/Bearer/BearerAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuilMacConsoleAppWithBroker)

src/client/Microsoft.Identity.Client/AuthScheme/Bearer/BearerAuthenticationOperation.cs#L11

src/client/Microsoft.Identity.Client/AuthScheme/Bearer/BearerAuthenticationOperation.cs(11,52): Error CS0737: 'BearerAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'BearerAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.

Check failure on line 11 in src/client/Microsoft.Identity.Client/AuthScheme/Bearer/BearerAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML)

src/client/Microsoft.Identity.Client/AuthScheme/Bearer/BearerAuthenticationOperation.cs#L11

src/client/Microsoft.Identity.Client/AuthScheme/Bearer/BearerAuthenticationOperation.cs(11,52): Error CS0737: 'BearerAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'BearerAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.
{
internal const string BearerTokenType = "bearer";

Expand All @@ -30,5 +30,11 @@
// ESTS issues Bearer tokens by default, no need for any extra params
return CollectionHelpers.GetEmptyDictionary<string, string>();
}

bool ValidateCachedToken(MsalCacheValidationData cachedTokenItem)
{
// no-op
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public interface IAuthenticationOperation
/// <returns>Name and values of params</returns>
IReadOnlyDictionary<string, string> GetTokenRequestParams();

/// <summary>
///
/// </summary>
/// <param name="cachedTokenItem"></param>
/// <returns></returns>
bool ValidateCachedToken(MsalCacheValidationData cachedTokenItem);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming - how about AcceptCachedToken ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe make it async from the start? :)


/// <summary>
/// Key ID of the public / private key pair used by the encryption algorithm, if any.
/// Tokens obtained by authentication schemes that use this are bound to the KeyId, i.e.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;

namespace Microsoft.Identity.Client.AuthScheme
{
/// <summary>
/// Data used to validate cache items for different authentication schemes.
/// </summary>
public class MsalCacheValidationData
{
/// <summary>
/// Gets the persisted parameters addded to the cache items.
/// </summary>
public IDictionary<string, string> PersistedCacheParameters { get; internal set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.Identity.Client.AuthScheme.PoP
{
internal class MtlsPopAuthenticationOperation : IAuthenticationOperation

Check failure on line 13 in src/client/Microsoft.Identity.Client/AuthScheme/PoP/MtlsPopAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuildandRunIntegrationTestsOnLinux)

src/client/Microsoft.Identity.Client/AuthScheme/PoP/MtlsPopAuthenticationOperation.cs#L13

src/client/Microsoft.Identity.Client/AuthScheme/PoP/MtlsPopAuthenticationOperation.cs(13,53): Error CS0737: 'MtlsPopAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'MtlsPopAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.

Check failure on line 13 in src/client/Microsoft.Identity.Client/AuthScheme/PoP/MtlsPopAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuilMacConsoleAppWithBroker)

src/client/Microsoft.Identity.Client/AuthScheme/PoP/MtlsPopAuthenticationOperation.cs#L13

src/client/Microsoft.Identity.Client/AuthScheme/PoP/MtlsPopAuthenticationOperation.cs(13,53): Error CS0737: 'MtlsPopAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'MtlsPopAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.

Check failure on line 13 in src/client/Microsoft.Identity.Client/AuthScheme/PoP/MtlsPopAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML)

src/client/Microsoft.Identity.Client/AuthScheme/PoP/MtlsPopAuthenticationOperation.cs#L13

src/client/Microsoft.Identity.Client/AuthScheme/PoP/MtlsPopAuthenticationOperation.cs(13,53): Error CS0737: 'MtlsPopAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'MtlsPopAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.
{
private readonly X509Certificate2 _mtlsCert;

Expand Down Expand Up @@ -40,5 +40,11 @@
{
authenticationResult.BindingCertificate = _mtlsCert;
}

bool ValidateCachedToken(MsalCacheValidationData cachedTokenItem)
{
// no-op
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace Microsoft.Identity.Client.AuthScheme.PoP
{
internal class PopAuthenticationOperation : IAuthenticationOperation

Check failure on line 24 in src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuildandRunIntegrationTestsOnLinux)

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs#L24

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs(24,49): Error CS0737: 'PopAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'PopAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.

Check failure on line 24 in src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuilMacConsoleAppWithBroker)

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs#L24

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs(24,49): Error CS0737: 'PopAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'PopAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.

Check failure on line 24 in src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML)

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs#L24

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs(24,49): Error CS0737: 'PopAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'PopAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.
{
private readonly PoPAuthenticationConfiguration _popAuthenticationConfiguration;
private readonly IPoPCryptoProvider _popCryptoProvider;
Expand Down Expand Up @@ -162,5 +162,11 @@

return sb.ToString();
}

bool ValidateCachedToken(MsalCacheValidationData cachedTokenItem)
{
// no-op
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//Authentication Scheme used when MSAL Broker and pop are used together.
//Tokens acquired from brokers will not be saved in the local ache and MSAL will not search the local cache during silent authentication.
//This is because tokens are cached in the broker instead so MSAL will rely on the broker's cache for silent requests.
internal class PopBrokerAuthenticationOperation : IAuthenticationOperation

Check failure on line 18 in src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopBrokerAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuildandRunIntegrationTestsOnLinux)

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopBrokerAuthenticationOperation.cs#L18

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopBrokerAuthenticationOperation.cs(18,55): Error CS0737: 'PopBrokerAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'PopBrokerAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.

Check failure on line 18 in src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopBrokerAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuilMacConsoleAppWithBroker)

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopBrokerAuthenticationOperation.cs#L18

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopBrokerAuthenticationOperation.cs(18,55): Error CS0737: 'PopBrokerAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'PopBrokerAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.

Check failure on line 18 in src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopBrokerAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML)

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopBrokerAuthenticationOperation.cs#L18

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopBrokerAuthenticationOperation.cs(18,55): Error CS0737: 'PopBrokerAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'PopBrokerAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.
{
public int TelemetryTokenType => TelemetryTokenTypeConstants.Pop;

Expand All @@ -34,5 +34,11 @@
{
return CollectionHelpers.GetEmptyDictionary<string, string>();
}

bool ValidateCachedToken(MsalCacheValidationData cachedTokenItem)
{
// no-op
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.Identity.Client.AuthScheme.SSHCertificates
{
internal class SSHCertAuthenticationOperation : IAuthenticationOperation

Check failure on line 12 in src/client/Microsoft.Identity.Client/AuthScheme/SSHCertificates/SSHCertAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuildandRunIntegrationTestsOnLinux)

src/client/Microsoft.Identity.Client/AuthScheme/SSHCertificates/SSHCertAuthenticationOperation.cs#L12

src/client/Microsoft.Identity.Client/AuthScheme/SSHCertificates/SSHCertAuthenticationOperation.cs(12,53): Error CS0737: 'SSHCertAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'SSHCertAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.

Check failure on line 12 in src/client/Microsoft.Identity.Client/AuthScheme/SSHCertificates/SSHCertAuthenticationOperation.cs

View check run for this annotation

Azure Pipelines / .NET MSAL PR (YAML) (MSALBuildAndTest BuilMacConsoleAppWithBroker)

src/client/Microsoft.Identity.Client/AuthScheme/SSHCertificates/SSHCertAuthenticationOperation.cs#L12

src/client/Microsoft.Identity.Client/AuthScheme/SSHCertificates/SSHCertAuthenticationOperation.cs(12,53): Error CS0737: 'SSHCertAuthenticationOperation' does not implement interface member 'IAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)'. 'SSHCertAuthenticationOperation.ValidateCachedToken(MsalCacheValidationData)' cannot implement an interface member because it is not public.
{
internal const string SSHCertTokenType = "ssh-cert";
private readonly string _jwk;
Expand Down Expand Up @@ -53,5 +53,11 @@
{ OAuth2Parameter.RequestConfirmation , _jwk }
};
}

bool ValidateCachedToken(MsalCacheValidationData cachedTokenItem)
{
// no-op
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ public IReadOnlyDictionary<string, string> GetTokenRequestParams()
{
return CollectionHelpers.GetEmptyDictionary<string, string>();
}

bool ValidateCachedToken(MsalCacheValidationData cachedTokenItem)
{
// no-op
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Identity.Client.ApiConfig.Parameters;
using Microsoft.Identity.Client.AuthScheme;
using Microsoft.Identity.Client.Cache.Items;
using Microsoft.Identity.Client.Core;
using Microsoft.Identity.Client.Extensibility;
Expand Down Expand Up @@ -76,6 +77,19 @@ protected override async Task<AuthenticationResult> ExecuteAsync(CancellationTok

MsalAccessTokenCacheItem cachedAccessTokenItem = await GetCachedAccessTokenAsync().ConfigureAwait(false);

// Validate the cached token using the authentication operation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be on request base?

if (AuthenticationRequestParameters.AuthenticationScheme != null &&
cachedAccessTokenItem != null)
{
var cacheValidationData = new MsalCacheValidationData();
cacheValidationData.PersistedCacheParameters = cachedAccessTokenItem.PersistedCacheParameters;
if (!AuthenticationRequestParameters.AuthenticationScheme.ValidateCachedToken(cacheValidationData))
{
logger.Info("[ClientCredentialRequest] Cached token failed authentication operation validation.");
cachedAccessTokenItem = null;
}
}

// No access token or cached access token needs to be refreshed
if (cachedAccessTokenItem != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<Compile Include="$(PathToMsalSources)\**\*.cs" Exclude="$(PathToMsalSources)\obj\**\*.*" />
<Compile Remove="$(PathToMsalSources)\Platforms\**\*.*;$(PathToMsalSources)\Resources\*.cs" />
<Compile Remove="$(PathToMsalSources)\PlatformsCommon\PlatformNotSupported\ApiConfig\SystemWebViewOptions.cs" />
<None Remove="AuthScheme\MsalCacheValidationData.cs" />
<EmbeddedResource Include="$(PathToMsalSources)\Properties\Microsoft.Identity.Client.rd.xml" />
<None Include="$(PathToMsalSources)\..\..\..\README.md" Pack="true" PackagePath="\" />
<None Include="Platforms\net\JsonObjectAttribute.cs" />
Expand Down Expand Up @@ -161,4 +162,8 @@
<AdditionalFiles Include="PublicAPI/$(TargetFramework)/PublicAPI.Unshipped.txt" />
</ItemGroup>

<ItemGroup>
<Compile Include="AuthScheme\MsalCacheValidationData.cs" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert all changes

</ItemGroup>

</Project>
Loading