1//go:build go1.18
2// +build go1.18
3
4// Copyright (c) Microsoft Corporation. All rights reserved.
5// Licensed under the MIT License.
6
7package azidentity
8
9import (
10 "errors"
11 "time"
12)
13
14// cliTimeout is the default timeout for authentication attempts via CLI tools
15const cliTimeout = 10 * time.Second
16
17// unavailableIfInChain returns err or, if the credential was invoked by DefaultAzureCredential, a
18// credentialUnavailableError having the same message. This ensures DefaultAzureCredential will try
19// the next credential in its chain (another developer credential).
20func unavailableIfInChain(err error, inDefaultChain bool) error {
21 if err != nil && inDefaultChain {
22 var unavailableErr credentialUnavailable
23 if !errors.As(err, &unavailableErr) {
24 err = newCredentialUnavailableError(credNameAzureDeveloperCLI, err.Error())
25 }
26 }
27 return err
28}
29
30// validScope is for credentials authenticating via external tools. The authority validates scopes for all other credentials.
31func validScope(scope string) bool {
32 for _, r := range scope {
33 if !(alphanumeric(r) || r == '.' || r == '-' || r == '_' || r == '/' || r == ':') {
34 return false
35 }
36 }
37 return true
38}