mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 13:28:27 +00:00
Requested changes
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Client as ElasticCacheClient } from "@elastic/elasticsearch";
|
import { Client as ElasticSearchClient } from "@elastic/elasticsearch";
|
||||||
import { customAlphabet } from "nanoid";
|
import { customAlphabet } from "nanoid";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ import { getConfig } from "@app/lib/config/env";
|
|||||||
import { BadRequestError } from "@app/lib/errors";
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
import { alphaNumericNanoId } from "@app/lib/nanoid";
|
import { alphaNumericNanoId } from "@app/lib/nanoid";
|
||||||
|
|
||||||
import { DynamicSecretElasticSearchSchema, TDynamicProviderFns } from "./models";
|
import { DynamicSecretElasticSearchSchema, ElasticSearchAuthTypes, TDynamicProviderFns } from "./models";
|
||||||
|
|
||||||
const generatePassword = () => {
|
const generatePassword = () => {
|
||||||
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*$#";
|
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*$#";
|
||||||
@@ -41,7 +41,7 @@ export const ElasticSearchDatabaseProvider = (): TDynamicProviderFns => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getClient = async (providerInputs: z.infer<typeof DynamicSecretElasticSearchSchema>) => {
|
const getClient = async (providerInputs: z.infer<typeof DynamicSecretElasticSearchSchema>) => {
|
||||||
const connection = new ElasticCacheClient({
|
const connection = new ElasticSearchClient({
|
||||||
node: {
|
node: {
|
||||||
url: new URL(`${providerInputs.host}:${providerInputs.port}`),
|
url: new URL(`${providerInputs.host}:${providerInputs.port}`),
|
||||||
...(providerInputs.ca && {
|
...(providerInputs.ca && {
|
||||||
@@ -52,7 +52,7 @@ export const ElasticSearchDatabaseProvider = (): TDynamicProviderFns => {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
...(providerInputs.auth.type === "api-key"
|
...(providerInputs.auth.type === ElasticSearchAuthTypes.ApiKey
|
||||||
? {
|
? {
|
||||||
apiKey: {
|
apiKey: {
|
||||||
api_key: providerInputs.auth.apiKey,
|
api_key: providerInputs.auth.apiKey,
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ export enum SqlProviders {
|
|||||||
MsSQL = "mssql"
|
MsSQL = "mssql"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum ElasticSearchAuthTypes {
|
||||||
|
User = "user",
|
||||||
|
ApiKey = "api-key"
|
||||||
|
}
|
||||||
|
|
||||||
export const DynamicSecretRedisDBSchema = z.object({
|
export const DynamicSecretRedisDBSchema = z.object({
|
||||||
host: z.string().trim().toLowerCase(),
|
host: z.string().trim().toLowerCase(),
|
||||||
port: z.number(),
|
port: z.number(),
|
||||||
@@ -38,12 +43,12 @@ export const DynamicSecretElasticSearchSchema = z.object({
|
|||||||
// two auth types "user, apikey"
|
// two auth types "user, apikey"
|
||||||
auth: z.discriminatedUnion("type", [
|
auth: z.discriminatedUnion("type", [
|
||||||
z.object({
|
z.object({
|
||||||
type: z.literal("user"),
|
type: z.literal(ElasticSearchAuthTypes.User),
|
||||||
username: z.string().trim(),
|
username: z.string().trim(),
|
||||||
password: z.string().trim()
|
password: z.string().trim()
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
type: z.literal("api-key"),
|
type: z.literal(ElasticSearchAuthTypes.ApiKey),
|
||||||
apiKey: z.string().trim(),
|
apiKey: z.string().trim(),
|
||||||
apiKeyId: z.string().trim()
|
apiKeyId: z.string().trim()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user