mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-12-05 06:16:23 +01:00
feat(auth-oauth2): custom parameters for authorization, token, and refresh requests (#629)
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d0926c961
commit
7a6d275fdb
16 files changed
+771
-5
No files matched your search
@@ -11,6 +11,7 @@ import {
|
||||
DEFAULT_LOCALHOST_PORT,
|
||||
stopActiveServer,
|
||||
} from "./callbackServer";
|
||||
import { readCustomParams } from "./customParams";
|
||||
import {
|
||||
type CallbackType,
|
||||
DEFAULT_PKCE_METHOD,
|
||||
@@ -468,6 +469,48 @@ export const plugin: PluginDefinition = {
|
||||
values.clientCredentialsMethod === "client_assertion",
|
||||
}),
|
||||
},
|
||||
{
|
||||
type: "key_value",
|
||||
name: "authorizationParams",
|
||||
label: "Authorization Params",
|
||||
description: "Query params appended to the authorization URL.",
|
||||
optional: true,
|
||||
dynamic: hiddenIfNot(["authorization_code", "implicit"]),
|
||||
},
|
||||
{
|
||||
type: "key_value",
|
||||
name: "tokenHeaders",
|
||||
label: "Token Headers",
|
||||
description:
|
||||
"Headers sent with the token request, and when refreshing unless overridden.",
|
||||
optional: true,
|
||||
dynamic: hiddenIfNot(["authorization_code", "password", "client_credentials"]),
|
||||
},
|
||||
{
|
||||
type: "key_value",
|
||||
name: "tokenBodyParams",
|
||||
label: "Token Body Params",
|
||||
description:
|
||||
"Form params sent with the token request, and when refreshing unless overridden.",
|
||||
optional: true,
|
||||
dynamic: hiddenIfNot(["authorization_code", "password", "client_credentials"]),
|
||||
},
|
||||
{
|
||||
type: "key_value",
|
||||
name: "refreshHeaders",
|
||||
label: "Refresh Headers",
|
||||
description: "Headers sent only when refreshing the token.",
|
||||
optional: true,
|
||||
dynamic: hiddenIfNot(["authorization_code", "password"]),
|
||||
},
|
||||
{
|
||||
type: "key_value",
|
||||
name: "refreshBodyParams",
|
||||
label: "Refresh Body Params",
|
||||
description: "Form params sent only when refreshing the token.",
|
||||
optional: true,
|
||||
dynamic: hiddenIfNot(["authorization_code", "password"]),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -506,6 +549,7 @@ export const plugin: PluginDefinition = {
|
||||
const headerPrefix = stringArg(values, "headerPrefix");
|
||||
const grantType = stringArg(values, "grantType") as GrantType;
|
||||
const credentialsInBody = values.credentials === "body";
|
||||
const customParams = readCustomParams(values);
|
||||
const tokenName = values.tokenName === "id_token" ? "id_token" : "access_token";
|
||||
|
||||
// Build external browser options if enabled
|
||||
@@ -546,6 +590,7 @@ export const plugin: PluginDefinition = {
|
||||
: null,
|
||||
tokenName: tokenName,
|
||||
externalBrowser: externalBrowserOptions,
|
||||
customParams,
|
||||
});
|
||||
} else if (grantType === "implicit") {
|
||||
const authorizationUrl = stringArg(values, "authorizationUrl");
|
||||
@@ -561,6 +606,7 @@ export const plugin: PluginDefinition = {
|
||||
state: stringArgOrNull(values, "state"),
|
||||
tokenName: tokenName,
|
||||
externalBrowser: externalBrowserOptions,
|
||||
customParams,
|
||||
});
|
||||
} else if (grantType === "client_credentials") {
|
||||
const accessTokenUrl = stringArg(values, "accessTokenUrl");
|
||||
@@ -577,6 +623,7 @@ export const plugin: PluginDefinition = {
|
||||
scope: stringArgOrNull(values, "scope"),
|
||||
audience: stringArgOrNull(values, "audience"),
|
||||
credentialsInBody,
|
||||
customParams,
|
||||
});
|
||||
} else if (grantType === "password") {
|
||||
const accessTokenUrl = stringArg(values, "accessTokenUrl");
|
||||
@@ -591,6 +638,7 @@ export const plugin: PluginDefinition = {
|
||||
scope: stringArgOrNull(values, "scope"),
|
||||
audience: stringArgOrNull(values, "audience"),
|
||||
credentialsInBody,
|
||||
customParams,
|
||||
});
|
||||
} else {
|
||||
throw new Error(`Invalid grant type ${String(grantType)}`);
|
||||
|
||||
Reference in new issue
Block a user