feat: handle different aws auth resource type (#5637)

* feat: oidc auth with sqs

* rafctor

* update: add id token struct

* update has_expired function

* fix duration

* fix typo

* Update backend/windmill-common/src/auth.rs

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>

* Update backend/windmill-common/src/auth.rs

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* update ref

* update sqlx

* update resource type

* update repo ref

* Update settings.json

* add new resource type

* update repo ref and clear resource path on resource type change

* update .sqlx

* add missing key

---------

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
dieriba
2025-04-17 21:51:18 +02:00
committed by GitHub
parent da13014c41
commit 5b123b01a1
24 changed files with 322 additions and 181 deletions
+4 -12
View File
@@ -1,13 +1,5 @@
DATABASE_URL=postgres://postgres:changeme@db/windmill?sslmode=disable
DATABASE_URL=postgres://postgres:changeme@localhost:5432/windmill?sslmode=disable
DENO_PATH=/opt/homebrew/bin/deno
BUN_PATH=/opt/homebrew/bin/bun
# For Enterprise Edition, use:
# WM_IMAGE=ghcr.io/windmill-labs/windmill-ee:main
WM_IMAGE=ghcr.io/windmill-labs/windmill:main
# To use another port than :80, setup the Caddyfile and the caddy section of the docker-compose to your needs: https://caddyserver.com/docs/getting-started
# To have caddy take care of automatic TLS
# To rotate logs, set the following variables:
#LOG_MAX_SIZE=10m
#LOG_MAX_FILE=3
WM_IMAGE=ghcr.io/windmill-labs/windmill:main
@@ -1,80 +1,95 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n aws_resource_path,\n message_attributes,\n queue_url,\n workspace_id,\n path,\n script_path,\n is_flow,\n edited_by,\n email,\n edited_at,\n server_id,\n last_server_ping,\n extra_perms,\n error,\n enabled\n FROM \n sqs_trigger\n WHERE \n workspace_id = $1 AND \n path = $2\n ",
"query": "\n SELECT\n aws_auth_resource_type AS \"aws_auth_resource_type: _\",\n aws_resource_path,\n message_attributes,\n queue_url,\n workspace_id,\n path,\n script_path,\n is_flow,\n edited_by,\n email,\n edited_at,\n server_id,\n last_server_ping,\n extra_perms,\n error,\n enabled\n FROM \n sqs_trigger\n WHERE \n workspace_id = $1 AND \n path = $2\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "aws_auth_resource_type: _",
"type_info": {
"Custom": {
"name": "aws_auth_resource_type",
"kind": {
"Enum": [
"oidc",
"credentials"
]
}
}
}
},
{
"ordinal": 1,
"name": "aws_resource_path",
"type_info": "Varchar"
},
{
"ordinal": 1,
"ordinal": 2,
"name": "message_attributes",
"type_info": "TextArray"
},
{
"ordinal": 2,
"ordinal": 3,
"name": "queue_url",
"type_info": "Varchar"
},
{
"ordinal": 3,
"ordinal": 4,
"name": "workspace_id",
"type_info": "Varchar"
},
{
"ordinal": 4,
"ordinal": 5,
"name": "path",
"type_info": "Varchar"
},
{
"ordinal": 5,
"ordinal": 6,
"name": "script_path",
"type_info": "Varchar"
},
{
"ordinal": 6,
"ordinal": 7,
"name": "is_flow",
"type_info": "Bool"
},
{
"ordinal": 7,
"ordinal": 8,
"name": "edited_by",
"type_info": "Varchar"
},
{
"ordinal": 8,
"ordinal": 9,
"name": "email",
"type_info": "Varchar"
},
{
"ordinal": 9,
"ordinal": 10,
"name": "edited_at",
"type_info": "Timestamptz"
},
{
"ordinal": 10,
"ordinal": 11,
"name": "server_id",
"type_info": "Varchar"
},
{
"ordinal": 11,
"ordinal": 12,
"name": "last_server_ping",
"type_info": "Timestamptz"
},
{
"ordinal": 12,
"ordinal": 13,
"name": "extra_perms",
"type_info": "Jsonb"
},
{
"ordinal": 13,
"ordinal": 14,
"name": "error",
"type_info": "Text"
},
{
"ordinal": 14,
"ordinal": 15,
"name": "enabled",
"type_info": "Bool"
}
@@ -86,6 +101,7 @@
]
},
"nullable": [
false,
false,
true,
false,
@@ -103,5 +119,5 @@
false
]
},
"hash": "2ef82fad8a6ccdc66228cfbce5393de351653ab9ac171fa0eea447c905440867"
"hash": "5237f9d3f57f4e799968a4a9630c984775d23c7a4dc1a7ad37528a46ab89d6bd"
}
@@ -1,23 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "SELECT jsonb_build_object(\n 'kind', jb.kind,\n 'script_path', jb.runnable_path,\n 'latest_schema', COALESCE(\n (SELECT DISTINCT ON (s.path) s.schema FROM script s WHERE s.path = jb.runnable_path AND jb.kind = 'script' ORDER BY s.path, s.created_at DESC),\n (SELECT flow_version.schema FROM flow LEFT JOIN flow_version ON flow_version.id = flow.versions[array_upper(flow.versions, 1)] WHERE flow.path = jb.runnable_path AND jb.kind = 'flow')\n ),\n 'schemas', ARRAY(\n SELECT jsonb_build_object(\n 'script_hash', LPAD(TO_HEX(COALESCE(s.hash, f.id)), 16, '0'),\n 'job_ids', ARRAY_AGG(DISTINCT j.id),\n 'schema', ANY_VALUE(COALESCE(s.schema, f.schema))\n ) FROM v2_job j\n LEFT JOIN script s ON s.hash = j.runnable_id AND j.kind = 'script'\n LEFT JOIN flow_version f ON f.id = j.runnable_id AND j.kind = 'flow'\n WHERE j.id = ANY(ARRAY_AGG(jb.id))\n GROUP BY COALESCE(s.hash, f.id)\n )\n ) FROM v2_job jb\n WHERE (jb.kind = 'flow' OR jb.kind = 'script')\n AND jb.workspace_id = $1 AND jb.id = ANY($2)\n GROUP BY jb.kind, jb.runnable_path",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "jsonb_build_object",
"type_info": "Jsonb"
}
],
"parameters": {
"Left": [
"Text",
"UuidArray"
]
},
"nullable": [
null
]
},
"hash": "5ea1d8c87a17690942ca9e70e0b953e3b32a9a7a73784219d48f8e8932cdb0c8"
}
@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO global_settings (name, value)\n VALUES ('rsa_keys', $1)\n ON CONFLICT (name) DO UPDATE\n SET value = EXCLUDED.value\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Jsonb"
]
},
"nullable": []
},
"hash": "65e6aa50db7cb878ce456d6665a4809e7b7f2c1b0d53b10da3b5578d337e28ec"
}
@@ -0,0 +1,34 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO sqs_trigger (\n aws_auth_resource_type,\n aws_resource_path,\n queue_url,\n message_attributes,\n workspace_id, \n path, \n script_path, \n is_flow, \n email, \n enabled, \n edited_by\n ) \n VALUES (\n $1, \n $2, \n $3, \n $4, \n $5, \n $6, \n $7,\n $8,\n $9,\n $10,\n $11\n )",
"describe": {
"columns": [],
"parameters": {
"Left": [
{
"Custom": {
"name": "aws_auth_resource_type",
"kind": {
"Enum": [
"oidc",
"credentials"
]
}
}
},
"Varchar",
"Varchar",
"TextArray",
"Varchar",
"Varchar",
"Varchar",
"Bool",
"Varchar",
"Bool",
"Varchar"
]
},
"nullable": []
},
"hash": "776909d3452aaf9e0ed41a5ec314b7bfc5bc8b6a76c98bf4daf7d715d18c52e6"
}
@@ -0,0 +1,34 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE \n sqs_trigger \n SET \n aws_auth_resource_type = $1,\n aws_resource_path = $2,\n queue_url = $3,\n message_attributes = $4, \n is_flow = $5, \n edited_by = $6, \n email = $7,\n script_path = $8,\n path = $9,\n edited_at = now(), \n error = NULL,\n server_id = NULL\n WHERE \n workspace_id = $10 AND \n path = $11\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
{
"Custom": {
"name": "aws_auth_resource_type",
"kind": {
"Enum": [
"oidc",
"credentials"
]
}
}
},
"Varchar",
"Varchar",
"TextArray",
"Bool",
"Varchar",
"Varchar",
"Varchar",
"Varchar",
"Text",
"Text"
]
},
"nullable": []
},
"hash": "8490024b96aa689d3c1bc5cbf94fcd8c5491732818404fee2397f00cccee0ad3"
}
@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO global_settings (name, value) VALUES ('rsa_keys', $1)",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Jsonb"
]
},
"nullable": []
},
"hash": "85c116da4a43a5ade37bb9ab2660d206b722ec4192368599c3a5027f50a89c80"
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT workspace_id, path, url, script_path, is_flow, edited_by, email, edited_at, server_id, last_server_ping, extra_perms, error, enabled, filters as \"filters: _\", initial_messages as \"initial_messages: _\", url_runnable_args as \"url_runnable_args: _\", can_return_message FROM websocket_trigger\n WHERE workspace_id = $1",
"query": "\n SELECT \n workspace_id,\n path,\n url,\n script_path,\n is_flow,\n edited_by,\n email,\n edited_at,\n server_id,\n last_server_ping,\n extra_perms,\n error,\n enabled,\n filters AS \"filters: _\",\n initial_messages AS \"initial_messages: _\",\n url_runnable_args AS \"url_runnable_args: _\",\n can_return_message\n FROM \n websocket_trigger\n WHERE \n workspace_id = $1\n ",
"describe": {
"columns": [
{
@@ -114,5 +114,5 @@
false
]
},
"hash": "1aa8ead10f8d994f6685d266fcbd409b0fff43111d9600e64b2348401ed8929d"
"hash": "8eabeee5527da4aad3f46ad185015262b4304667449f3e1a71efd7477a39f7fc"
}
@@ -1,23 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO sqs_trigger (\n aws_resource_path,\n queue_url,\n message_attributes,\n workspace_id, \n path, \n script_path, \n is_flow, \n email, \n enabled, \n edited_by\n ) \n VALUES (\n $1, \n $2, \n $3, \n $4, \n $5, \n $6, \n $7,\n $8,\n $9,\n $10\n )",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Varchar",
"Varchar",
"TextArray",
"Varchar",
"Varchar",
"Varchar",
"Bool",
"Varchar",
"Bool",
"Varchar"
]
},
"nullable": []
},
"hash": "9b9bc21023f10a0b4bb45879c7da8e119bffd2982b97fc900358506a0a14bbb8"
}
@@ -1,80 +1,95 @@
{
"db_name": "PostgreSQL",
"query": "SELECT * FROM sqs_trigger\n WHERE workspace_id = $1",
"query": "\n SELECT\n aws_auth_resource_type AS \"aws_auth_resource_type: _\",\n aws_resource_path,\n message_attributes,\n queue_url,\n workspace_id,\n path,\n script_path,\n is_flow,\n edited_by,\n email,\n edited_at,\n server_id,\n last_server_ping,\n extra_perms,\n error,\n enabled\n FROM \n sqs_trigger\n WHERE \n workspace_id = $1\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "path",
"type_info": "Varchar"
"name": "aws_auth_resource_type: _",
"type_info": {
"Custom": {
"name": "aws_auth_resource_type",
"kind": {
"Enum": [
"oidc",
"credentials"
]
}
}
}
},
{
"ordinal": 1,
"name": "queue_url",
"type_info": "Varchar"
},
{
"ordinal": 2,
"name": "aws_resource_path",
"type_info": "Varchar"
},
{
"ordinal": 3,
"ordinal": 2,
"name": "message_attributes",
"type_info": "TextArray"
},
{
"ordinal": 4,
"name": "script_path",
"ordinal": 3,
"name": "queue_url",
"type_info": "Varchar"
},
{
"ordinal": 5,
"name": "is_flow",
"type_info": "Bool"
},
{
"ordinal": 6,
"ordinal": 4,
"name": "workspace_id",
"type_info": "Varchar"
},
{
"ordinal": 5,
"name": "path",
"type_info": "Varchar"
},
{
"ordinal": 6,
"name": "script_path",
"type_info": "Varchar"
},
{
"ordinal": 7,
"name": "is_flow",
"type_info": "Bool"
},
{
"ordinal": 8,
"name": "edited_by",
"type_info": "Varchar"
},
{
"ordinal": 8,
"ordinal": 9,
"name": "email",
"type_info": "Varchar"
},
{
"ordinal": 9,
"ordinal": 10,
"name": "edited_at",
"type_info": "Timestamptz"
},
{
"ordinal": 10,
"name": "extra_perms",
"type_info": "Jsonb"
},
{
"ordinal": 11,
"name": "error",
"type_info": "Text"
},
{
"ordinal": 12,
"name": "server_id",
"type_info": "Varchar"
},
{
"ordinal": 13,
"ordinal": 12,
"name": "last_server_ping",
"type_info": "Timestamptz"
},
{
"ordinal": 13,
"name": "extra_perms",
"type_info": "Jsonb"
},
{
"ordinal": 14,
"name": "error",
"type_info": "Text"
},
{
"ordinal": 15,
"name": "enabled",
"type_info": "Bool"
}
@@ -85,7 +100,6 @@
]
},
"nullable": [
false,
false,
false,
true,
@@ -95,6 +109,8 @@
false,
false,
false,
false,
false,
true,
true,
true,
@@ -102,5 +118,5 @@
false
]
},
"hash": "2b6c13191484b0c664f35e2c811082b00c44fd4a7e98a11b714133674a7b6da7"
"hash": "a7df493316f632fc636e4c3c90bef4c98035b5dc808bb8379251c0b35d945ba0"
}
@@ -1,80 +1,95 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n queue_url,\n aws_resource_path,\n message_attributes,\n workspace_id,\n path,\n script_path,\n is_flow,\n edited_by,\n email,\n edited_at,\n server_id,\n last_server_ping,\n extra_perms,\n error,\n enabled\n FROM\n sqs_trigger\n WHERE\n enabled IS TRUE\n AND (last_server_ping IS NULL OR\n last_server_ping < now() - interval '15 seconds'\n )\n ",
"query": "\n SELECT\n aws_auth_resource_type AS \"aws_auth_resource_type: _\",\n queue_url,\n aws_resource_path,\n message_attributes,\n workspace_id,\n path,\n script_path,\n is_flow,\n edited_by,\n email,\n edited_at,\n server_id,\n last_server_ping,\n extra_perms,\n error,\n enabled\n FROM\n sqs_trigger\n WHERE\n enabled IS TRUE\n AND (last_server_ping IS NULL OR\n last_server_ping < now() - interval '15 seconds'\n )\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "aws_auth_resource_type: _",
"type_info": {
"Custom": {
"name": "aws_auth_resource_type",
"kind": {
"Enum": [
"oidc",
"credentials"
]
}
}
}
},
{
"ordinal": 1,
"name": "queue_url",
"type_info": "Varchar"
},
{
"ordinal": 1,
"ordinal": 2,
"name": "aws_resource_path",
"type_info": "Varchar"
},
{
"ordinal": 2,
"ordinal": 3,
"name": "message_attributes",
"type_info": "TextArray"
},
{
"ordinal": 3,
"ordinal": 4,
"name": "workspace_id",
"type_info": "Varchar"
},
{
"ordinal": 4,
"ordinal": 5,
"name": "path",
"type_info": "Varchar"
},
{
"ordinal": 5,
"ordinal": 6,
"name": "script_path",
"type_info": "Varchar"
},
{
"ordinal": 6,
"ordinal": 7,
"name": "is_flow",
"type_info": "Bool"
},
{
"ordinal": 7,
"ordinal": 8,
"name": "edited_by",
"type_info": "Varchar"
},
{
"ordinal": 8,
"ordinal": 9,
"name": "email",
"type_info": "Varchar"
},
{
"ordinal": 9,
"ordinal": 10,
"name": "edited_at",
"type_info": "Timestamptz"
},
{
"ordinal": 10,
"ordinal": 11,
"name": "server_id",
"type_info": "Varchar"
},
{
"ordinal": 11,
"ordinal": 12,
"name": "last_server_ping",
"type_info": "Timestamptz"
},
{
"ordinal": 12,
"ordinal": 13,
"name": "extra_perms",
"type_info": "Jsonb"
},
{
"ordinal": 13,
"ordinal": 14,
"name": "error",
"type_info": "Text"
},
{
"ordinal": 14,
"ordinal": 15,
"name": "enabled",
"type_info": "Bool"
}
@@ -83,6 +98,7 @@
"Left": []
},
"nullable": [
false,
false,
false,
true,
@@ -100,5 +116,5 @@
false
]
},
"hash": "e6adaebcade2e25be800e8b888b23c94caae2421f3cae7c06d6346bd6de1d94a"
"hash": "bc0bedddcafad216c30c5061eef3f4ed8573cda89f655d6490d22f182e3f2f36"
}
@@ -1,23 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE \n sqs_trigger \n SET \n aws_resource_path = $1,\n queue_url = $2,\n message_attributes = $3, \n is_flow = $4, \n edited_by = $5, \n email = $6,\n script_path = $7,\n path = $8,\n edited_at = now(), \n error = NULL,\n server_id = NULL\n WHERE \n workspace_id = $9 AND \n path = $10\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Varchar",
"Varchar",
"TextArray",
"Bool",
"Varchar",
"Varchar",
"Varchar",
"Varchar",
"Text",
"Text"
]
},
"nullable": []
},
"hash": "f68d23841e0e31cdf8633aaf0f32777e04e4965682e5b37afbe84194b756d5f5"
}
+1 -1
View File
@@ -1 +1 @@
29a22d49c710bf21abcfe0e4c081e7eace4ac21e
4c4db954d9de775905a2e207a5969d5feff23455
@@ -0,0 +1,3 @@
-- Add down migration script here
ALTER TABLE sqs_trigger DROP COLUMN aws_auth_resource_type;
DROP TYPE IF EXISTS AWS_AUTH_RESOURCE_TYPE;
@@ -0,0 +1,4 @@
-- Add up migration script here
CREATE TYPE AWS_AUTH_RESOURCE_TYPE AS ENUM ('oidc', 'credentials');
ALTER TABLE sqs_trigger
ADD COLUMN aws_auth_resource_type AWS_AUTH_RESOURCE_TYPE DEFAULT 'credentials'::AWS_AUTH_RESOURCE_TYPE NOT NULL;
+15
View File
@@ -15106,6 +15106,12 @@ components:
type: string
required:
- subscription_id
AwsAuthResourceType:
type: string
enum:
- oidc
- credentials
SqsTrigger:
allOf:
@@ -15114,6 +15120,8 @@ components:
properties:
queue_url:
type: string
aws_auth_resource_type:
$ref: "#/components/schemas/AwsAuthResourceType"
aws_resource_path:
type: string
message_attributes:
@@ -15134,12 +15142,15 @@ components:
- queue_url
- aws_resource_path
- enabled
- aws_auth_resource_type
NewSqsTrigger:
type: object
properties:
queue_url:
type: string
aws_auth_resource_type:
$ref: "#/components/schemas/AwsAuthResourceType"
aws_resource_path:
type: string
message_attributes:
@@ -15160,12 +15171,15 @@ components:
- path
- script_path
- is_flow
- aws_auth_resource_type
EditSqsTrigger:
type: object
properties:
queue_url:
type: string
aws_auth_resource_type:
$ref: "#/components/schemas/AwsAuthResourceType"
aws_resource_path:
type: string
message_attributes:
@@ -15187,6 +15201,7 @@ components:
- script_path
- is_flow
- enabled
- aws_auth_resource_type
Slot:
type: object
+4
View File
@@ -21,6 +21,9 @@ use crate::gcp_triggers_ee::{
manage_google_subscription, process_google_push_request, validate_jwt_token, SubscriptionMode,
};
#[cfg(all(feature = "enterprise", feature = "sqs_trigger"))]
use windmill_common::auth::aws::AwsAuthResourceType;
#[cfg(any(
feature = "http_trigger",
all(feature = "enterprise", feature = "gcp_trigger")
@@ -150,6 +153,7 @@ pub struct SqsTriggerConfig {
pub queue_url: String,
pub aws_resource_path: String,
pub message_attributes: Option<Vec<String>>,
pub aws_auth_resource_type: AwsAuthResourceType,
}
#[cfg(all(feature = "enterprise", feature = "gcp_trigger"))]
@@ -1,6 +1,7 @@
use crate::db::DB;
use axum::Router;
use serde::{Deserialize, Serialize};
use windmill_common::auth::aws::AwsAuthResourceType;
pub fn workspaced_service() -> Router {
@@ -14,6 +15,7 @@ pub fn start_sqs(_db: DB, mut _killpill_rx: tokio::sync::broadcast::Receiver<()>
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct SqsTrigger {
pub queue_url: String,
pub aws_auth_resource_type: AwsAuthResourceType,
pub aws_resource_path: String,
pub message_attributes: Option<Vec<String>>,
pub path: String,
+52 -9
View File
@@ -577,13 +577,35 @@ pub(crate) async fn tarball_workspace(
#[cfg(feature = "websocket")]
{
let websocket_triggers = sqlx::query_as!(
crate::websocket_triggers::WebsocketTrigger,
"SELECT workspace_id, path, url, script_path, is_flow, edited_by, email, edited_at, server_id, last_server_ping, extra_perms, error, enabled, filters as \"filters: _\", initial_messages as \"initial_messages: _\", url_runnable_args as \"url_runnable_args: _\", can_return_message FROM websocket_trigger
WHERE workspace_id = $1",
&w_id
)
.fetch_all(&mut *tx)
.await?;
crate::websocket_triggers::WebsocketTrigger,
r#"
SELECT
workspace_id,
path,
url,
script_path,
is_flow,
edited_by,
email,
edited_at,
server_id,
last_server_ping,
extra_perms,
error,
enabled,
filters AS "filters: _",
initial_messages AS "initial_messages: _",
url_runnable_args AS "url_runnable_args: _",
can_return_message
FROM
websocket_trigger
WHERE
workspace_id = $1
"#,
&w_id
)
.fetch_all(&mut *tx)
.await?;
for trigger in websocket_triggers {
let trigger_str = &to_string_without_metadata(&trigger, false, None).unwrap();
@@ -622,8 +644,29 @@ pub(crate) async fn tarball_workspace(
{
let sqs_triggers = sqlx::query_as!(
crate::sqs_triggers_ee::SqsTrigger,
"SELECT * FROM sqs_trigger
WHERE workspace_id = $1",
r#"
SELECT
aws_auth_resource_type AS "aws_auth_resource_type: _",
aws_resource_path,
message_attributes,
queue_url,
workspace_id,
path,
script_path,
is_flow,
edited_by,
email,
edited_at,
server_id,
last_server_ping,
extra_perms,
error,
enabled
FROM
sqs_trigger
WHERE
workspace_id = $1
"#,
&w_id
)
.fetch_all(&mut *tx)
+14 -2
View File
@@ -353,18 +353,30 @@ pub mod aws {
}
}
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)]
#[sqlx(type_name = "AWS_AUTH_RESOURCE_TYPE", rename_all = "lowercase")]
#[serde(rename_all = "lowercase")]
pub enum AwsAuthResourceType {
Credentials,
Oidc,
}
#[derive(Debug, Deserialize)]
pub struct CredentialsAuth {
#[serde(deserialize_with = "empty_string_as_none")]
pub region: Option<String>,
pub access_key_id: String,
pub secret_access_key: String,
#[serde(rename = "awsAccessKeyId")]
pub aws_access_key_id: String,
#[serde(rename = "awsSecretAccessKey")]
pub aws_secret_access_key: String,
}
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct OidcAuth {
#[serde(deserialize_with = "empty_string_as_none")]
pub region: Option<String>,
#[serde(rename = "roleArn")]
pub role_arn: String,
}
@@ -352,6 +352,7 @@
bind:queue_url={args.queue_url}
bind:aws_resource_path={args.aws_resource_path}
bind:message_attributes={args.message_attributes}
bind:aws_auth_resource_type={args.aws_auth_resource_type}
{showCapture}
{captureInfo}
bind:captureTable
@@ -93,6 +93,7 @@
bind:queue_url={args.queue_url}
bind:aws_resource_path={args.aws_resource_path}
bind:message_attributes={args.message_attributes}
bind:aws_auth_resource_type={args.aws_auth_resource_type}
headless={true}
can_write={true}
showCapture={false}
@@ -15,7 +15,7 @@
import ItemPicker from '$lib/components/ItemPicker.svelte'
import VariableEditor from '$lib/components/VariableEditor.svelte'
import { Button } from '$lib/components/common'
import { VariableService } from '$lib/gen'
import { VariableService, type AwsAuthResourceType } from '$lib/gen'
import { workspaceStore } from '$lib/stores'
export let can_write: boolean = false
@@ -26,6 +26,7 @@
export let isValid: boolean = false
export let queue_url = ''
export let aws_resource_path = ''
export let aws_auth_resource_type: AwsAuthResourceType = 'credentials'
export let message_attributes: string[] = []
async function loadVariables() {
@@ -58,13 +59,23 @@
<div class="flex flex-col w-full gap-4">
<Subsection label="Connection setup">
<div class="flex flex-col gap-3">
<div class="flex flex-col gap-1">
<p class="text-xs mb-1 text-tertiary">
Select an AWS resource with credentials to authenticate your account. <Required
required={true}
/>
<div class="flex flex-col gap-3">
<p class="text-xs text-tertiary">
Select an AWS resource to authenticate your account. <Required required={true} />
</p>
<ResourcePicker resourceType="aws_auth" bind:value={aws_resource_path} />
<ToggleButtonGroup bind:selected={aws_auth_resource_type} on:selected={() => {
aws_resource_path = ''
}} let:item>
<ToggleButton label="Credentials" value="credentials" {item} />
<ToggleButton label="Oidc" value="oidc" {item} />
</ToggleButtonGroup>
{#if aws_auth_resource_type === 'credentials'}
<ResourcePicker resourceType="aws" bind:value={aws_resource_path} />
{:else if aws_auth_resource_type === 'oidc'}
<ResourcePicker resourceType="aws_oidc" bind:value={aws_resource_path} />
{/if}
{#if isValid}
<TestTriggerConnection kind="sqs" args={{ aws_resource_path, queue_url }} />
{/if}
@@ -9,7 +9,7 @@
import { Loader2, Save } from 'lucide-svelte'
import Label from '$lib/components/Label.svelte'
import Toggle from '$lib/components/Toggle.svelte'
import { SqsTriggerService } from '$lib/gen'
import { SqsTriggerService, type AwsAuthResourceType } from '$lib/gen'
import SqsTriggerEditorConfigSection from './SqsTriggerEditorConfigSection.svelte'
import Section from '$lib/components/Section.svelte'
import ScriptPicker from '$lib/components/ScriptPicker.svelte'
@@ -32,6 +32,7 @@
let aws_resource_path: string = ''
let queue_url = ''
let message_attributes: string[] = []
let aws_auth_resource_type: AwsAuthResourceType = 'credentials'
let isValid = false
const dispatch = createEventDispatcher()
@@ -70,6 +71,7 @@
queue_url = defaultValues?.queue_url ?? ''
path = ''
message_attributes = defaultValues?.message_attributes ?? []
aws_auth_resource_type = defaultValues?.aws_auth_resource_type ?? 'credentials'
initialPath = ''
edit = false
dirtyPath = false
@@ -92,6 +94,7 @@
message_attributes = s.message_attributes ?? []
path = s.path
enabled = s.enabled
aws_auth_resource_type = s.aws_auth_resource_type
can_write = canWrite(s.path, s.extra_perms, $userStore)
} catch (error) {
sendUserToast(`Could not load SQS trigger: ${error.body}`, true)
@@ -106,6 +109,7 @@
requestBody: {
path,
script_path,
aws_auth_resource_type,
enabled,
is_flow,
queue_url,
@@ -121,6 +125,7 @@
enabled: true,
aws_resource_path,
queue_url,
aws_auth_resource_type,
path,
script_path,
is_flow,
@@ -232,6 +237,7 @@
bind:queue_url
bind:message_attributes
bind:aws_resource_path
bind:aws_auth_resource_type
{can_write}
headless={true}
/>