Skip to content

Commit 89b5a1d

Browse files
Deprecate Kerberos API and remove tests (#5476)
* Deprecate Kerberos API and remove tests * Remove internal code and deprecate all public APIs * Remove the internal logic * Delete all internal logic * Address comments
1 parent 276cd50 commit 89b5a1d

31 files changed

+38
-1826
lines changed

src/client/Microsoft.Identity.Client/AppConfig/ApplicationConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public string ClientVersion
8181
/// <summary>
8282
/// Kerberos Service Ticket container to be used.
8383
/// </summary>
84+
[Obsolete]
8485
public KerberosTicketContainer TicketContainer { get; set; } = KerberosTicketContainer.IdToken;
8586

8687
[Obsolete("Telemetry is sent automatically by MSAL.NET. See https://aka.ms/msal-net-telemetry.")]

src/client/Microsoft.Identity.Client/AppConfig/ApplicationOptions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
using System;
5-
using System.Collections;
65
using System.Collections.Generic;
76
using System.ComponentModel;
87
using Microsoft.Identity.Client.Kerberos;
@@ -102,11 +101,15 @@ public abstract class ApplicationOptions : BaseApplicationOptions
102101
/// <summary>
103102
/// Service principal name for Kerberos Service Ticket.
104103
/// </summary>
104+
[Obsolete]
105+
[EditorBrowsable(EditorBrowsableState.Never)]
105106
public string KerberosServicePrincipalName { get; set; } = string.Empty;
106107

107108
/// <summary>
108109
/// Kerberos Service Ticket container to be used.
109-
/// </summary>
110+
/// </summary>
111+
[Obsolete]
112+
[EditorBrowsable(EditorBrowsableState.Never)]
110113
public KerberosTicketContainer TicketContainer { get; set; } = KerberosTicketContainer.IdToken;
111114
}
112115
}

src/client/Microsoft.Identity.Client/AppConfig/BaseApplicationOptions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
using System;
5-
using System.Collections;
6-
using System.Collections.Generic;
7-
using System.ComponentModel;
8-
using Microsoft.Identity.Client.Kerberos;
9-
104
namespace Microsoft.Identity.Client
115
{
126
/// <summary>

src/client/Microsoft.Identity.Client/AppConfig/PublicClientApplicationBuilder.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public static PublicClientApplicationBuilder CreateWithApplicationOptions(Public
5151
{
5252
var config = new ApplicationConfiguration(MsalClientType.PublicClient);
5353
return new PublicClientApplicationBuilder(config)
54-
.WithOptions(options)
55-
.WithKerberosTicketClaim(options.KerberosServicePrincipalName, options.TicketContainer);
54+
.WithOptions(options);
5655
}
5756

5857
/// <summary>
@@ -324,10 +323,10 @@ public PublicClientApplicationBuilder WithParentActivityOrWindow(Func<IntPtr> wi
324323
/// The expiry of the Kerberos ticket is tied to the expiry of the token that contains it.
325324
/// MSAL provides several helper APIs to read and write Kerberos tickets from the Windows Ticket Cache - see <see cref="KerberosSupplementalTicketManager"/>.
326325
/// </remarks>
326+
[Obsolete]
327+
[EditorBrowsable(EditorBrowsableState.Never)]
327328
public PublicClientApplicationBuilder WithKerberosTicketClaim(string servicePrincipalName, KerberosTicketContainer ticketContainer)
328329
{
329-
Config.KerberosServicePrincipalName = servicePrincipalName;
330-
Config.TicketContainer = ticketContainer;
331330
return this;
332331
}
333332

src/client/Microsoft.Identity.Client/Kerberos/KerberosKeyTypes.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System;
5+
using System.ComponentModel;
6+
47
namespace Microsoft.Identity.Client.Kerberos
58
{
69
/// <summary>
710
/// The Kerberos key types used in this assembly.
811
/// </summary>
12+
[Obsolete]
13+
[EditorBrowsable(EditorBrowsableState.Never)]
914
public enum KerberosKeyTypes
1015
{
1116
/// <summary>

src/client/Microsoft.Identity.Client/Kerberos/KerberosSupplementalTicket.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
3+
using System;
4+
using System.ComponentModel;
35

46
#if SUPPORTS_SYSTEM_TEXT_JSON
57
using JsonProperty = System.Text.Json.Serialization.JsonPropertyNameAttribute;
@@ -13,6 +15,8 @@ namespace Microsoft.Identity.Client.Kerberos
1315
/// Class for Kerberos tickets that are included as claims and used as a supplemental token in an OAuth/OIDC
1416
/// protocol response.
1517
/// </summary>
18+
[Obsolete]
19+
[EditorBrowsable(EditorBrowsableState.Never)]
1620
public class KerberosSupplementalTicket
1721
{
1822
/// <summary>

src/client/Microsoft.Identity.Client/Kerberos/KerberosSupplementalTicketManager.cs

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ namespace Microsoft.Identity.Client.Kerberos
2323
/// <summary>
2424
/// Helper class to manage Kerberos Ticket Claims.
2525
/// </summary>
26+
[Obsolete]
27+
[EditorBrowsable(EditorBrowsableState.Never)]
2628
public static class KerberosSupplementalTicketManager
2729
{
2830
private const int DefaultLogonId = 0;
@@ -95,26 +97,7 @@ public static void SaveToWindowsTicketCache(KerberosSupplementalTicket ticket)
9597
/// </remarks>
9698
public static void SaveToWindowsTicketCache(KerberosSupplementalTicket ticket, long logonId)
9799
{
98-
#if !SUPPORTS_WIN32
99-
throw new PlatformNotSupportedException("Ticket Cache interface is not supported for this .NET platform. It is supported on .NET Classic, .NET Core and NetStandadrd");
100-
#else
101-
if (!DesktopOsHelper.IsWindows())
102-
{
103-
throw new PlatformNotSupportedException("Ticket Cache interface is not supported on this OS. It is supported on Windows only.");
104-
105-
}
106-
107-
if (ticket == null || string.IsNullOrEmpty(ticket.KerberosMessageBuffer))
108-
{
109-
throw new ArgumentException("Kerberos Ticket information is not valid");
110-
}
111-
112-
using (var cache = Platforms.Features.DesktopOs.Kerberos.TicketCacheWriter.Connect())
113-
{
114-
byte[] krbCred = Convert.FromBase64String(ticket.KerberosMessageBuffer);
115-
cache.ImportCredential(krbCred, logonId);
116-
}
117-
#endif
100+
throw new NotImplementedException("This method is deprecated.");
118101
}
119102

120103
/// <summary>
@@ -144,20 +127,7 @@ public static byte[] GetKerberosTicketFromWindowsTicketCache(string servicePrinc
144127
/// </remarks>
145128
public static byte[] GetKerberosTicketFromWindowsTicketCache(string servicePrincipalName, long logonId)
146129
{
147-
#if !SUPPORTS_WIN32
148-
throw new PlatformNotSupportedException("Ticket Cache interface is not supported for this .NET platform. It is supported on .NET Classic, .NET Core and NetStandadrd");
149-
#else
150-
if (!DesktopOsHelper.IsWindows())
151-
{
152-
throw new PlatformNotSupportedException("Ticket Cache interface is not supported on this OS. It is supported on Windows only.");
153-
154-
}
155-
156-
using (var reader = new Platforms.Features.DesktopOs.Kerberos.TicketCacheReader(servicePrincipalName, logonId))
157-
{
158-
return reader.RequestToken();
159-
}
160-
#endif
130+
throw new NotImplementedException("This method is deprecated.");
161131
}
162132

163133
/// <summary>
@@ -175,32 +145,5 @@ public static byte[] GetKrbCred(KerberosSupplementalTicket ticket)
175145

176146
return null;
177147
}
178-
179-
/// <summary>
180-
/// Generate a Kerberos Ticket Claim string.
181-
/// </summary>
182-
/// <param name="servicePrincipalName">Service principal name to use.</param>
183-
/// <param name="ticketContainer">Ticket container to use.</param>
184-
/// <returns>A Kerberos Ticket Claim string if valid service principal name was given. Empty string, otherwise.</returns>
185-
internal static string GetKerberosTicketClaim(string servicePrincipalName, KerberosTicketContainer ticketContainer)
186-
{
187-
if (string.IsNullOrEmpty(servicePrincipalName))
188-
{
189-
return string.Empty;
190-
}
191-
192-
if (ticketContainer == KerberosTicketContainer.IdToken)
193-
{
194-
return string.Format(
195-
CultureInfo.InvariantCulture,
196-
IdTokenAsRepTemplate,
197-
servicePrincipalName);
198-
}
199-
200-
return string.Format(
201-
CultureInfo.InvariantCulture,
202-
AccessTokenAsRepTemplate,
203-
servicePrincipalName);
204-
}
205148
}
206149
}

src/client/Microsoft.Identity.Client/Kerberos/KerberosTicketContainer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System;
5+
using System.ComponentModel;
6+
47
namespace Microsoft.Identity.Client.Kerberos
58
{
69
/// <summary>
710
/// Declares the type of container to use for Kerberos Ticket Claim.
811
/// </summary>
12+
[Obsolete]
13+
[EditorBrowsable(EditorBrowsableState.Never)]
914
public enum KerberosTicketContainer
1015
{
1116
/// <summary>

src/client/Microsoft.Identity.Client/OAuth2/TokenClient.cs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ await _serviceBundle.Config.ClientCredential.AddConfidentialClientParametersAsyn
149149

150150
_oAuth2Client.AddBodyParameter(OAuth2Parameter.Scope, scopes);
151151

152-
// Add Kerberos Ticket claims if there's valid service principal name in Configuration.
153-
// Kerberos Ticket claim is only allowed at token request due to security issue.
154-
// It should not be included for authorize request.
155-
AddClaims();
152+
_oAuth2Client.AddBodyParameter(OAuth2Parameter.Claims, _requestParams.ClaimsAndClientCapabilities);
156153

157154
foreach (var kvp in additionalBodyParameters)
158155
{
@@ -183,42 +180,6 @@ await _serviceBundle.Config.ClientCredential.AddConfidentialClientParametersAsyn
183180
AddExtraHttpHeaders();
184181
}
185182

186-
/// <summary>
187-
/// Add Claims, including ClientCapabilities, to body parameter for POST request.
188-
/// </summary>
189-
private void AddClaims()
190-
{
191-
string kerberosClaim = KerberosSupplementalTicketManager.GetKerberosTicketClaim(
192-
_requestParams.RequestContext.ServiceBundle.Config.KerberosServicePrincipalName,
193-
_requestParams.RequestContext.ServiceBundle.Config.TicketContainer);
194-
string resolvedClaims;
195-
if (string.IsNullOrEmpty(kerberosClaim))
196-
{
197-
resolvedClaims = _requestParams.ClaimsAndClientCapabilities;
198-
}
199-
else
200-
{
201-
if (!string.IsNullOrEmpty(_requestParams.ClaimsAndClientCapabilities))
202-
{
203-
var existingClaims = JsonHelper.ParseIntoJsonObject(_requestParams.ClaimsAndClientCapabilities);
204-
var mergedClaims = ClaimsHelper.MergeClaimsIntoCapabilityJson(kerberosClaim, existingClaims);
205-
206-
resolvedClaims = JsonHelper.JsonObjectToString(mergedClaims);
207-
_requestParams.RequestContext.Logger.Verbose(
208-
() => $"Adding kerberos claim + Claims/ClientCapabilities to request: {resolvedClaims}");
209-
}
210-
else
211-
{
212-
resolvedClaims = kerberosClaim;
213-
_requestParams.RequestContext.Logger.Verbose(
214-
() => $"Adding kerberos claim to request: {resolvedClaims}");
215-
}
216-
}
217-
218-
// no-op if resolvedClaims is null
219-
_oAuth2Client.AddBodyParameter(OAuth2Parameter.Claims, resolvedClaims);
220-
}
221-
222183
private void AddExtraHttpHeaders()
223184
{
224185
if (_requestParams.ExtraHttpHeaders != null)

src/client/Microsoft.Identity.Client/Platforms/Features/DesktopOS/Kerberos/AcceptContextFlag.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)