-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix * attribute
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/client/Microsoft.Identity.Client/Extensibility/AcquireTokenForClientBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.ComponentModel; | ||
|
||
namespace Microsoft.Identity.Client.Extensibility | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static class AcquireTokenForClientBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Binds the token to a key in the cache. L2 cache keys contain the key id. | ||
/// No cryptographic operations is performed on the token. | ||
/// </summary> | ||
/// <param name="builder"></param> | ||
/// <param name="keyId">A key id to which the access token is associated. The token will not be retrieved from the cache unless the same key id is presented. Can be null.</param> | ||
/// <param name="expectedTokenTypeFromAad">AAD issues several types of bound tokens. MSAL checks the token type, which needs to match the value set by ESTS. Normal POP tokens have this as "pop"</param> | ||
/// <returns>the builder</returns> | ||
[EditorBrowsable(EditorBrowsableState.Never)] // https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/4789 | ||
public static AcquireTokenForClientParameterBuilder WithProofOfPosessionKeyId( | ||
this AcquireTokenForClientParameterBuilder builder, | ||
string keyId, | ||
string expectedTokenTypeFromAad = "Bearer") | ||
{ | ||
if (string.IsNullOrEmpty(keyId)) | ||
{ | ||
throw new ArgumentNullException(nameof(keyId)); | ||
} | ||
|
||
builder.ValidateUseOfExperimentalFeature(); | ||
builder.CommonParameters.AuthenticationScheme = new ExternalBoundTokenScheme(keyId, expectedTokenTypeFromAad); | ||
|
||
return builder; | ||
} | ||
} | ||
} |