Exemple #1
0
        private static ReadOnlyMemory <TokenCredential> GetDefaultAzureCredentialChain(DefaultAzureCredentialOptions options)
        {
            if (options is null)
            {
                return(s_defaultCredentialChain);
            }

            int i = 0;

            TokenCredential[] chain = new TokenCredential[5];

            if (!options.ExcludeEnvironmentCredential)
            {
                chain[i++] = new EnvironmentCredential(options);
            }

            if (!options.ExcludeManagedIdentityCredential)
            {
                chain[i++] = new ManagedIdentityCredential(options.ManagedIdentityClientId, options);
            }

            if (!options.ExcludeSharedTokenCacheCredential)
            {
                chain[i++] = new SharedTokenCacheCredential(options.SharedTokenCacheUsername);
            }

            if (!options.ExcludeInteractiveBrowserCredential)
            {
                chain[i++] = new InteractiveBrowserCredential(null, Constants.DeveloperSignOnClientId, options);
            }

            chain[i++] = new CredentialNotFoundGuard();

            return(new ReadOnlyMemory <TokenCredential>(chain, 0, i));
        }
Exemple #2
0
 internal AzureApplicationCredential(AzureApplicationCredentialOptions options, EnvironmentCredential environmentCredential = null, ManagedIdentityCredential managedIdentityCredential = null)
 {
     _credential = new ChainedTokenCredential(
         environmentCredential ?? new EnvironmentCredential(options),
         managedIdentityCredential ?? new ManagedIdentityCredential(options.ManagedIdentityClientId)
         );
 }