コード例 #1
0
 public AuthenticationHelper(ISettingsHelper settingsHelper, IAuthBroker authBroker, ISecretsProvider secretsProvider, IHttpClient httpClient)
 {
     SettingsHelper       = settingsHelper;
     AuthBroker           = authBroker;
     this.secretsProvider = secretsProvider;
     this.httpClient      = httpClient;
 }
コード例 #2
0
        public QueryCommand(ISecretsProvider secrets)
        {
            this.secrets = secrets;

            Command = new Command("query", "Make a SQL query and retrieve up to 1000 rows")
            {
                new Argument <string>("query")
                {
                    Arity       = ArgumentArity.ExactlyOne,
                    Description = "The SQL query to run",
                },
                new Option <long>(
                    alias: "--source-limit",
                    description: "Maximum number of rows to read from each data source. " +
                    "Values lower than 1 will disable this limit. Default: 100",
                    getDefaultValue: () => 100
                    ),
                new Option <long>(
                    alias: "--infer-schema-limit",
                    description: "Maximum number of rows to read for inferring schema from RAW tables. " +
                    "Values lower than 1 will disable this limit. Default: 100",
                    getDefaultValue: () => 100
                    ),
            };
            Command.Handler = CommandHandler.Create <string, string, long, long>(Handle);
        }
コード例 #3
0
 public SecretsHelper(ISettingsHelper settingsHelper, AuthenticationHelper authHelper, IVault vault, ISecretsProvider secretsProvider)
 {
     SettingsHelper       = settingsHelper;
     AuthenticationHelper = authHelper;
     this.vault           = vault;
     this.secretsProvider = secretsProvider;
 }
コード例 #4
0
        /// <summary>
        /// Gets blob credentials from the given secrets provider
        /// </summary>
        public static async Task <AzureBlobStorageCredentials> GetBlobCredentialsAsync(
            this ISecretsProvider secretsProvider,
            string secretName,
            bool useSasTokens,
            CancellationToken token)
        {
            if (useSasTokens)
            {
                var secrets = await secretsProvider.RetrieveSecretsAsync(new List <RetrieveSecretsRequest>()
                {
                    new RetrieveSecretsRequest(secretName, SecretKind.SasToken)
                }, token);

                return(new AzureBlobStorageCredentials((UpdatingSasToken)secrets.Secrets[secretName]));
            }
            else
            {
                var secrets = await secretsProvider.RetrieveSecretsAsync(new List <RetrieveSecretsRequest>()
                {
                    new RetrieveSecretsRequest(secretName, SecretKind.PlainText)
                }, token);

                return(new AzureBlobStorageCredentials((PlainTextSecret)secrets.Secrets[secretName]));
            }
        }
コード例 #5
0
        public RunCommand(ISecretsProvider secrets)
        {
            this.secrets = secrets;

            Command = new Command("run", "Start and/or watch transformation jobs")
            {
                new Option <int?>("--id")
                {
                    Description = "The id of the transformation to run. Either this or --external-id must be specified."
                },
                new Option <string>("--external-id")
                {
                    Description = "The externalId of the transformation to run. Either this or --id must be specified."
                },
                new Option <bool>("--watch")
                {
                    Description = "Wait until job has completed"
                },
                new Option <bool>("--watch-only")
                {
                    Description = "Do not start a transformation job, only watch the most recent job for completion"
                },
                new Option <TimeSpan>("--timeout", () => TimeSpan.FromHours(12))
                {
                    Description = "Maximum amount of time to wait for job to complete"
                },
                new Option <TimeSpan>("--interval", () => TimeSpan.FromSeconds(5))
                {
                    Description = "Time interval for polling job status"
                }
            };
            Command.Handler = CommandHandler.Create(
                (Func <IConsole, string, int?, string, bool, bool, TimeSpan, TimeSpan, Task <int> >)Handle
                );
        }
コード例 #6
0
        public static IJetfireClient CreateClient(ISecretsProvider secrets, string cluster)
        {
            var baseUri     = GetBaseUriFromCluster(secrets, cluster);
            var credentials = GetCredentials(secrets);

            return(new JetfireClient(baseUri, credentials));
        }
コード例 #7
0
        public ListCommand(ISecretsProvider secrets)
        {
            Secrets = secrets;

            Command = new Command("list", "List transformations");

            Command.Handler = CommandHandler.Create <string>(Handle);
        }
コード例 #8
0
        /// <summary>
        /// Gets the plain secret for the given secret name
        /// </summary>
        public static async Task <string> GetPlainSecretAsync(this ISecretsProvider secretsProvider, string secretName, CancellationToken token)
        {
            var secrets = await secretsProvider.RetrieveSecretsAsync(new List <RetrieveSecretsRequest>()
            {
                new RetrieveSecretsRequest(secretName, SecretKind.PlainText)
            }, token);

            return(((PlainTextSecret)secrets.Secrets[secretName]).Secret);
        }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SecretsConfigurationProvider"/> class.
 /// </summary>
 /// <param name="secretsProvider">
 /// An object that provides the secrets that make up the settings of this instance.
 /// </param>
 public SecretsConfigurationProvider(ISecretsProvider secretsProvider)
 {
     foreach (var secret in secretsProvider.Secrets)
     {
         string value;
         try { value = secret.GetValue(); }
         catch { continue; }
         Data.Add(secret.Key, value);
     }
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of <see cref="DefaultConfigProvider"/>
 /// </summary>
 public DefaultConfigProvider(
     string basePath,
     ISecretsProvider secretsProvider)
 {
     _secretsProvider = secretsProvider;
     _secretsAnalyzer = new SecretsAnalyzer(secretsProvider);
     ConfigsPath      = Path.Combine(basePath, "configs");
     OverridesPath    = Path.Combine(basePath, "overrides");
     IncludePath      = Path.Combine(basePath, "includes");
 }
コード例 #11
0
        private async void Init(ISecretsProvider secretsProvider)
        {
            var allConfig = await secretsProvider.GetSecrets();

            var config = allConfig["Ad_Config"];

            appKey   = (string)config["App_Key"];
            bannerId = (string)config["Banner_Id"];
            AdDuplex.AdDuplexClient.Initialize(appKey);
        }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OpenTibiaCosmosDbContext"/> class.
        /// </summary>
        /// <param name="cosmosDbConfigurationOptions">A reference to the CosmosDb configuration options.</param>
        /// <param name="secretsProvider">A reference to the secrets provider.</param>
        public OpenTibiaCosmosDbContext(
            IOptions <CosmosDbConfigurationOptions> cosmosDbConfigurationOptions,
            ISecretsProvider secretsProvider)
        {
            cosmosDbConfigurationOptions.ThrowIfNull(nameof(cosmosDbConfigurationOptions));
            secretsProvider.ThrowIfNull(nameof(secretsProvider));

            this.CosmosDbConfiguration = cosmosDbConfigurationOptions.Value;
            this.SecretsProvider       = secretsProvider;
        }
コード例 #13
0
        public SecretAnalyzerBehavior()
        {
            var mock = new Mock <ISecretsProvider>();

            mock
            .Setup(sp => sp.Provide())
            .Returns(() => new Dictionary <string, string> {
                { "some-secret1", "some-val1" }
            });
            _secretsProvider = mock.Object;
        }
コード例 #14
0
        /// <inheritdoc />
        public LoggerFactoryArguments(
            ILogger logger,
            ISecretsProvider secretsProvider,
            LoggingSettings loggingSettings)
        {
            Contract.RequiresNotNull(logger);

            Logger          = logger;
            LoggingSettings = loggingSettings;
            SecretsProvider = secretsProvider;
        }
コード例 #15
0
 static Uri GetBaseUriFromCluster(ISecretsProvider secrets, string cluster)
 {
     if (cluster == "localhost")
     {
         return(new Uri("http://localhost:8084"));
     }
     if (string.IsNullOrWhiteSpace(cluster))
     {
         cluster = secrets.GetNamedSecret(ClusterEnvironmentVariable) ?? "europe-west1-1";
     }
     return(new Uri($"https://jetfire.{cluster}.cogniteapp.com"));
 }
コード例 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FibulaCosmosDbContext"/> class.
        /// </summary>
        /// <param name="cosmosDbContextOptions">A reference to the CosmosDb context options.</param>
        /// <param name="secretsProvider">A reference to the secrets provider.</param>
        public FibulaCosmosDbContext(
            IOptions <FibulaCosmosDbContextOptions> cosmosDbContextOptions,
            ISecretsProvider secretsProvider)
        {
            cosmosDbContextOptions.ThrowIfNull(nameof(cosmosDbContextOptions));
            secretsProvider.ThrowIfNull(nameof(secretsProvider));

            DataAnnotationsValidator.ValidateObjectRecursive(cosmosDbContextOptions.Value);

            this.Options         = cosmosDbContextOptions.Value;
            this.SecretsProvider = secretsProvider;
        }
コード例 #17
0
 public JwtTokenService(
     ISecretsProvider secretsProvider,
     IClaimsProvider claimsProvider,
     IJwtTokenProvider jwtTokenProvider,
     ISecurityKeyProvider securityKeyProvider,
     TokenServiceSettings tokenServiceSettings)
 {
     _secretsProvider      = secretsProvider;
     _claimsProvider       = claimsProvider;
     _jwtTokenProvider     = jwtTokenProvider;
     _securityKeyProvider  = securityKeyProvider;
     _tokenServiceSettings = tokenServiceSettings;
 }
コード例 #18
0
        public DeployCommand(ISecretsProvider secrets)
        {
            this.secrets = secrets;

            Command = new Command("deploy", "Deploy a set of transformations from a directory")
            {
                new Argument <string>("path", Directory.GetCurrentDirectory)
                {
                    Arity       = ArgumentArity.ZeroOrOne,
                    Description = "A directory to search for transformation manifests. If omitted, the current directory is used.",
                },
            };
            Command.Handler = CommandHandler.Create <IConsole, string, string>(Handle);
        }
コード例 #19
0
 public SignInService(
     IPlatformClient platformClient,
     ILoggerFactory loggerFactory,
     IAuthenticationServiceErrorHandler serviceErrorHandler,
     IConnectivityService connectivityService,
     ISecretsProvider secretsProvider,
     IAuthenticationInfoService authenticationInfoService)
 {
     _platformClient            = platformClient;
     _serviceErrorHandler       = serviceErrorHandler;
     _connectivityService       = connectivityService;
     _secretsProvider           = secretsProvider;
     _authenticationInfoService = authenticationInfoService;
     _logger = loggerFactory.CreateLogger <SignInService>();
 }
コード例 #20
0
        public OnBoardingViewModel(
            INavigationService navigationService,
            IMainRoute mainRoute,
            INotificationManager notificationManager,
            ITracingEngine tracingEngine,
            ISecretsProvider secretsProvider)
        {
            GoToNextStepCommand = ReactiveUI.ReactiveCommand.CreateFromTask(HandleNextStepAsync);

            _navigationService   = navigationService;
            _mainRoute           = mainRoute;
            _notificationManager = notificationManager;
            _tracingEngine       = tracingEngine;
            _secretsProvider     = secretsProvider;
            SetInstructions();
        }
コード例 #21
0
        public JobsCommand(ISecretsProvider secrets)
        {
            Secrets = secrets;
            Command = new Command("jobs", "Show latest jobs for a given transformation")
            {
                new Option <int?>("--id")
                {
                    Description = "The id of the transformation. Either this or --external-id must be specified."
                },
                new Option <string>("--external-id")
                {
                    Description = "The externalId of the transformation. Either this or --id must be specified."
                },
            };

            Command.Handler = CommandHandler.Create <string, int?, string>(Handle);
        }
コード例 #22
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddHostedService <SecretsWatcherHostedService>();
            services.AddControllers();
            var clientOptions = K8sConfig.Load(@"C:\Users\linjm\.kube\config").ToKubeClientOptions(
                defaultKubeNamespace: "default"
                );

            services.AddSingleton <KubeClientOptions>(clientOptions);

            var providers = new ISecretsProvider[]
            {
                new SecretsProvider()
            };

            services.AddSingleton <IEnumerable <ISecretsProvider> >(providers);
        }
コード例 #23
0
        public OpenIdConnectHandler(
            IUsersService usersService,
            ISecretsProvider secretsProvider,
            ISystem system,
            ILogWriterFactory logWriterFactory)
        {
            if (logWriterFactory is null)
            {
                throw new ArgumentNullException(nameof(logWriterFactory));
            }

            logger               = logWriterFactory.CreateLogger <OpenIdConnectHandler>();
            this.usersService    = usersService ?? throw new ArgumentNullException(nameof(usersService));
            this.secretsProvider = secretsProvider ?? throw new ArgumentNullException(nameof(secretsProvider));
            this.system          = system ?? throw new ArgumentNullException(nameof(system));
            authHostName         = new Lazy <Task <string> >(GetAuthHostName);
            cognitoSettings      = new Lazy <CognitoSettings>(() => GetCognitoSettings().SafeGetResult());
        }
コード例 #24
0
        public DeleteCommand(ISecretsProvider secrets)
        {
            this.secrets = secrets;

            Command = new Command("delete", "Delete a transformation")
            {
                new Option <int?>("--id")
                {
                    Description = "The id of the transformation to delete. Either this or --external-id must be specified."
                },
                new Option <string>("--external-id")
                {
                    Description = "The externalId of the transformation to delete. Either this or --id must be specified."
                },
            };

            Command.Handler = CommandHandler.Create <string, int?, string>(Handle);
        }
コード例 #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BotHttpAdapter"/> class.
        /// </summary>
        /// <param name="appSettings">App settings.</param>
        /// <param name="credentialProvider">Cred provider.</param>
        /// <param name="secretsProvider">Secrets provider..</param>
        /// <param name="middleWare">Auth middleware.</param>
        /// <param name="logger">Logger.</param>
        public BotHttpAdapter(
            IAppSettings appSettings,
            ICredentialProvider credentialProvider,
            ISecretsProvider secretsProvider,
            BotAuthMiddleware middleWare,
            ILogger <BotHttpAdapter> logger)
            : base(credentialProvider)
        {
            if (middleWare is null)
            {
                throw new ArgumentNullException(nameof(middleWare));
            }

            this.Use(middleWare);
            this.appSettings     = appSettings ?? throw new ArgumentNullException(nameof(appSettings));
            this.secretsProvider = secretsProvider ?? throw new ArgumentNullException(nameof(secretsProvider));
            this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
        }
コード例 #26
0
        public static void ApplySecrets(this ConfigDocument doc, ISecretsProvider secretsProvider)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }
            if (secretsProvider == null)
            {
                throw new ArgumentNullException(nameof(secretsProvider));
            }

            var secretMap = secretsProvider.Provide();

            foreach (var secret in doc.GetSecrets())
            {
                if (secretMap.TryGetValue(secret.Key, out var secretVal))
                {
                    secret.Resolve(secretVal);
                }
            }
        }
コード例 #27
0
        public ShowCommand(ISecretsProvider secrets)
        {
            Secrets = secrets;

            Command = new Command("show", "Show detalis of a transformation")
            {
                new Option <int?>("--id")
                {
                    Description = "The id of the transformation to show. Either this or --external-id must be specified."
                },
                new Option <string>("--external-id")
                {
                    Description = "The externalId of the transformation to show. Either this or --id must be specified."
                },
                new Option <string>("--job")
                {
                    Description = "The UUID of the job to show. Include this to show job details instead of transformation details."
                },
            };

            Command.Handler = CommandHandler.Create <string, int?, string, string>(Handle);
        }
コード例 #28
0
        static ICredentials GetCredentials(ISecretsProvider secrets)
        {
            var apiKey = secrets.GetNamedSecret(ApiKeyEnvironmentVariable).TrimToNull();

            var tokenUrl      = secrets.GetNamedSecret(TokenUrlEnvironmentVariable).TrimToNull();
            var clientId      = secrets.GetNamedSecret(ClientIdEnvironmentVariable).TrimToNull();
            var clientSecret  = secrets.GetNamedSecret(ClientSecretEnvironmentVariable).TrimToNull();
            var tokenScopes   = secrets.GetNamedSecret(TokenScopesEnvironmentVariable).TrimToNull();
            var tokenAudience = secrets.GetNamedSecret(TokenAudienceEnvironmentVariable).TrimToNull();
            var project       = secrets.GetNamedSecret(ProjectEnvironmentVariable).TrimToNull();

            if (apiKey != null)
            {
                return(new ApiKeyCredentials(apiKey));
            }
            else if (tokenUrl != null && clientId != null && clientSecret != null && project != null)
            {
                var scopeList = new List <string>();
                if (tokenScopes != null && tokenScopes != "")
                {
                    scopeList = new List <string>(tokenScopes.Split(","));
                }

                var authConfig = new AuthenticatorConfig
                {
                    Implementation = AuthenticatorConfig.AuthenticatorImplementation.Basic,
                    ClientId       = clientId,
                    Secret         = clientSecret,
                    TokenUrl       = tokenUrl,
                    Scopes         = scopeList,
                    Audience       = tokenAudience
                };
                return(new TokenCredentials(authConfig, project));
            }
            else
            {
                throw new JetfireCliException($"Either the {ApiKeyEnvironmentVariable} environment variable, or the {TokenUrlEnvironmentVariable}, {ClientIdEnvironmentVariable}, {ClientSecretEnvironmentVariable}, {TokenScopesEnvironmentVariable} and {ProjectEnvironmentVariable} environment variables must be set");
            }
        }
コード例 #29
0
 public ManifestResolver(ISecretsProvider secrets)
 {
     this.secrets = secrets;
 }
コード例 #30
0
 public RetryableSecretsProviderDecorator(ISecretsProvider secretsProvider) : base(secretsProvider)
 {
 }