Exemple #1
0
 internal SharedTokenCacheCredential(string tenantId, string username, TokenCredentialOptions options, CredentialPipeline pipeline, MsalPublicClient client)
 {
     _tenantId             = tenantId;
     _username             = username;
     _skipTenantValidation = (options as SharedTokenCacheCredentialOptions)?.EnableGuestTenantAuthentication ?? false;
     _record   = (options as SharedTokenCacheCredentialOptions)?.AuthenticationRecord;
     _pipeline = pipeline ?? CredentialPipeline.GetInstance(options);
     _allowMultiTenantAuthentication = options?.AllowMultiTenantAuthentication ?? false;
     Client            = client ?? new MsalPublicClient(_pipeline, tenantId, (options as SharedTokenCacheCredentialOptions)?.ClientId ?? Constants.DeveloperSignOnClientId, null, (options as ITokenCacheOptions) ?? s_DefaultCacheOptions);
     _accountAsyncLock = new AsyncLockWithValue <IAccount>();
 }
        protected MsalClientBase(CredentialPipeline pipeline, string tenantId, string clientId, ITokenCacheOptions cacheOptions)
        {
            Pipeline = pipeline;

            TenantId = tenantId;

            ClientId = clientId;

            EnablePersistentCache = cacheOptions?.EnablePersistentCache ?? false;

            AllowUnencryptedCache = cacheOptions?.AllowUnencryptedCache ?? false;

            _clientAsyncLock = new AsyncLockWithValue <TClient>();
        }
        protected MsalClientBase(CredentialPipeline pipeline, string tenantId, string clientId, bool isPiiLoggingEnabled, ITokenCacheOptions cacheOptions)
        {
            // This validation is performed as a backstop. Validation in TokenCredentialOptions.AuthorityHost prevents users from explicitly
            // setting AuthorityHost to a non TLS endpoint. However, the AuthorityHost can also be set by the AZURE_AUTHORITY_HOST environment
            // variable rather than in code. In this case we need to validate the endpoint before we use it. However, we can't validate in
            // CredentialPipeline as this is also used by the ManagedIdentityCredential which allows non TLS endpoints. For this reason
            // we validate here as all other credentials will create an MSAL client.
            Validations.ValidateAuthorityHost(pipeline.AuthorityHost);

            IsPiiLoggingEnabled = isPiiLoggingEnabled;
            Pipeline            = pipeline;
            TenantId            = tenantId;
            ClientId            = clientId;
            TokenCache          = cacheOptions?.TokenCachePersistenceOptions == null ? null : new TokenCache(cacheOptions?.TokenCachePersistenceOptions);
            _clientAsyncLock    = new AsyncLockWithValue <TClient>();
        }
 internal DefaultAzureCredential(DefaultAzureCredentialFactory factory, DefaultAzureCredentialOptions options)
 {
     _pipeline       = factory.Pipeline;
     _sources        = GetDefaultAzureCredentialChain(factory, options);
     _credentialLock = new AsyncLockWithValue <TokenCredential>();
 }
 /// <summary>
 /// Resets the <see cref="cacheHelperLock"/> so that tests can validate multiple calls to <see cref="RegisterCache"/>
 /// This should only be used for testing.
 /// </summary>
 internal static void ResetWrapperCache()
 {
     cacheHelperLock = new AsyncLockWithValue <MsalCacheHelperWrapper>();
 }