Skip to content

Commit

Permalink
Merge branch 'main' into user/haashah/add-no-validate-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Haard30 authored Mar 5, 2024
2 parents 553c4fa + 61a45bb commit 9e9ce1f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Added
- `--allow-custom-scopes` to skip validation and allow custom Azure DevOps PAT scopes.
- Added `--allow-custom-scopes` flag to skip validation and allow custom Azure DevOps PAT scopes.
- Added new sub-command `azureauth ado pat scopes` to list the set of actual scopes the `pat` command validates against and print the short-link to the pat scopes docs.

## [0.8.4] - 2023-09-05
### Changed
Expand Down
1 change: 1 addition & 0 deletions src/AzureAuth/Commands/Ado/CommandPat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Microsoft.Authentication.AzureAuth.Commands.Ado
/// An ADO Command for creating or fetching, and returning Azure Devops PATs.
/// </summary>
[Command("pat", Description = "Create and cache Azure Devops Personal Access Tokens (PATs) using encrypted local storage.")]
[Subcommand(typeof(Pat.CommandScopes))]
public class CommandPat
{
private const string OrganizationOption = "--organization";
Expand Down
48 changes: 48 additions & 0 deletions src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

using McMaster.Extensions.CommandLineUtils;

using Microsoft.Authentication.AdoPat;
using Microsoft.Extensions.Logging;

using System;
using System.Linq;

namespace Microsoft.Authentication.AzureAuth.Commands.Ado.Pat
{
/// <summary>
/// Command to print the list of available scopes

Check warning on line 14 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

XML comment has badly formed XML -- 'Expected an end tag for element 'summary'.'

Check warning on line 14 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

XML comment has badly formed XML -- 'Expected an end tag for element 'summary'.'

Check warning on line 14 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

XML comment has badly formed XML -- 'Expected an end tag for element 'summary'.'

Check warning on line 14 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

XML comment has badly formed XML -- 'Expected an end tag for element 'summary'.'

Check warning on line 14 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

XML comment has badly formed XML -- 'Expected an end tag for element 'summary'.'

Check warning on line 14 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

XML comment has badly formed XML -- 'Expected an end tag for element 'summary'.'
/// </summary>

Check warning on line 15 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

XML comment has badly formed XML -- 'End tag was not expected at this location.'

Check warning on line 15 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

XML comment has badly formed XML -- 'End tag was not expected at this location.'

Check warning on line 15 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

XML comment has badly formed XML -- 'End tag was not expected at this location.'

Check warning on line 15 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

XML comment has badly formed XML -- 'End tag was not expected at this location.'

Check warning on line 15 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

XML comment has badly formed XML -- 'End tag was not expected at this location.'

Check warning on line 15 in src/AzureAuth/Commands/Ado/Pat/CommandScopes.cs

View workflow job for this annotation

GitHub Actions / test (windows-latest)

XML comment has badly formed XML -- 'End tag was not expected at this location.'
[Command("scopes", Description = "List the valid ado pat scopes")]
public class CommandScopes
{
private readonly ILogger logger;

private readonly string UrlMessage = $"See {AdoPat.Constants.PatListURL} for details.";

/// <summary>
/// Create a CommandScopes
/// </summary>
/// <param name="logger"></param>
public CommandScopes(ILogger<CommandScopes> logger)
{
this.logger = logger;
}

/// <summary>
/// Executes the Scopes command listing the available scopes
/// </summary>
/// <returns></returns>
public int OnExecute()
{
var scopes = Scopes.ValidScopes.ToList();
scopes.Sort();

// Print URL at the top and bottom because it's a long list of scopes.
logger.LogInformation(UrlMessage + "\n");
logger.LogInformation(string.Join(Environment.NewLine, scopes));
logger.LogInformation("\n" + UrlMessage);
return 0;
}
}
}

0 comments on commit 9e9ce1f

Please sign in to comment.