Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix auth0 and okta request

adilson5ac185dc1e67
diff --git a/backend/src/ee/services/secret-rotation-v2/auth0-client-secret/auth0-client-secret-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/auth0-client-secret/auth0-client-secret-rotation-fns.ts
index 4fc02f39de..8eec7bdba8 100644
--- a/backend/src/ee/services/secret-rotation-v2/auth0-client-secret/auth0-client-secret-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/auth0-client-secret/auth0-client-secret-rotation-fns.ts
@@ -122,7 +122,7 @@ export const auth0ClientSecretRotationFactory: TRotationFactory<
} catch (error: unknown) {
if (error instanceof AxiosError) {
const errorData = error.response?.data as { error?: string; error_description?: string } | undefined;
- if (errorData?.error === "access_denied") return;
+ if (errorData?.error === "invalid_scope" || errorData?.error === "access_denied") return;
throw new BadRequestError({
message: `Auth0 client credentials check failed: ${errorData?.error_description ?? errorData?.error ?? error.message}`
});
diff --git a/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-fns.ts
index 1bb0d14a50..30769af480 100644
--- a/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-fns.ts
@@ -19,6 +19,7 @@ import {
TRotationFactoryRevokeCredentials,
TRotationFactoryRotateCredentials
} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";
+import { BadRequestError } from "@app/lib/errors";
import { getAwsConnectionConfig } from "@app/services/app-connection/aws";
const getCreateDate = (key: AccessKeyMetadata): number => {
@@ -137,7 +138,11 @@ export const awsIamUserSecretRotationFactory: TRotationFactory<
const errName = (err as { name?: string }).name;
// AccessDenied means the credentials authenticated successfully but the IAM user
// lacks iam:GetUser on themselves — the credential is still valid for our purposes.
- if (errName === "AccessDenied") return;
+ if (errName === "AccessDenied") {
+ throw new BadRequestError({
+ message: "Failed to check active credentials"
+ });
+ }
throw err;
}
};
diff --git a/backend/src/ee/services/secret-rotation-v2/okta-client-secret/okta-client-secret-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/okta-client-secret/okta-client-secret-rotation-fns.ts
index a943f788fd..a03d0accc6 100644
--- a/backend/src/ee/services/secret-rotation-v2/okta-client-secret/okta-client-secret-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/okta-client-secret/okta-client-secret-rotation-fns.ts
@@ -12,6 +12,7 @@ import {
import { request } from "@app/lib/config/request";
import { delay as delayMs } from "@app/lib/delay";
import { BadRequestError } from "@app/lib/errors";
+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
import { getOktaInstanceUrl } from "@app/services/app-connection/okta";
import {
@@ -269,15 +270,19 @@ export const oktaClientSecretRotationFactory: TRotationFactory<
TOktaClientSecretRotationGeneratedCredentials
> = async ({ clientId: activeClientId, clientSecret }) => {
const instanceUrl = await getOktaInstanceUrl(connection);
- const tokenUrl = `${instanceUrl}/oauth2/default/v1/token`;
+ // replace the -admin on the instanceUrl
+ const apiURL = instanceUrl.replace("-admin", "");
+
+ const tokenUrl = `${apiURL}/oauth2/default/v1/introspect`;
+ await blockLocalAndPrivateIpAddresses(tokenUrl);
const basicAuth = Buffer.from(`${activeClientId}:${clientSecret}`).toString("base64");
try {
await request.post(
tokenUrl,
new URLSearchParams({
- grant_type: "client_credentials",
- scope: "infisical-credential-check"
+ token: "access_token", // this can be anything
+ token_type_hint: "access_token"
}).toString(),
{
headers: {
@@ -290,6 +295,7 @@ export const oktaClientSecretRotationFactory: TRotationFactory<
} catch (error: unknown) {
if (error instanceof AxiosError) {
const errorData = error.response?.data as { error?: string; error_description?: string } | undefined;
+ if (errorData?.error === "invalid_scope") return;
throw new BadRequestError({
message: `Okta client credentials check failed: ${errorData?.error_description ?? errorData?.error ?? error.message}`
});
diff --git a/backend/src/ee/services/secret-rotation-v2/supabase-api-key/supabase-api-key-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/supabase-api-key/supabase-api-key-rotation-fns.ts
index 81c69e8ae1..71280a5048 100644
--- a/backend/src/ee/services/secret-rotation-v2/supabase-api-key/supabase-api-key-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/supabase-api-key/supabase-api-key-rotation-fns.ts
@@ -152,9 +152,10 @@ export const supabaseApiKeyRotationFactory: TRotationFactory<
const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<
TSupabaseApiKeyRotationGeneratedCredentials
> = async ({ apiKey }) => {
- // Project URL follows Supabase Cloud pattern. Self-hosted instances expose project APIs
- // on user-defined hosts that are not derivable from projectRef alone.
- const projectUrl = `https://${projectRef}.supabase.co`;
+ const projectUrl = connection.credentials.instanceUrl
+ ? await getSupabaseInstanceUrl(connectionConfig)
+ : `https://${projectRef}.supabase.co`;
+
await blockLocalAndPrivateIpAddresses(projectUrl);
try {