Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new fields for authnetication purpose #866

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
"transformAt": "router",
"transformAtV1": "router",
"saveDestinationResponse": true,
"includeKeys": [
"triggerType",
"googleCloudFunctionUrl",
"gcloudAuthorization",
"apiKeyId",
"enableBatchInput",
"oneTrustCookieCategories"
],
"includeKeys": [],
"excludeKeys": [],
"supportedSourceTypes": [
"amp",
Expand All @@ -30,10 +23,10 @@
"supportedMessageTypes": ["identify", "page", "screen", "track", "alias", "group"],
"destConfig": {
"defaultConfig": [
"triggerType",
"functionEnvironment",
"requireAuthentication",
"credentials",
"googleCloudFunctionUrl",
"gcloudAuthorization",
"apiKeyId",
"enableBatchInput",
"maxBatchSize",
"oneTrustCookieCategories"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"configSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"required": ["triggerType"],
"required": ["googleCloudFunctionUrl", "functionEnvironment"],
"type": "object",
"properties": {
"triggerType": { "type": "string", "enum": ["Http", "Https"] },
"apiKeyId": {
"googleCloudFunctionUrl": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|(?!.*\\.ngrok\\.io)^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$"
},
"functionEnvironment": { "type": "string", "enum": ["gen1", "gen2"] },
"requireAuthentication": { "type": "boolean", "default": true },
"enableBatchInput": { "type": "boolean", "default": false },
"oneTrustCookieCategories": {
"type": "array",
Expand All @@ -24,35 +25,19 @@
}
},
"allOf": [
{
"if": { "properties": { "triggerType": { "const": "Http" } }, "required": ["triggerType"] },
"then": {
"properties": {
"googleCloudFunctionUrl": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|(?!.*\\.ngrok\\.io)^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$"
}
},
"required": ["googleCloudFunctionUrl"]
}
},
{
"if": {
"properties": { "triggerType": { "const": "Https" } },
"required": ["triggerType"]
"properties": { "requireAuthentication": { "const": true } },
"required": ["requireAuthentication"]
},
"then": {
"properties": {
"googleCloudFunctionUrl": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|(?!.*\\.ngrok\\.io)^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$"
},
"gcloudAuthorization": {
"credentials": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|.*"
}
},
"required": ["googleCloudFunctionUrl", "gcloudAuthorization"]
"required": ["credentials"]
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,8 @@
{
"title": "Connection Settings",
"fields": [
{
"type": "singleSelect",
"label": "Choose your Trigger Type ",
"value": "triggerType",
"options": [
{ "name": "HTTP", "value": "Http" },
{ "name": "HTTPS", "value": "Https" }
],
"required": true
},
{
"type": "textInput",
"preRequisiteField": [{ "name": "triggerType", "selectedValue": "Http" }],
"label": "URL",
"value": "googleCloudFunctionUrl",
"required": true,
Expand All @@ -24,36 +13,30 @@
"footerNote": "The Url given under Trigger section when you create Google Cloud Function"
},
{
"type": "textInput",
"preRequisiteField": [{ "name": "triggerType", "selectedValue": "Https" }],
"label": "URL",
"value": "googleCloudFunctionUrl",
"required": true,
"placeholder": "http://www.abcd.com",
"regex": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|(?!.*\\.ngrok\\.io)^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$",
"footerNote": "The Url given under Trigger section when you create Google Cloud Function"
"type": "singleSelect",
"label": "Choose your function environment",
"value": "functionEnvironment",
"options": [
{ "name": "1st gen", "value": "gen1" },
{ "name": "2nd gen", "value": "gen2" }
],
"required": true
},
{
"type": "textInput",
"preRequisiteField": [{ "name": "triggerType", "selectedValue": "Https" }],
"label": "Gcloud Authorization",
"value": "gcloudAuthorization",
"regex": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|.*",
"required": true,
"placeholder": "e.g. tZrPAgHyn2jMWOVGKrS6gBGLYT8v9kJE",
"secret": true,
"footerNote": "Your private Gcloud Authorization Token"
"type": "checkbox",
"label": "Enable it if your function requires authentication",
"value": "requireAuthentication",
"default": true
},
{
"type": "textInput",
"label": "Api Key Id",
"value": "apiKeyId",
"regex": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$",
"regexErrorMessage": "Invalid Api Key Id",
"required": false,
"placeholder": "e.g: bSjsdGYsOo9sjw23Shj",
"secret": true,
"footerNote": "Your API Key"
"type": "textareaInput",
"preRequisiteField": [{ "name": "requireAuthentication", "selectedValue": true }],
"label": "Credentials",
"labelNote": "GCP Service Account credentials JSON for RudderStack to use in authenticating your Google Cloud Function",
"value": "credentials",
"regex": ".*",
"required": true,
"footerNote": "The credentials JSON is used by the client library to access the Google Cloud Fucction API"
}
]
},
Expand Down
11 changes: 5 additions & 6 deletions test/data/validation/destinations/google_cloud_function.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
[
{
"config": {
"triggerType": "Http",
"functionEnvironment": "gen1",
"googleCloudFunctionUrl": "http://sample.com/url",
"apiKeyId": "1d6583b196d34de28a3g19ahadde4b0z"
"requireAuthentication": false
},
"result": true
},
{
"config": {
"triggerType": "Http",
"functionEnvironment": "gen1",
"googleCloudFunctionUrl": "htp://sample.com/url",
"apiKeyId": "1d6583b196d34de28a3g19ahadde4b0z"
"requireAuthentication": false
},
"result": false,
"err": [
"googleCloudFunctionUrl must match pattern \"(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|(?!.*\\.ngrok\\.io)^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$\"",
" must match \"then\" schema"
"googleCloudFunctionUrl must match pattern \"(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|(?!.*\\.ngrok\\.io)^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$\""
]
}
]