mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-18 15:34:09 +01:00
Add auth plugins
This commit is contained in:
23
plugins/auth-bearer/src/index.ts
Normal file
23
plugins/auth-bearer/src/index.ts
Normal 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(),
|
||||
}],
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user