Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making developer credential types public #12501

Merged
merged 2 commits into from
Jun 5, 2020
Merged
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
2 changes: 2 additions & 0 deletions sdk/identity/Azure.Identity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.2.0-preview.4 (Unreleased)

### New Features
- Makes `AzureCliCredential`, `VisualStudioCredential` and `VisualStudioCodeCredential` public to allow direct usage.

## 1.2.0-preview.3

Expand Down
30 changes: 30 additions & 0 deletions sdk/identity/Azure.Identity/api/Azure.Identity.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public AuthorizationCodeCredential(string tenantId, string clientId, string clie
public override Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public override System.Threading.Tasks.ValueTask<Azure.Core.AccessToken> GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public partial class AzureCliCredential : Azure.Core.TokenCredential
{
public AzureCliCredential() { }
public override Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public override System.Threading.Tasks.ValueTask<Azure.Core.AccessToken> GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public partial class ChainedTokenCredential : Azure.Core.TokenCredential
{
public ChainedTokenCredential(params Azure.Core.TokenCredential[] sources) { }
Expand Down Expand Up @@ -189,4 +195,28 @@ public UsernamePasswordCredential(string username, string password, string tenan
public override Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public override System.Threading.Tasks.ValueTask<Azure.Core.AccessToken> GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public partial class VisualStudioCodeCredential : Azure.Core.TokenCredential
{
public VisualStudioCodeCredential() { }
public VisualStudioCodeCredential(Azure.Identity.VisualStudioCodeCredentialOptions options) { }
public override Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken) { throw null; }
public override System.Threading.Tasks.ValueTask<Azure.Core.AccessToken> GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken) { throw null; }
}
public partial class VisualStudioCodeCredentialOptions : Azure.Identity.TokenCredentialOptions
{
public VisualStudioCodeCredentialOptions() { }
public string TenantId { get { throw null; } set { } }
}
public partial class VisualStudioCredential : Azure.Core.TokenCredential
{
public VisualStudioCredential() { }
public VisualStudioCredential(Azure.Identity.VisualStudioCredentialOptions options) { }
public override Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken) { throw null; }
public override System.Threading.Tasks.ValueTask<Azure.Core.AccessToken> GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken) { throw null; }
}
public partial class VisualStudioCredentialOptions : Azure.Identity.TokenCredentialOptions
{
public VisualStudioCredentialOptions() { }
public string TenantId { get { throw null; } set { } }
}
}
4 changes: 2 additions & 2 deletions sdk/identity/Azure.Identity/src/AzureCliCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
namespace Azure.Identity
{
/// <summary>
/// Enables authentication to Azure Active Directory using Azure CLI to generated an access token.
/// Enables authentication to Azure Active Directory using Azure CLI to obtain an access token.
/// </summary>
internal class AzureCliCredential : TokenCredential
public class AzureCliCredential : TokenCredential
{
private const string AzureCLINotInstalled = "Azure CLI not installed";
private const string AzNotLogIn = "Please run 'az login' to set up account";
Expand Down
15 changes: 9 additions & 6 deletions sdk/identity/Azure.Identity/src/VisualStudioCodeCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
namespace Azure.Identity
{
/// <summary>
/// Enables authentication to Azure Active Directory using data from Visual Studio Code
/// Enables authentication to Azure Active Directory using data from Visual Studio Code.
/// </summary>
internal class VisualStudioCodeCredential : TokenCredential
public class VisualStudioCodeCredential : TokenCredential
{
private const string CredentialsSection = "VS Code Azure";
private const string ClientId = "aebc6443-996d-45c2-90f0-388ff96faa56";
Expand All @@ -28,12 +28,15 @@ internal class VisualStudioCodeCredential : TokenCredential
private readonly MsalPublicClient _client;

/// <summary>
/// Protected constructor for mocking
/// Creates a new instance of the <see cref="VisualStudioCodeCredential"/>.
/// </summary>
protected VisualStudioCodeCredential() : this(default, default) {}
public VisualStudioCodeCredential() : this(null) { }

/// <inheritdoc />
public VisualStudioCodeCredential(string tenantId, TokenCredentialOptions options) : this(tenantId, CredentialPipeline.GetInstance(options), default, default) {}
/// <summary>
/// Creates a new instance of the <see cref="VisualStudioCodeCredential"/> with the specified options.
/// </summary>
/// <param name="options">Options for configuring the credential.</param>
public VisualStudioCodeCredential(VisualStudioCodeCredentialOptions options) : this(options?.TenantId, CredentialPipeline.GetInstance(options), default, default) { }

internal VisualStudioCodeCredential(string tenantId, CredentialPipeline pipeline, IFileSystemService fileSystem, IVisualStudioCodeAdapter vscAdapter)
: this(tenantId, pipeline, default, fileSystem, vscAdapter)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Text;

namespace Azure.Identity
{
/// <summary>
/// Options for configuring the <see cref="VisualStudioCodeCredential"/>.
/// </summary>
public class VisualStudioCodeCredentialOptions : TokenCredentialOptions
{
/// <summary>
/// The tenant ID the user will be authenticated to. If not specified the user will be authenticated to the tenant the user originally authenticated to via the Visual Studio Code Azure Account plugin.
/// </summary>
public string TenantId { get; set; }
}
}
13 changes: 8 additions & 5 deletions sdk/identity/Azure.Identity/src/VisualStudioCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Azure.Identity
/// <summary>
/// Enables authentication to Azure Active Directory using data from Visual Studio
/// </summary>
internal class VisualStudioCredential : TokenCredential
public class VisualStudioCredential : TokenCredential
{
private const string TokenProviderFilePath = @".IdentityService\AzureServiceAuth\tokenprovider.json";
private const string ResourceArgumentName = "--resource";
Expand All @@ -32,12 +32,15 @@ internal class VisualStudioCredential : TokenCredential
private readonly IProcessService _processService;

/// <summary>
/// Protected constructor for mocking
/// Creates a new instance of the <see cref="VisualStudioCredential"/>.
/// </summary>
protected VisualStudioCredential() : this(default, default) {}
public VisualStudioCredential() : this(null) { }

/// <inheritdoc />
internal VisualStudioCredential(string tenantId, TokenCredentialOptions options) : this(tenantId, CredentialPipeline.GetInstance(options), default, default) {}
/// <summary>
/// Creates a new instance of the <see cref="VisualStudioCredential"/> with the specified options.
/// </summary>
/// <param name="options">Options for configuring the credential.</param>
public VisualStudioCredential(VisualStudioCredentialOptions options) : this(options?.TenantId, CredentialPipeline.GetInstance(options), default, default) { }

internal VisualStudioCredential(string tenantId, CredentialPipeline pipeline, IFileSystemService fileSystem, IProcessService processService)
{
Expand Down
16 changes: 16 additions & 0 deletions sdk/identity/Azure.Identity/src/VisualStudioCredentialOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.Identity
{
/// <summary>
/// Options for configuring the <see cref="VisualStudioCredential"/>.
/// </summary>
public class VisualStudioCredentialOptions : TokenCredentialOptions
{
/// <summary>
/// The tenant ID the user will be authenticated to. If not specified the user will be authenticated to their home tenant.
/// </summary>
public string TenantId { get; set; }
}
}