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

Use OAuth tokens on DevBox by default for Azure Repos #1245

Merged
merged 1 commit into from
May 10, 2023
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
6 changes: 4 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -751,11 +751,13 @@ Credential: "git:https://bob@github.com/example/myrepo" (user = bob)

Specify the type of credential the Azure Repos host provider should return.

Defaults to the value `pat`.
Defaults to the value `pat`. In certain cloud hosted environments when using a
work or school account, such as [Microsoft DevBox][devbox], the default value is
`oauth`.

Value|Description
-|-
`pat` _(default)_|Azure DevOps personal access tokens
`pat`|Azure DevOps personal access tokens
`oauth`|Microsoft identity OAuth tokens (AAD or MSA tokens)

Here is more information about [Azure Access tokens][azure-tokens].
Expand Down
6 changes: 4 additions & 2 deletions docs/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,13 @@ export GCM_MSAUTH_USEDEFAULTACCOUNT="false"

Specify the type of credential the Azure Repos host provider should return.

Defaults to the value `pat`.
Defaults to the value `pat`. In certain cloud hosted environments when using a
work or school account, such as [Microsoft DevBox][devbox], the default value is
`oauth`.

Value|Description
-|-
`pat` _(default)_|Azure DevOps personal access tokens
`pat`|Azure DevOps personal access tokens
`oauth`|Microsoft identity OAuth tokens (AAD or MSA tokens)

More information about Azure Access tokens can be found [here][azure-access-tokens].
Expand Down
4 changes: 2 additions & 2 deletions src/shared/Microsoft.AzureRepos/AzureReposHostProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ private static string GetAccountNameForCredentialQuery(InputArguments input)
/// <returns>True if Personal Access Tokens should be used, false otherwise.</returns>
private bool UsePersonalAccessTokens()
{
// Default to using PATs
const bool defaultValue = true;
// Default to using PATs except on DevBox where we prefer OAuth tokens
bool defaultValue = !PlatformUtils.IsDevBox();

if (_context.Settings.TryGetSetting(
AzureDevOpsConstants.EnvironmentVariables.CredentialType,
Expand Down