mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-17 00:56:37 +01:00
Add auth plugins
This commit is contained in:
28
plugins/auth-basic/src/index.ts
Normal file
28
plugins/auth-basic/src/index.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { PluginDefinition } from '@yaakapp/api';
|
||||
|
||||
export const plugin: PluginDefinition = {
|
||||
authentication: {
|
||||
name: 'Basic',
|
||||
config: [{
|
||||
type: 'text',
|
||||
name: 'username',
|
||||
label: 'Username',
|
||||
optional: true,
|
||||
}, {
|
||||
type: 'text',
|
||||
name: 'password',
|
||||
label: 'Password',
|
||||
optional: true,
|
||||
}],
|
||||
async onApply(_ctx: any, args: any): Promise<any> {
|
||||
const { username, password } = args.config;
|
||||
return {
|
||||
url: args.url,
|
||||
headers: [{
|
||||
name: 'Authorization',
|
||||
value: 'Basic ' + Buffer.from(`${username}:${password}`).toString('base64'),
|
||||
}],
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user