mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 03:11:28 +01:00
Merge main into proxy branch (formatting and docs)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -38,7 +38,7 @@ The plugin presents the following fields:
|
||||
|
||||
- **Access Key ID** – Your AWS access key identifier
|
||||
- **Secret Access Key** – The secret associated with the access key
|
||||
- **Session Token** *(optional)* – Used for temporary or assumed-role credentials (treated as secret)
|
||||
- **Session Token** _(optional)_ – Used for temporary or assumed-role credentials (treated as secret)
|
||||
- **Region** – AWS region (e.g., `us-east-1`)
|
||||
- **Service** – AWS service identifier (e.g., `sts`, `s3`, `execute-api`)
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "@yaak/auth-aws",
|
||||
"displayName": "AWS SigV4",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Authenticate requests using AWS SigV4 signing",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mountain-loop/yaak.git",
|
||||
"directory": "plugins/auth-aws"
|
||||
},
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev"
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
import { URL } from 'node:url';
|
||||
import type { PluginDefinition } from '@yaakapp/api';
|
||||
import type { CallHttpAuthenticationResponse } from '@yaakapp-internal/plugins';
|
||||
import type { Request } from 'aws4';
|
||||
import aws4 from 'aws4';
|
||||
import { URL } from "node:url";
|
||||
import type { PluginDefinition } from "@yaakapp/api";
|
||||
import type { CallHttpAuthenticationResponse } from "@yaakapp-internal/plugins";
|
||||
import type { Request } from "aws4";
|
||||
import aws4 from "aws4";
|
||||
|
||||
export const plugin: PluginDefinition = {
|
||||
authentication: {
|
||||
name: 'awsv4',
|
||||
label: 'AWS Signature',
|
||||
shortLabel: 'AWS v4',
|
||||
name: "awsv4",
|
||||
label: "AWS Signature",
|
||||
shortLabel: "AWS v4",
|
||||
args: [
|
||||
{ name: 'accessKeyId', label: 'Access Key ID', type: 'text', password: true },
|
||||
{ name: "accessKeyId", label: "Access Key ID", type: "text", password: true },
|
||||
{
|
||||
name: 'secretAccessKey',
|
||||
label: 'Secret Access Key',
|
||||
type: 'text',
|
||||
name: "secretAccessKey",
|
||||
label: "Secret Access Key",
|
||||
type: "text",
|
||||
password: true,
|
||||
},
|
||||
{
|
||||
name: 'service',
|
||||
label: 'Service Name',
|
||||
type: 'text',
|
||||
defaultValue: 'sts',
|
||||
placeholder: 'sts',
|
||||
description: 'The service that is receiving the request (sts, s3, sqs, ...)',
|
||||
name: "service",
|
||||
label: "Service Name",
|
||||
type: "text",
|
||||
defaultValue: "sts",
|
||||
placeholder: "sts",
|
||||
description: "The service that is receiving the request (sts, s3, sqs, ...)",
|
||||
},
|
||||
{
|
||||
name: 'region',
|
||||
label: 'Region',
|
||||
type: 'text',
|
||||
placeholder: 'us-east-1',
|
||||
description: 'The region that is receiving the request (defaults to us-east-1)',
|
||||
name: "region",
|
||||
label: "Region",
|
||||
type: "text",
|
||||
placeholder: "us-east-1",
|
||||
description: "The region that is receiving the request (defaults to us-east-1)",
|
||||
optional: true,
|
||||
},
|
||||
{
|
||||
name: 'sessionToken',
|
||||
label: 'Session Token',
|
||||
type: 'text',
|
||||
name: "sessionToken",
|
||||
label: "Session Token",
|
||||
type: "text",
|
||||
password: true,
|
||||
optional: true,
|
||||
description: 'Only required if you are using temporary credentials',
|
||||
description: "Only required if you are using temporary credentials",
|
||||
},
|
||||
],
|
||||
onApply(_ctx, { values, ...args }): CallHttpAuthenticationResponse {
|
||||
const accessKeyId = String(values.accessKeyId || '');
|
||||
const secretAccessKey = String(values.secretAccessKey || '');
|
||||
const sessionToken = String(values.sessionToken || '') || undefined;
|
||||
const accessKeyId = String(values.accessKeyId || "");
|
||||
const secretAccessKey = String(values.secretAccessKey || "");
|
||||
const sessionToken = String(values.sessionToken || "") || undefined;
|
||||
|
||||
const url = new URL(args.url);
|
||||
|
||||
const headers: NonNullable<Request['headers']> = {};
|
||||
for (const headerName of ['content-type', 'host', 'x-amz-date', 'x-amz-security-token']) {
|
||||
const headers: NonNullable<Request["headers"]> = {};
|
||||
for (const headerName of ["content-type", "host", "x-amz-date", "x-amz-security-token"]) {
|
||||
const v = args.headers.find((h) => h.name.toLowerCase() === headerName);
|
||||
if (v != null) {
|
||||
headers[headerName] = v.value;
|
||||
@@ -61,8 +61,8 @@ export const plugin: PluginDefinition = {
|
||||
{
|
||||
host: url.host,
|
||||
method: args.method,
|
||||
path: url.pathname + (url.search || ''),
|
||||
service: String(values.service || 'sts'),
|
||||
path: url.pathname + (url.search || ""),
|
||||
service: String(values.service || "sts"),
|
||||
region: values.region ? String(values.region) : undefined,
|
||||
headers,
|
||||
doNotEncodePath: true,
|
||||
@@ -80,8 +80,8 @@ export const plugin: PluginDefinition = {
|
||||
|
||||
return {
|
||||
setHeaders: Object.entries(signature.headers)
|
||||
.filter(([name]) => name !== 'content-type') // Don't add this because we already have it
|
||||
.map(([name, value]) => ({ name, value: String(value || '') })),
|
||||
.filter(([name]) => name !== "content-type") // Don't add this because we already have it
|
||||
.map(([name, value]) => ({ name, value: String(value || "") })),
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user