Add auth plugins

This commit is contained in:
Gregory Schier
2025-01-16 15:28:25 -08:00
parent e213c76870
commit ebb7b69dd8
6 changed files with 295 additions and 7 deletions

View File

@@ -0,0 +1,9 @@
{
"name": "@yaakapp/auth-bearer",
"private": true,
"version": "0.0.1",
"scripts": {
"build": "yaakcli build ./src/index.ts",
"dev": "yaakcli dev ./src/index.js"
}
}

View File

@@ -0,0 +1,23 @@
import { PluginDefinition } from '@yaakapp/api';
export const plugin: PluginDefinition = {
authentication: {
name: 'Bearer',
config: [{
type: 'text',
name: 'token',
label: 'Token',
optional: true,
}],
async onApply(_ctx: any, args: any): Promise<any> {
const { token } = args.config;
return {
url: args.url,
headers: [{
name: 'Authorization',
value: `Bearer ${token}`.trim(),
}],
};
},
},
};