Support for OAuth 2.0 (#5)

This commit is contained in:
Gregory Schier
2025-01-26 13:32:17 -08:00
committed by GitHub
parent d142966d0c
commit 252d23bb0e
17 changed files with 855 additions and 52 deletions

View File

@@ -24,21 +24,22 @@ export const plugin: PluginDefinition = {
name: 'jwt',
label: 'JWT Bearer',
shortLabel: 'JWT',
config: [
args: [
{
type: 'select',
name: 'algorithm',
label: 'Algorithm',
hideLabel: true,
defaultValue: defaultAlgorithm,
options: algorithms.map(value => ({ name: value === 'none' ? 'None' : value, value })),
options: algorithms.map(value => ({ label: value === 'none' ? 'None' : value, value })),
},
{
type: 'editor',
type: 'text',
name: 'secret',
label: 'Secret or Private Key',
password: true,
optional: true,
hideGutter: true,
multiLine: true,
},
{
type: 'checkbox',
@@ -54,8 +55,8 @@ export const plugin: PluginDefinition = {
placeholder: '{ }',
},
],
async onApply(_ctx, args) {
const { algorithm, secret: _secret, secretBase64, payload } = args.config;
async onApply(_ctx, { values }) {
const { algorithm, secret: _secret, secretBase64, payload } = values;
const secret = secretBase64 ? Buffer.from(`${_secret}`, 'base64') : `${_secret}`;
const token = jwt.sign(`${payload}`, secret, { algorithm: algorithm as any });
const value = `Bearer ${token}`;