Example #1
0
 public KeyVaultsController(IYResourceClient resourceClient,
                            IYHttpRequestHandler client,
                            IYEngineProvider engineProvider, IOptions <YMicrosoftIdentityOptions> azureAdOptions)
 {
     this.resourceClient = resourceClient;
     this.client         = client;
     this.engineProvider = engineProvider;
     this.options        = azureAdOptions.Value;
 }
Example #2
0
 public YHttpRequestHandler(IYAuthProvider authProvider, IHttpClientFactory httpClientFactory,
                            IOptions <YGraphOptions> graphOptions,
                            IOptions <YHostOptions> apiOptions,
                            IOptions <YMicrosoftIdentityOptions> azureAdOptions)
 {
     this.authProvider      = authProvider;
     this.httpClientFactory = httpClientFactory;
     this.graphOptions      = graphOptions.Value;
     this.apiOptions        = apiOptions.Value;
     this.azureAdOptions    = azureAdOptions.Value;
 }
Example #3
0
 public EnginesController(IYEngineProvider engineProvider,
                          IYEnginesService enginesService,
                          IYNotificationsService notificationsService,
                          IYHangFireService hangFireService,
                          IOptions <YMicrosoftIdentityOptions> options)
 {
     this.engineProvider       = engineProvider;
     this.enginesService       = enginesService;
     this.notificationsService = notificationsService;
     this.hangFireService      = hangFireService;
     this.options = options.Value;
 }
Example #4
0
 public IndexModel(IYAuthProvider authProvider, IHttpClientFactory httpClientFactory,
                   IConfiguration configuration,
                   IYHttpRequestHandler client, IYResourceClient resourceClient, IOptions <YMicrosoftIdentityOptions> azureAdOptions)
 {
     this.authProvider      = authProvider;
     this.httpClientFactory = httpClientFactory;
     this.configuration     = configuration;
     this.client            = client;
     this.resourceClient    = resourceClient;
     this.httpClient        = this.httpClientFactory.CreateClient();
     this.options           = azureAdOptions.Value;
 }
 public AppInsightsController(IYHttpRequestHandler client,
                              IYEngineProvider engineProvider,
                              DataFactoriesController dataFactoriesController,
                              KeyVaultsController keyVaultsController,
                              IOptions <YMicrosoftIdentityOptions> azureAdOptions)
 {
     this.client                  = client;
     this.engineProvider          = engineProvider;
     this.dataFactoriesController = dataFactoriesController;
     this.keyVaultsController     = keyVaultsController;
     this.options                 = azureAdOptions.Value;
 }
Example #6
0
        /// <summary>
        /// Add Swagger generation, with OAuth2 implicit flow configured with Azure Ad
        /// </summary>
        public static IServiceCollection AddAzureOauth2Swagger(
            this IServiceCollection services,
            IConfiguration configuration,
            string azureOptionsSectionName = "AzureAD",
            string configSectionName       = "YgdraServices")
        {
            var options = new YHostOptions();

            configuration.Bind(configSectionName, options);

            var azureOptions = new YMicrosoftIdentityOptions();

            configuration.Bind(azureOptionsSectionName, azureOptions);


            var scopes = options.GetScopes().Select(scope => $"https://{azureOptions.Domain}/{azureOptions.ClientId}/{scope}");


            // Define the OAuth2.0 scheme that's in use (i.e. Implicit Flow)
            services.AddSwaggerGen(c =>
            {
                c.AddSecurityDefinition("OAuth2", new OpenApiSecurityScheme
                {
                    Type  = SecuritySchemeType.OAuth2,
                    Flows = new OpenApiOAuthFlows
                    {
                        Implicit = new OpenApiOAuthFlow
                        {
                            AuthorizationUrl = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/authorize"),
                            TokenUrl         = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/token"),
                            Scopes           = scopes.ToDictionary(s => s, s => s)
                        }
                    }
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference {
                                Type = ReferenceType.SecurityScheme, Id = "OAuth2"
                            },
                        },
                        scopes.ToList()
                    }
                });
            });

            return(services);
        }
Example #7
0
 public PurviewController(IYAuthProvider authProvider,
                          IOptions <YMicrosoftIdentityOptions> azureAdOptions,
                          IYHttpRequestHandler client,
                          IOptions <YPurviewOptions> hostOptions,
                          IYEngineProvider engineProvider,
                          DataFactoriesController dataFactoriesController)
 {
     this.authProvider      = authProvider;
     this.options           = azureAdOptions.Value;
     this.client            = client;
     this.hostOptions       = hostOptions.Value;
     this.engineProvider    = engineProvider;
     this.factoryController = dataFactoriesController;
 }
 public DataFactoriesController(IYResourceClient resourceClient,
                                IYHttpRequestHandler client,
                                IYEngineProvider engineProvider,
                                IOptions <YMicrosoftIdentityOptions> azureAdOptions,
                                KeyVaultsController keyVaultsController,
                                IYDataSourcesService dataSourcesService,
                                IYAuthProvider authProvider)
 {
     this.resourceClient      = resourceClient;
     this.client              = client;
     this.engineProvider      = engineProvider;
     this.keyVaultsController = keyVaultsController;
     this.dataSourcesService  = dataSourcesService;
     this.authProvider        = authProvider;
     this.options             = azureAdOptions.Value;
 }
Example #9
0
        public YAuthCliProvider(IOptions <YMicrosoftIdentityOptions> azureAdOptions)
        {
            this.AzureAdOptions = azureAdOptions.Value;

            var authority = string.Format(LoginUrlConstant, AzureAdOptions.Domain);

            // Using MASAL to Get access token and id token
            this.pca = PublicClientApplicationBuilder
                       .Create(AzureAdOptions.ClientId)
                       .WithAuthority(authority)
                       .WithDefaultRedirectUri()
                       .Build();

            // Adding cache helper
            TokenCacheHelper.EnableSerialization(pca.UserTokenCache);
        }
Example #10
0
        /// <summary>
        /// Add Swagger UI and inject ClientId parameter used to authenticate
        /// </summary>
        public static IApplicationBuilder UseAzureSwaggerUi(
            this IApplicationBuilder builder,
            string name,
            IConfiguration configuration,
            string configSectionName = "AzureAd")
        {
            var options = new YMicrosoftIdentityOptions();

            configuration.Bind(configSectionName, options);

            builder.UseSwaggerUI(setup =>
            {
                setup.RoutePrefix = "";
                setup.SwaggerEndpoint("/swagger/v1/swagger.json", name);
                setup.OAuthClientId(options.ClientId);
                setup.OAuthAppName("Ygdra");

                // Not needed when using Implicit flow
                // setup.OAuthUseBasicAuthenticationWithAccessCodeGrant();
            });

            return(builder);
        }
Example #11
0
 public YResourceClient(IYAuthProvider authProvider, IYHttpRequestHandler requestHandler, IOptions <YMicrosoftIdentityOptions> options)
 {
     this.authProvider   = authProvider;
     this.requestHandler = requestHandler;
     this.options        = options.Value;
 }
Example #12
0
 public ResourceGroupsController(IYHttpRequestHandler client, IOptions <YMicrosoftIdentityOptions> options)
 {
     this.client  = client;
     this.options = options.Value;
 }