public TokenCreator(IOptions <TokenCreatorConfiguration> options, AbstractApplicationBuilder <ConfidentialClientApplicationBuilder> confidentialClientApplicationBuilder, AbstractApplicationBuilder <PublicClientApplicationBuilder> publicClientApplicationBuilder, ILogger <TokenCreator> logger) { _ = options ?? throw new ArgumentNullException(nameof(options)); this.confidentialClientApplicationBuilder = confidentialClientApplicationBuilder ?? throw new ArgumentNullException(nameof(confidentialClientApplicationBuilder)); this.publicClientApplicationBuilder = publicClientApplicationBuilder ?? throw new ArgumentNullException(nameof(publicClientApplicationBuilder)); tokenCreatorConfiguration = options.Value; this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public static T WithCachePartitioningAsserts <T>( this AbstractApplicationBuilder <T> builder, IPlatformProxy platformProxy) where T : AbstractApplicationBuilder <T> { (platformProxy as AbstractPlatformProxy).UserTokenCacheAccessorForTest = new UserAccessorWithPartitionAsserts(new NullLogger(), null); (platformProxy as AbstractPlatformProxy).AppTokenCacheAccessorForTest = new AppAccessorWithPartitionAsserts(new NullLogger(), null); builder.Config.PlatformProxy = platformProxy; return((T)builder); }
protected virtual void ConfigureBuilder <T>(AbstractApplicationBuilder <T> builder) where T : AbstractApplicationBuilder <T> { var httpClientFactory = serviceProvider.GetService <IHttpClientFactory>(); var loggerFactory = serviceProvider.GetService <ILoggerFactory>(); if (!(httpClientFactory is null)) { builder.WithHttpClientFactory(httpClientFactory); } if (!(loggerFactory is null)) { builder.WithLoggerFactory(loggerFactory); } }
/// <summary> /// Helper method that configures an ApplicationBuilder object with the given options /// </summary> /// <typeparam name="T">The type built by the ApplicationBuilder</typeparam> /// <param name="builder">The extended ApplicationBuilder</param> /// <param name="authorityUri">The URI of the Azure Active Directory Authority</param> /// <param name="redirectUri">The Redirect URI for authentication</param> /// <param name="tenantId">The ID of the Azure Active Directory Tenant</param> /// <param name="environment">Information about the configured cloud environment</param> /// <returns></returns> internal static T WithPnPAdditionalAuthenticationSettings <T>(this AbstractApplicationBuilder <T> builder, Uri authorityUri, Uri redirectUri, string tenantId, Microsoft365Environment?environment) where T : AbstractApplicationBuilder <T> { if (tenantId == null) { throw new ArgumentNullException(nameof(tenantId)); } if (environment.HasValue && environment.Value != Microsoft365Environment.Production) { if (tenantId.Equals(AuthGlobals.OrganizationsTenantId, StringComparison.InvariantCultureIgnoreCase)) { builder = builder.WithAuthority($"https://{CloudManager.GetAzureADLoginAuthority(environment.Value)}/{AuthGlobals.OrganizationsTenantId}/"); } else { builder = builder.WithAuthority(authorityUri?.ToString() ?? $"https://{CloudManager.GetAzureADLoginAuthority(environment.Value)}", tenantId, true); } } else { if (tenantId.Equals(AuthGlobals.OrganizationsTenantId, StringComparison.InvariantCultureIgnoreCase)) { builder = builder.WithAuthority(AadAuthorityAudience.AzureAdMultipleOrgs); } else { builder = builder.WithAuthority(authorityUri?.ToString() ?? "https://login.microsoftonline.com", tenantId, true); } } if (redirectUri != null) { builder = builder.WithRedirectUri(redirectUri.ToString()); } return((T)builder); }
public static T WithPnPAdditionalAuthenticationSettings <T>(this AbstractApplicationBuilder <T> builder, Uri authorityUri, Uri redirectUri, string tenantId) where T : AbstractApplicationBuilder <T> { if (tenantId == null) { throw new ArgumentNullException(nameof(tenantId)); } if (tenantId.Equals(OrganizationsTenantId, StringComparison.InvariantCultureIgnoreCase)) { builder = builder.WithAuthority(AadAuthorityAudience.AzureAdMultipleOrgs); } else { builder = builder.WithAuthority(authorityUri?.ToString() ?? "https://login.microsoftonline.com", tenantId, true); } if (redirectUri != null) { builder = builder.WithRedirectUri(redirectUri.ToString()); } return((T)builder); }