Skip to content

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

custom branding for secret share

x0322052398c390b5c0
diff --git a/backend/src/db/migrations/20260109205558_secret-share-brand-config.ts b/backend/src/db/migrations/20260109205558_secret-share-brand-config.ts
new file mode 100644
index 0000000000..e0570194c7
--- /dev/null
+++ b/backend/src/db/migrations/20260109205558_secret-share-brand-config.ts
@@ -0,0 +1,21 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ const hasColumn = await knex.schema.hasColumn(TableName.Organization, "secretShareBrandConfig");
+ if (!hasColumn) {
+ await knex.schema.alterTable(TableName.Organization, (t) => {
+ t.jsonb("secretShareBrandConfig").nullable();
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ const hasColumn = await knex.schema.hasColumn(TableName.Organization, "secretShareBrandConfig");
+ if (hasColumn) {
+ await knex.schema.alterTable(TableName.Organization, (t) => {
+ t.dropColumn("secretShareBrandConfig");
+ });
+ }
+}
diff --git a/backend/src/db/schemas/organizations.ts b/backend/src/db/schemas/organizations.ts
index 3cc7fe8584..6ea136bb43 100644
--- a/backend/src/db/schemas/organizations.ts
+++ b/backend/src/db/schemas/organizations.ts
@@ -41,7 +41,8 @@ export const OrganizationsSchema = z.object({
googleSsoAuthLastUsed: z.date().nullable().optional(),
parentOrgId: z.string().uuid().nullable().optional(),
rootOrgId: z.string().uuid().nullable().optional(),
- blockDuplicateSecretSyncDestinations: z.boolean().default(false)
+ blockDuplicateSecretSyncDestinations: z.boolean().default(false),
+ secretShareBrandConfig: z.unknown().nullable().optional()
});
export type TOrganizations = z.infer<typeof OrganizationsSchema>;
diff --git a/backend/src/ee/services/license/license-fns.ts b/backend/src/ee/services/license/license-fns.ts
index 4612e09ffa..e94f89113d 100644
--- a/backend/src/ee/services/license/license-fns.ts
+++ b/backend/src/ee/services/license/license-fns.ts
@@ -112,7 +112,8 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({
fips: false,
eventSubscriptions: false,
machineIdentityAuthTemplates: false,
- pkiLegacyTemplates: false
+ pkiLegacyTemplates: false,
+ secretShareExternalBranding: false
});
export const setupLicenseRequestWithStore = (
diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.ts
index 823d9e6d52..10f2dab406 100644
--- a/backend/src/ee/services/license/license-types.ts
+++ b/backend/src/ee/services/license/license-types.ts
@@ -92,6 +92,7 @@ export type TFeatureSet = {
pkiLegacyTemplates: false;
fips: false;
eventSubscriptions: false;
+ secretShareExternalBranding: false;
};
export type TOrgPlansTableDTO = {
diff --git a/backend/src/server/routes/v1/organization-router.ts b/backend/src/server/routes/v1/organization-router.ts
index a56fdcfed4..d36a3ece13 100644
--- a/backend/src/server/routes/v1/organization-router.ts
+++ b/backend/src/server/routes/v1/organization-router.ts
@@ -320,7 +320,31 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
blockDuplicateSecretSyncDestinations: z
.boolean()
.optional()
- .describe("Block duplicate secret sync destinations across the organization")
+ .describe("Block duplicate secret sync destinations across the organization"),
+ secretShareBrandConfig: z
+ .object({
+ faviconUrl: z.string().url().optional().or(z.literal("")),
+ logoUrl: z.string().url().optional().or(z.literal("")),
+ primaryColor: z
+ .string()
+ .refine(
+ (val) => !val || new RE2(/^#[0-9A-Fa-f]{6}$/).test(val),
+ "Primary color must be a valid hex color (e.g., #FF5733)"
+ )
+ .optional()
+ .or(z.literal("")),
+ secondaryColor: z
+ .string()
+ .refine(
+ (val) => !val || new RE2(/^#[0-9A-Fa-f]{6}$/).test(val),
+ "Secondary color must be a valid hex color (e.g., #FF5733)"
+ )
+ .optional()
+ .or(z.literal(""))
+ })
+ .nullable()
+ .optional()
+ .describe("Custom branding configuration for secret sharing pages")
}),
response: {
200: z.object({
diff --git a/backend/src/server/routes/v1/secret-sharing-router.ts b/backend/src/server/routes/v1/secret-sharing-router.ts
index 6531039385..f459656807 100644
--- a/backend/src/server/routes/v1/secret-sharing-router.ts
+++ b/backend/src/server/routes/v1/secret-sharing-router.ts
@@ -2,6 +2,7 @@ import { z } from "zod";
import { SecretSharingSchema } from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
+import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { SecretSharingAccessType } from "@app/lib/types";
import {
publicEndpointLimit,
@@ -13,6 +14,16 @@ import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
import { SecretSharingType } from "@app/services/secret-sharing/secret-sharing-types";
+const ALLOWED_IMAGE_CONTENT_TYPES = [
+ "image/png",
+ "image/jpeg",
+ "image/gif",
+ "image/svg+xml",
+ "image/x-icon",
+ "image/webp"
+];
+const MAX_IMAGE_SIZE = 5 * 1024 * 1024; // 5MB
+
export const registerSecretSharingRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
@@ -67,6 +78,14 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
response: {
200: z.object({
isPasswordProtected: z.boolean(),
+ brandingConfig: z
+ .object({
+ hasLogoUrl: z.boolean(),
+ hasFaviconUrl: z.boolean(),
+ primaryColor: z.string().optional(),
+ secondaryColor: z.string().optional()
+ })
+ .optional(),
secret: SecretSharingSchema.pick({
encryptedValue: true,
iv: true,
@@ -79,7 +98,8 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
orgName: z.string().optional(),
secretValue: z.string().optional()
})
- .optional()
+ .optional(),
+ error: z.string().optional()
})
}
},
@@ -92,22 +112,38 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
actorId: req.permission?.id
});
- if (sharedSecret.secret?.orgId) {
- await server.services.auditLog.createAuditLog({
- orgId: sharedSecret.secret.orgId,
- ...req.auditLogInfo,
- event: {
- type: EventType.READ_SHARED_SECRET,
- metadata: {
- id: req.params.id,
- name: sharedSecret.secret.name || undefined,
- accessType: sharedSecret.secret.accessType
+ let brandingConfig;
+
+ if (sharedSecret.secretOrgId) {
+ const orgBrandConfig = await req.server.services.secretSharing.getOrgBrandConfig(sharedSecret.secretOrgId);
+
+ if (orgBrandConfig) {
+ brandingConfig = {
+ hasLogoUrl: Boolean(orgBrandConfig.logoUrl),
+ hasFaviconUrl: Boolean(orgBrandConfig.faviconUrl),
+ primaryColor: orgBrandConfig.primaryColor,
+ secondaryColor: orgBrandConfig.secondaryColor
+ };
+ }
+
+ // Verify that secret was actually returned
+ if (sharedSecret.secret) {
+ await server.services.auditLog.createAuditLog({
+ orgId: sharedSecret.secretOrgId,
+ ...req.auditLogInfo,
+ event: {
+ type: EventType.READ_SHARED_SECRET,
+ metadata: {
+ id: req.params.id,
+ name: sharedSecret.secret.name || undefined,
+ accessType: sharedSecret.secret.accessType
+ }
}
- }
- });
+ });
+ }
}
- return sharedSecret;
+ return { ...sharedSecret, brandingConfig };
}
});
@@ -240,4 +276,67 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
return { ...deletedSharedSecret };
}
});
+
+ // Endpoint to proxy external branding images
+ server.route({
+ method: "GET",
+ url: "/public/:id/branding/:assetType",
+ config: {
+ rateLimit: publicEndpointLimit
+ },
+ schema: {
+ params: z.object({
+ id: z.string(),
+ assetType: z.enum(["logo", "favicon"])
+ })
+ },
+ handler: async (req, res) => {
+ const { id, assetType } = req.params;
+
+ const orgId = await req.server.services.secretSharing.getSharedSecretOrgId(id);
+
+ if (!orgId) {
+ throw new NotFoundError({ message: "Shared secret not found or has no organization" });
+ }
+
+ const orgBrandConfig = await req.server.services.secretSharing.getOrgBrandConfig(orgId);
+
+ if (!orgBrandConfig) {
+ throw new NotFoundError({ message: "No branding configured for this organization" });
+ }
+
+ const imageUrl = assetType === "logo" ? orgBrandConfig.logoUrl : orgBrandConfig.faviconUrl;
+
+ if (!imageUrl) {
+ throw new NotFoundError({ message: `No ${assetType} configured for this organization` });
+ }
+
+ // Fetch image
+ const response = await fetch(imageUrl);
+
+ if (!response.ok) {
+ throw new BadRequestError({ message: `Failed to fetch ${assetType}` });
+ }
+
+ const contentType = response.headers.get("content-type") || "application/octet-stream";
+ const contentLength = response.headers.get("content-length");
+
+ // Validate content type
+ if (!ALLOWED_IMAGE_CONTENT_TYPES.some((allowed) => contentType.startsWith(allowed))) {
+ throw new BadRequestError({ message: "Invalid image type" });
+ }
+
+ // Validate size
+ if (contentLength && parseInt(contentLength, 10) > MAX_IMAGE_SIZE) {
+ throw new BadRequestError({ message: "Image too large" });
+ }
+
+ const imageBuffer = Buffer.from(await response.arrayBuffer());
+
+ void res.header("Content-Type", contentType);
+ void res.header("Cache-Control", "public, max-age=3600"); // Cache for 1 hour
+
+ return res.send(imageBuffer);
+ }
+ });
};
diff --git a/backend/src/services/certificate-authority/certificate-authority-fns.ts b/backend/src/services/certificate-authority/certificate-authority-fns.ts
index 545cb92e5b..78dd37a764 100644
--- a/backend/src/services/certificate-authority/certificate-authority-fns.ts
+++ b/backend/src/services/certificate-authority/certificate-authority-fns.ts
@@ -5,8 +5,8 @@ import { crypto } from "@app/lib/crypto/cryptography";
import { NotFoundError } from "@app/lib/errors";
import { getProjectKmsCertificateKeyId } from "@app/services/project/project-fns";
-import { DEFAULT_CRL_VALIDITY_DAYS } from "../certificate-common/certificate-constants";
import { CertKeyAlgorithm, CertStatus } from "../certificate/certificate-types";
+import { DEFAULT_CRL_VALIDITY_DAYS } from "../certificate-common/certificate-constants";
import { TCertificateAuthorityDALFactory } from "./certificate-authority-dal";
import {
TDNParts,
diff --git a/backend/src/services/certificate-authority/certificate-authority-queue.ts b/backend/src/services/certificate-authority/certificate-authority-queue.ts
index 2a63bbea97..2059f00791 100644
--- a/backend/src/services/certificate-authority/certificate-authority-queue.ts
+++ b/backend/src/services/certificate-authority/certificate-authority-queue.ts
@@ -7,9 +7,9 @@ import { daysToMillisecond, secondsToMillis } from "@app/lib/dates";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
-import { DEFAULT_CRL_VALIDITY_DAYS } from "@app/services/certificate-common/certificate-constants";
import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";
import { CertKeyAlgorithm, CertStatus } from "@app/services/certificate/certificate-types";
+import { DEFAULT_CRL_VALIDITY_DAYS } from "@app/services/certificate-common/certificate-constants";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { TProjectDALFactory } from "@app/services/project/project-dal";
import { getProjectKmsCertificateKeyId } from "@app/services/project/project-fns";
diff --git a/backend/src/services/org/org-schema.ts b/backend/src/services/org/org-schema.ts
index dbdd04586f..3142d2604f 100644
--- a/backend/src/services/org/org-schema.ts
+++ b/backend/src/services/org/org-schema.ts
@@ -30,5 +30,6 @@ export const sanitizedOrganizationSchema = OrganizationsSchema.pick({
maxSharedSecretViewLimit: true,
blockDuplicateSecretSyncDestinations: true,
rootOrgId: true,
- parentOrgId: true
+ parentOrgId: true,
+ secretShareBrandConfig: true
});
diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts
index 688b3c220c..e164b2c038 100644
--- a/backend/src/services/org/org-service.ts
+++ b/backend/src/services/org/org-service.ts
@@ -417,7 +417,8 @@ export const orgServiceFactory = ({
shareSecretsProductEnabled,
maxSharedSecretLifetime,
maxSharedSecretViewLimit,
- blockDuplicateSecretSyncDestinations
+ blockDuplicateSecretSyncDestinations,
+ secretShareBrandConfig
}
}: TUpdateOrgDTO) => {
const appCfg = getConfig();
@@ -437,9 +438,26 @@ export const orgServiceFactory = ({
OrgPermissionSubjects.SecretShare
);
}
+
+ if (secretShareBrandConfig !== undefined) {
+ ForbiddenError.from(permission).throwUnlessCan(
+ OrgPermissionSecretShareAction.ManageSettings,
+ OrgPermissionSubjects.SecretShare
+ );
+ }
+
const plan = await licenseService.getPlan(orgId);
const currentOrg = await orgDAL.findOrgById(actorOrgId);
+ if (secretShareBrandConfig !== undefined) {
+ if (!plan.secretShareExternalBranding) {
+ throw new BadRequestError({
+ message:
+ "Failed to update secret share branding due to plan restriction. Upgrade plan to configure custom branding."
+ });
+ }
+ }
+
if (enforceMfa !== undefined) {
if (!plan.enforceMfa) {
throw new BadRequestError({
@@ -602,7 +620,8 @@ export const orgServiceFactory = ({
shareSecretsProductEnabled,
maxSharedSecretLifetime,
maxSharedSecretViewLimit,
- blockDuplicateSecretSyncDestinations
+ blockDuplicateSecretSyncDestinations,
+ secretShareBrandConfig
});
if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
return org;
diff --git a/backend/src/services/org/org-types.ts b/backend/src/services/org/org-types.ts
index 2587045bbd..b35b093516 100644
--- a/backend/src/services/org/org-types.ts
+++ b/backend/src/services/org/org-types.ts
@@ -69,6 +69,13 @@ export type TFindAllWorkspacesDTO = {
orgId: string;
};
+export type TSecretShareBrandConfig = {
+ faviconUrl?: string;
+ logoUrl?: string;
+ primaryColor?: string;
+ secondaryColor?: string;
+} | null;
+
export type TUpdateOrgDTO = {
data: Partial<{
name: string;
@@ -91,6 +98,7 @@ export type TUpdateOrgDTO = {
maxSharedSecretLifetime: number;
maxSharedSecretViewLimit: number | null;
blockDuplicateSecretSyncDestinations: boolean;
+ secretShareBrandConfig: TSecretShareBrandConfig;
}>;
} & TOrgPermission;
diff --git a/backend/src/services/secret-sharing/secret-sharing-service.ts b/backend/src/services/secret-sharing/secret-sharing-service.ts
index 67170e5f66..f7ca256e13 100644
--- a/backend/src/services/secret-sharing/secret-sharing-service.ts
+++ b/backend/src/services/secret-sharing/secret-sharing-service.ts
@@ -541,18 +541,22 @@ export const secretSharingServiceFactory = ({
// or can be safely sent to the client.
if (expiresAt !== null && expiresAt < new Date()) {
// check lifetime expiry
- await secretSharingDAL.softDeleteById(sharedSecretId);
- throw new ForbiddenRequestError({
- message: "Access denied: Secret has expired by lifetime"
- });
+ await secretSharingDAL.softDeleteById(sharedSecret.id);
+ return {
+ isPasswordProtected: false,
+ secretOrgId: sharedSecret.orgId,
+ error: "Access denied: Secret has expired by lifetime"
+ };
}
if (expiresAfterViews !== null && expiresAfterViews === 0) {
// check view count expiry
- await secretSharingDAL.softDeleteById(sharedSecretId);
- throw new ForbiddenRequestError({
- message: "Access denied: Secret has expired by view count"
- });
+ await secretSharingDAL.softDeleteById(sharedSecret.id);
+ return {
+ isPasswordProtected: false,
+ secretOrgId: sharedSecret.orgId,
+ error: "Access denied: Secret has expired by view count"
+ };
}
// Password checks
@@ -563,7 +567,7 @@ export const secretSharingServiceFactory = ({
const isMatch = await crypto.hashing().compareHash(password as string, sharedSecret.password as string);
if (!isMatch) throw new UnauthorizedError({ message: "Invalid credentials" });
} else {
- return { isPasswordProtected };
+ return { isPasswordProtected, secretOrgId: sharedSecret.orgId };
}
}
@@ -580,6 +584,7 @@ export const secretSharingServiceFactory = ({
return {
isPasswordProtected,
+ secretOrgId: sharedSecret.orgId,
secret: {
...sharedSecret,
...(decryptedSecretValue && {
@@ -607,7 +612,10 @@ export const secretSharingServiceFactory = ({
const sharedSecret = isUuidV4(sharedSecretId)
? await secretSharingDAL.findOne({ id: sharedSecretId, type: deleteSharedSecretInput.type })
- : await secretSharingDAL.findOne({ identifier: sharedSecretId, type: deleteSharedSecretInput.type });
+ : await secretSharingDAL.findOne({
+ identifier: Buffer.from(sharedSecretId, "base64url").toString("hex"),
+ type: deleteSharedSecretInput.type
+ });
if (sharedSecret.userId !== actorId) {
throw new ForbiddenRequestError({
@@ -618,17 +626,45 @@ export const secretSharingServiceFactory = ({
throw new ForbiddenRequestError({ message: "User does not have permission to delete shared secret" });
}
- const deletedSharedSecret = await secretSharingDAL.deleteById(sharedSecretId);
+ const deletedSharedSecret = await secretSharingDAL.deleteById(sharedSecret.id);
return deletedSharedSecret;
};
+ const getSharedSecretOrgId = async (sharedSecretId: string) => {
+ const sharedSecret = isUuidV4(sharedSecretId)
+ ? await secretSharingDAL.findOne({
+ id: sharedSecretId,
+ type: SecretSharingType.Share
+ })
+ : await secretSharingDAL.findOne({
+ identifier: Buffer.from(sharedSecretId, "base64url").toString("hex"),
+ type: SecretSharingType.Share
+ });
+
+ return sharedSecret?.orgId ?? null;
+ };
+
+ const getOrgBrandConfig = async (
+ orgId: string
+ ): Promise<{
+ faviconUrl?: string;
+ logoUrl?: string;
+ primaryColor?: string;
+ secondaryColor?: string;
+ } | null> => {
+ const org = await orgDAL.findOrgById(orgId);
+ return org?.secretShareBrandConfig ?? null;
+ };
+
return {
createSharedSecret,
createPublicSharedSecret,
getSharedSecrets,
deleteSharedSecretById,
getSharedSecretById,
+ getSharedSecretOrgId,
+ getOrgBrandConfig,
createSecretRequest,
getSecretRequestById,
diff --git a/frontend/src/hooks/api/organization/queries.tsx b/frontend/src/hooks/api/organization/queries.tsx
index 857358ffea..f9eb8ab2d4 100644
--- a/frontend/src/hooks/api/organization/queries.tsx
+++ b/frontend/src/hooks/api/organization/queries.tsx
@@ -126,7 +126,8 @@ export const useUpdateOrg = () => {
shareSecretsProductEnabled,
maxSharedSecretLifetime,
maxSharedSecretViewLimit,
- blockDuplicateSecretSyncDestinations
+ blockDuplicateSecretSyncDestinations,
+ secretShareBrandConfig
}) => {
return apiRequest.patch(`/api/v1/organization/${orgId}`, {
name,
@@ -148,7 +149,8 @@ export const useUpdateOrg = () => {
shareSecretsProductEnabled,
maxSharedSecretLifetime,
maxSharedSecretViewLimit,
- blockDuplicateSecretSyncDestinations
+ blockDuplicateSecretSyncDestinations,
+ secretShareBrandConfig
});
},
onSuccess: () => {
diff --git a/frontend/src/hooks/api/organization/types.ts b/frontend/src/hooks/api/organization/types.ts
index 45870176fc..331f3761e0 100644
--- a/frontend/src/hooks/api/organization/types.ts
+++ b/frontend/src/hooks/api/organization/types.ts
@@ -3,6 +3,13 @@ import { IdentityMembershipOrg } from "@app/hooks/api/identities/types";
import { MfaMethod } from "../auth/types";
+export type TSecretShareBrandConfig = {
+ faviconUrl?: string;
+ logoUrl?: string;
+ primaryColor?: string;
+ secondaryColor?: string;
+} | null;
+
export type Organization = {
id: string;
name: string;
@@ -32,6 +39,7 @@ export type Organization = {
blockDuplicateSecretSyncDestinations: boolean;
parentOrgId: string | null;
rootOrgId: string | null;
+ secretShareBrandConfig?: TSecretShareBrandConfig;
};
export type UpdateOrgDTO = {
@@ -56,6 +64,7 @@ export type UpdateOrgDTO = {
maxSharedSecretViewLimit?: number | null;
maxSharedSecretLifetime?: number;
blockDuplicateSecretSyncDestinations?: boolean;
+ secretShareBrandConfig?: TSecretShareBrandConfig;
};
export type BillingDetails = {
diff --git a/frontend/src/hooks/api/secretSharing/types.ts b/frontend/src/hooks/api/secretSharing/types.ts
index 524346beb5..8567222816 100644
--- a/frontend/src/hooks/api/secretSharing/types.ts
+++ b/frontend/src/hooks/api/secretSharing/types.ts
@@ -50,18 +50,27 @@ export type TRevealSecretRequestValueRequest = {
id: string;
};
+export type TSharedSecretResponse = {
+ secretValue?: string;
+ encryptedValue: string;
+ iv: string;
+ tag: string;
+ accessType: SecretSharingAccessType;
+ orgName?: string;
+ expiresAt?: Date | string;
+ expiresAfterViews?: number | null;
+};
+
export type TViewSharedSecretResponse = {
isPasswordProtected: boolean;
- secret: {
- secretValue?: string;
- encryptedValue: string;
- iv: string;
- tag: string;
- accessType: SecretSharingAccessType;
- orgName?: string;
- expiresAt?: Date | string;
- expiresAfterViews?: number | null;
+ brandingConfig?: {
+ hasLogoUrl: boolean;
+ hasFaviconUrl: boolean;
+ primaryColor?: string;
+ secondaryColor?: string;
};
+ secret?: TSharedSecretResponse;
+ error?: string;
};
export type TGetSecretRequestByIdResponse = {
diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.ts
index 3a34576a4f..dcb64f6e9a 100644
--- a/frontend/src/hooks/api/subscriptions/types.ts
+++ b/frontend/src/hooks/api/subscriptions/types.ts
@@ -62,4 +62,5 @@ export type SubscriptionPlan = {
cardDeclinedReason?: string;
cardDeclinedDays?: number;
machineIdentityAuthTemplates: boolean;
+ secretShareExternalBranding: boolean;
};
diff --git a/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingBrandingSection.tsx b/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingBrandingSection.tsx
new file mode 100644
index 0000000000..9a014eb8e6
--- /dev/null
+++ b/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingBrandingSection.tsx
@@ -0,0 +1,230 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { LockIcon } from "lucide-react";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button, FormControl, Input } from "@app/components/v2";
+import { Badge } from "@app/components/v3";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { useUpdateOrg } from "@app/hooks/api";
+
+const hexColorRegex = /^#[0-9A-Fa-f]{6}$/;
+
+const formSchema = z.object({
+ logoUrl: z.string().url("Must be a valid URL").or(z.literal("")).optional(),
+ faviconUrl: z.string().url("Must be a valid URL").or(z.literal("")).optional(),
+ primaryColor: z
+ .string()
+ .regex(hexColorRegex, "Must be a valid hex color (e.g., #FF5733)")
+ .or(z.literal(""))
+ .optional(),
+ secondaryColor: z
+ .string()
+ .regex(hexColorRegex, "Must be a valid hex color (e.g., #FF5733)")
+ .or(z.literal(""))
+ .optional()
+});
+
+type TForm = z.infer<typeof formSchema>;
+
+export const SecretSharingBrandingSection = () => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+ const { mutateAsync, isPending } = useUpdateOrg();
+
+ const isFeatureEnabled = subscription?.secretShareExternalBranding;
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isDirty }
+ } = useForm<TForm>({
+ resolver: zodResolver(formSchema),
+ defaultValues: {
+ logoUrl: currentOrg?.secretShareBrandConfig?.logoUrl || "",
+ faviconUrl: currentOrg?.secretShareBrandConfig?.faviconUrl || "",
+ primaryColor: currentOrg?.secretShareBrandConfig?.primaryColor || "",
+ secondaryColor: currentOrg?.secretShareBrandConfig?.secondaryColor || ""
+ }
+ });
+
+ useEffect(() => {
+ if (currentOrg?.secretShareBrandConfig) {
+ reset({
+ logoUrl: currentOrg.secretShareBrandConfig.logoUrl || "",
+ faviconUrl: currentOrg.secretShareBrandConfig.faviconUrl || "",
+ primaryColor: currentOrg.secretShareBrandConfig.primaryColor || "",
+ secondaryColor: currentOrg.secretShareBrandConfig.secondaryColor || ""
+ });
+ }
+ }, [currentOrg?.secretShareBrandConfig, reset]);
+
+ const handleFormSubmit = async (data: TForm) => {
+ if (!currentOrg?.id) return;
+
+ const hasAnyValue = data.logoUrl || data.faviconUrl || data.primaryColor || data.secondaryColor;
+
+ await mutateAsync({
+ orgId: currentOrg.id,
+ secretShareBrandConfig: hasAnyValue
+ ? {
+ logoUrl: data.logoUrl || undefined,
+ faviconUrl: data.faviconUrl || undefined,
+ primaryColor: data.primaryColor || undefined,
+ secondaryColor: data.secondaryColor || undefined
+ }
+ : null
+ });
+
+ reset(data);
+
+ createNotification({
+ text: "Successfully updated secret sharing branding",
+ type: "success"
+ });
+ };
+
+ return (
+ <div className="mb-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex w-full items-center justify-between">
+ <div className="flex items-center gap-2">
+ <p className="text-xl font-medium">Custom Branding</p>
+ {!isFeatureEnabled && (
+ <Badge variant="info">
+ <LockIcon />
+ Enterprise
+ </Badge>
+ )}
+ </div>
+ </div>
+ <p className="mt-2 mb-4 text-sm text-gray-400">
+ Customize the appearance of your shared secret pages with your own branding.
+ </p>
+
+ {!isFeatureEnabled ? (
+ <div className="rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4 text-center">
+ <p className="text-sm text-mineshaft-300">
+ Custom branding for secret sharing pages is available on Enterprise plans.
+ </p>
+ </div>
+ ) : (
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Settings}>
+ {(isAllowed) => (
+ <form onSubmit={handleSubmit(handleFormSubmit)} autoComplete="off">
+ <div className="grid grid-cols-1 gap-4 md:grid-cols-2">
+ <Controller
+ control={control}
+ name="logoUrl"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Logo URL"
+ tooltipText="URL to your company logo (displayed on shared secret pages)"
+ >
+ <Input
+ {...field}
+ placeholder="https://example.com/logo.png"
+ isDisabled={!isAllowed}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="faviconUrl"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Favicon URL"
+ tooltipText="URL to your favicon (displayed in browser tab)"
+ >
+ <Input
+ {...field}
+ placeholder="https://example.com/favicon.ico"
+ isDisabled={!isAllowed}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="primaryColor"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Primary Color"
+ tooltipText="Background color for the page (hex format, e.g., #82cec0)"
+ >
+ <div className="flex items-center gap-2">
+ <Input
+ {...field}
+ placeholder="#82cec0"
+ isDisabled={!isAllowed}
+ className="flex-1"
+ />
+ {field.value && hexColorRegex.test(field.value) && (
+ <div
+ className="h-9 w-9 rounded border border-mineshaft-500"
+ style={{ backgroundColor: field.value }}
+ />
+ )}
+ </div>
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="secondaryColor"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label="Secondary Color"
+ tooltipText="Panel and component colors (hex format, e.g., #14211e)"
+ >
+ <div className="flex items-center gap-2">
+ <Input
+ {...field}
+ placeholder="#14211e"
+ isDisabled={!isAllowed}
+ className="flex-1"
+ />
+ {field.value && hexColorRegex.test(field.value) && (
+ <div
+ className="h-9 w-9 rounded border border-mineshaft-500"
+ style={{ backgroundColor: field.value }}
+ />
+ )}
+ </div>
+ </FormControl>
+ )}
+ />
+ </div>
+ <Button
+ colorSchema="secondary"
+ type="submit"
+ isLoading={isPending}
+ isDisabled={!isDirty || !isAllowed}
+ className="mt-4"
+ >
+ Save
+ </Button>
+ </form>
+ )}
+ </OrgPermissionCan>
+ )}
+ </div>
+ );
+};
diff --git a/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingSettingsTab.tsx b/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingSettingsTab.tsx
index 96517eaa94..63236b46ba 100644
--- a/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingSettingsTab.tsx
+++ b/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingSettingsTab.tsx
@@ -4,6 +4,7 @@ import { withPermission } from "@app/hoc";
import { OrgSecretShareLimitSection } from "./OrgSecretShareLimitSection";
import { SecretSharingAllowShareToAnyone } from "./SecretSharingAllowShareToAnyone";
+import { SecretSharingBrandingSection } from "./SecretSharingBrandingSection";
export const SecretSharingSettingsTab = withPermission(
() => {
@@ -11,6 +12,7 @@ export const SecretSharingSettingsTab = withPermission(
<div className="w-full">
<SecretSharingAllowShareToAnyone />
<OrgSecretShareLimitSection />
+ <SecretSharingBrandingSection />
</div>
);
},
diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/ViewSharedSecretByIDPage.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/ViewSharedSecretByIDPage.tsx
index 25b28b6451..ca3e480216 100644
--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/ViewSharedSecretByIDPage.tsx
+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/ViewSharedSecretByIDPage.tsx
@@ -1,17 +1,56 @@
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { Helmet } from "react-helmet";
import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
import { AxiosError } from "axios";
import { addSeconds, formatISO } from "date-fns";
+import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
+import { Lottie } from "@app/components/v2";
import { SessionStorageKeys } from "@app/const";
import { ROUTE_PATHS } from "@app/const/routes";
import { useGetActiveSharedSecretById } from "@app/hooks/api/secretSharing";
+import {
+ PasswordContainer,
+ SecretContainer,
+ SecretErrorContainer
+} from "@app/pages/public/ViewSharedSecretByIDPage/components";
-import { PasswordContainer, SecretContainer, SecretErrorContainer } from "./components";
+const DEFAULT_LOGO_URL = "/images/gradientLogo.svg";
+const DEFAULT_FAVICON_URL = "/infisical.ico";
+
+// Returns true if the color is considered "light"
+const isLightColor = (hexColor: string): boolean => {
+ const hex = hexColor.replace("#", "");
+ const r = parseInt(hex.substring(0, 2), 16);
+ const g = parseInt(hex.substring(2, 4), 16);
+ const b = parseInt(hex.substring(4, 6), 16);
+ const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
+ return luminance > 0.5;
+};
+
+// Adjusts color brightness by a literal amount (negative for darker, positive for lighter)
+const adjustColor = (hexColor: string, amount: number): string => {
+ const hex = hexColor.replace("#", "");
+ const r = Math.max(0, Math.min(255, parseInt(hex.substring(0, 2), 16) + amount));
+ const g = Math.max(0, Math.min(255, parseInt(hex.substring(2, 4), 16) + amount));
+ const b = Math.max(0, Math.min(255, parseInt(hex.substring(4, 6), 16) + amount));
+ // eslint-disable-next-line no-bitwise
+ return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
+};
+
+export type BrandingTheme = {
+ primaryColor: string;
+ secondaryColor: string;
+ textColor: string;
+ textMutedColor: string;
+ panelBg: string;
+ panelBorder: string;
+ inputBg: string;
+ buttonBg: string;
+};
const extractDetailsFromUrl = (urlEncodedKey: string) => {
if (urlEncodedKey) {
@@ -100,44 +139,138 @@ export const ViewSharedSecretByIDPage = () => {
isInvalidCredential || (fetchSecret?.isPasswordProtected && !fetchSecret.secret);
const isValidatingPassword = Boolean(password) && isFetching;
+ const brandingConfig = fetchSecret?.brandingConfig;
+ const hasCustomBranding = !!brandingConfig;
+
+ // Use proxy URLs for branding assets to avoid cross origin issues
+ const logoUrl = brandingConfig?.hasLogoUrl
+ ? `/api/v1/secret-sharing/shared/public/${id}/branding/logo`
+ : DEFAULT_LOGO_URL;
+ const faviconUrl = brandingConfig?.hasFaviconUrl
+ ? `/api/v1/secret-sharing/shared/public/${id}/branding/favicon`
+ : DEFAULT_FAVICON_URL;
+
+ const brandingTheme = useMemo((): BrandingTheme | undefined => {
+ if (!brandingConfig?.primaryColor) {
+ return undefined;
+ }
+
+ const primary = brandingConfig.primaryColor;
+ const secondary = brandingConfig.secondaryColor || primary;
+ const isSecondaryLight = isLightColor(secondary);
+
+ return {
+ primaryColor: primary,
+ secondaryColor: secondary,
+ // Text colors based on secondary brightness (for components)
+ textColor: isSecondaryLight ? "#1a1a1a" : "#f5f5f5",
+ textMutedColor: isSecondaryLight ? "#1a1a1acc" : "#f5f5f5cc",
+ // Panel and components based on secondary color
+ panelBg: secondary,
+ panelBorder: adjustColor(secondary, isSecondaryLight ? -30 : 30),
+ inputBg: adjustColor(secondary, isSecondaryLight ? -15 : 15),
+ buttonBg: secondary
+ };
+ }, [brandingConfig?.primaryColor, brandingConfig?.secondaryColor]);
+
+ const backgroundStyle = useMemo(() => {
+ if (!brandingTheme) {
+ return undefined;
+ }
+
+ const isPrimaryLight = isLightColor(brandingTheme.primaryColor);
+ const gradientStart = adjustColor(brandingTheme.primaryColor, isPrimaryLight ? -20 : 20);
+
+ return {
+ backgroundImage: `linear-gradient(to bottom right, ${gradientStart}, ${brandingTheme.primaryColor})`,
+ backgroundAttachment: "fixed"
+ } as React.CSSProperties;
+ }, [brandingTheme]);
+
+ useEffect(() => {
+ if (!faviconUrl) return;
+
+ const existingLink = document.querySelector("link[rel='icon']") as HTMLLinkElement | null;
+ if (existingLink) {
+ existingLink.href = faviconUrl;
+ } else {
+ const link = document.createElement("link");
+ link.rel = "icon";
+ link.href = faviconUrl;
+ document.head.appendChild(link);
+ }
+ }, [faviconUrl]);
+
+ if (isPending) {
+ return (
+ <div className="flex h-screen w-screen items-center justify-center bg-bunker-800">
+ <Lottie isAutoPlay icon="infisical_loading" className="h-32 w-32" />
+ </div>
+ );
+ }
+
return (
<>
<Helmet>
- <title>Securely Share Secrets | Infisical</title>
- <link rel="icon" href="/infisical.ico" />
+ <title>Securely Share Secrets{hasCustomBranding ? "" : " | Infisical"}</title>
<meta property="og:image" content="/images/message.png" />
<meta property="og:title" content="" />
<meta name="og:description" content="" />
</Helmet>
- <div className="flex h-screen flex-col justify-between overflow-auto bg-linear-to-tr from-mineshaft-700 to-bunker-800 text-gray-200 dark:scheme-dark">
+ <div
+ className={twMerge(
+ "flex h-screen flex-col justify-between overflow-auto text-gray-200 dark:scheme-dark",
+ !backgroundStyle && "bg-linear-to-tr from-mineshaft-700 to-bunker-800"
+ )}
+ style={backgroundStyle}
+ >
<div />
<div className="mx-auto w-full max-w-xl px-4 py-4 md:px-0">
<div className="mb-8 text-center">
<div className="mb-4 flex justify-center pt-8">
- <a target="_blank" rel="noopener noreferrer" href="https://infisical.com">
+ {hasCustomBranding ? (
<img
- src="/images/gradientLogo.svg"
+ src={logoUrl}
height={90}
width={120}
- alt="Infisical logo"
- className="cursor-pointer"
+ alt="Logo"
+ className="max-h-24 w-auto object-contain"
/>
- </a>
+ ) : (
+ <a target="_blank" rel="noopener noreferrer" href="https://infisical.com">
+ <img
+ src={logoUrl}
+ height={90}
+ width={120}
+ alt="Infisical logo"
+ className="cursor-pointer"
+ />
+ </a>
+ )}
</div>
- <h1 className="bg-linear-to-b from-white to-bunker-200 bg-clip-text text-center text-4xl font-medium text-transparent">
+ <h1
+ className={twMerge(
+ "bg-linear-to-b bg-clip-text text-center text-4xl font-medium text-transparent",
+ brandingTheme && isLightColor(brandingTheme.primaryColor)
+ ? "from-black to-bunker-500"
+ : "from-white to-bunker-200"
+ )}
+ >
View shared secret
</h1>
- <p className="text-md">
- Powered by{" "}
- <a
- href="https://github.com/infisical/infisical"
- target="_blank"
- rel="noopener noreferrer"
- className="text-bold bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent"
- >
- Infisical &rarr;
- </a>
- </p>
+ {!hasCustomBranding && (
+ <p className="text-md">
+ Powered by{" "}
+ <a
+ href="https://github.com/infisical/infisical"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-bold bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent"
+ >
+ Infisical &rarr;
+ </a>
+ </p>
+ )}
</div>
{(shouldShowPasswordPrompt || isValidatingPassword) && (
<PasswordContainer
@@ -146,61 +279,76 @@ export const ViewSharedSecretByIDPage = () => {
setPassword(el);
}}
isInvalidCredential={!isFetching && isInvalidCredential}
+ brandingTheme={brandingTheme}
/>
)}
{!isPending && (
<>
- {!error && fetchSecret?.secret && (
- <SecretContainer secret={fetchSecret.secret} secretKey={key} />
+ {!error && !fetchSecret?.error && fetchSecret?.secret && (
+ <SecretContainer
+ secret={fetchSecret.secret}
+ secretKey={key}
+ brandingTheme={brandingTheme}
+ />
+ )}
+ {(fetchSecret?.error || (error && !isInvalidCredential && !isUnauthorized)) && (
+ <SecretErrorContainer brandingTheme={brandingTheme} />
)}
- {error && !isInvalidCredential && !isUnauthorized && <SecretErrorContainer />}
</>
)}
- <div className="m-auto my-8 flex w-full">
- <div className="w-full border-t border-mineshaft-600" />
- </div>
- <div className="m-auto flex w-full flex-col rounded-md border border-primary-500/30 bg-primary/5 p-6 pt-5">
- <p className="w-full pb-2 text-lg font-medium text-mineshaft-100 md:pb-3 md:text-xl">
- Open source{" "}
- <span className="bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent">
- secret management
- </span>{" "}
- for developers
- </p>
- <div className="flex flex-col items-start sm:flex-row sm:items-center">
- <p className="md:text-md text-md mr-4">
- <a
- href="https://github.com/infisical/infisical"
- target="_blank"
- rel="noopener noreferrer"
- className="text-bold bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent"
- >
- Infisical
- </a>{" "}
- is the all-in-one secret management platform to securely manage secrets, configs,
- and certificates across your team and infrastructure.
- </p>
- <div className="mt-4 cursor-pointer sm:mt-0">
- <a target="_blank" rel="noopener noreferrer" href="https://infisical.com">
- <div className="flex items-center justify-between rounded-md border border-mineshaft-400/40 bg-mineshaft-600 px-3 py-2 duration-200 hover:border-primary/60 hover:bg-primary/20 hover:text-white">
- <p className="mr-4 whitespace-nowrap">Try Infisical</p>
- <FontAwesomeIcon icon={faArrowRight} />
+ {!hasCustomBranding && (
+ <>
+ <div className="m-auto my-8 flex w-full">
+ <div className="w-full border-t border-mineshaft-600" />
+ </div>
+ <div className="m-auto flex w-full flex-col rounded-md border border-primary-500/30 bg-primary/5 p-6 pt-5">
+ <p className="w-full pb-2 text-lg font-medium text-mineshaft-100 md:pb-3 md:text-xl">
+ Open source{" "}
+ <span className="bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent">
+ secret management
+ </span>{" "}
+ for developers
+ </p>
+ <div className="flex flex-col items-start sm:flex-row sm:items-center">
+ <p className="md:text-md text-md mr-4">
+ <a
+ href="https://github.com/infisical/infisical"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-bold bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent"
+ >
+ Infisical
+ </a>{" "}
+ is the all-in-one secret management platform to securely manage secrets,
+ configs, and certificates across your team and infrastructure.
+ </p>
+ <div className="mt-4 cursor-pointer sm:mt-0">
+ <a target="_blank" rel="noopener noreferrer" href="https://infisical.com">
+ <div className="flex items-center justify-between rounded-md border border-mineshaft-400/40 bg-mineshaft-600 px-3 py-2 duration-200 hover:border-primary/60 hover:bg-primary/20 hover:text-white">
+ <p className="mr-4 whitespace-nowrap">Try Infisical</p>
+ <FontAwesomeIcon icon={faArrowRight} />
+ </div>
+ </a>
</div>
- </a>
+ </div>
</div>
- </div>
- </div>
- </div>
- <div className="w-full bg-mineshaft-600 p-2">
- <p className="text-center text-sm text-mineshaft-300">
- Made with ❤️ by{" "}
- <a className="text-primary" href="https://infisical.com">
- Infisical
- </a>
- <br />
- 235 2nd st, San Francisco, California, 94105, United States. 🇺🇸
- </p>
+ </>
+ )}
</div>
+ {hasCustomBranding ? (
+ <div />
+ ) : (
+ <div className="w-full bg-mineshaft-600 p-2">
+ <p className="text-center text-sm text-mineshaft-300">
+ Made with ❤️ by{" "}
+ <a className="text-primary" href="https://infisical.com">
+ Infisical
+ </a>
+ <br />
+ 235 2nd st, San Francisco, California, 94105, United States. 🇺🇸
+ </p>
+ </div>
+ )}
</div>
</>
);
diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/PasswordContainer.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/PasswordContainer.tsx
index 8beb2e74bf..a7877bf187 100644
--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/PasswordContainer.tsx
+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/PasswordContainer.tsx
@@ -2,14 +2,18 @@ import { Controller, useForm } from "react-hook-form";
import { faArrowRight, faSpinner } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
+import { twMerge } from "tailwind-merge";
import { z } from "zod";
import { Button, FormControl, IconButton, Input } from "@app/components/v2";
+import { BrandingTheme } from "../ViewSharedSecretByIDPage";
+
type Props = {
onPasswordSubmit: (val: any) => void;
isSubmitting?: boolean;
isInvalidCredential?: boolean;
+ brandingTheme?: BrandingTheme;
};
const formSchema = z.object({
@@ -21,7 +25,8 @@ export type FormData = z.infer<typeof formSchema>;
export const PasswordContainer = ({
onPasswordSubmit,
isSubmitting,
- isInvalidCredential
+ isInvalidCredential,
+ brandingTheme
}: Props) => {
const { control, handleSubmit } = useForm<FormData>({
resolver: zodResolver(formSchema)
@@ -31,50 +36,86 @@ export const PasswordContainer = ({
onPasswordSubmit(password);
};
+ const panelStyle = brandingTheme
+ ? {
+ backgroundColor: brandingTheme.panelBg,
+ borderColor: brandingTheme.panelBorder
+ }
+ : undefined;
+
+ const inputStyle = brandingTheme
+ ? {
+ backgroundColor: brandingTheme.inputBg,
+ color: brandingTheme.textColor,
+ "--muted-color": brandingTheme.textMutedColor,
+ borderColor: brandingTheme.panelBorder
+ }
+ : undefined;
+
return (
- <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-4">
+ <div
+ className={`rounded-lg border p-4 ${brandingTheme ? "" : "border-mineshaft-600 bg-mineshaft-800"}`}
+ style={panelStyle}
+ >
<form onSubmit={handleSubmit(onFormSubmit)}>
<Controller
control={control}
name="password"
defaultValue=""
render={({ field, fieldState: { error } }) => (
- <FormControl
- isError={Boolean(error) || isInvalidCredential}
- errorText={isInvalidCredential ? "Invalid credential" : error?.message}
- isRequired
- label="Password"
- >
- <div className="flex items-center justify-between gap-2 rounded-md">
- <Input {...field} placeholder="Enter Password to view secret" type="password" />
- <div className="flex">
- <IconButton
- ariaLabel="copy icon"
- colorSchema="secondary"
- className="group relative"
- onClick={handleSubmit(onFormSubmit)}
- >
- <FontAwesomeIcon
- className={isSubmitting ? "fa-spin" : ""}
- icon={isSubmitting ? faSpinner : faArrowRight}
- />
- </IconButton>
+ <div style={brandingTheme ? { color: brandingTheme.textColor } : undefined}>
+ <FormControl
+ isError={Boolean(error) || isInvalidCredential}
+ errorText={isInvalidCredential ? "Invalid credential" : error?.message}
+ isRequired
+ label="Password"
+ labelClassName="text-[var(--muted-color)]"
+ >
+ <div className="flex items-center justify-between gap-2 rounded-md">
+ <Input
+ {...field}
+ placeholder="Enter password to view secret"
+ type="password"
+ style={inputStyle}
+ className={twMerge(
+ "h-9",
+ brandingTheme &&
+ "border placeholder-[var(--muted-color)]/70 focus:ring-[var(--muted-color)]/50"
+ )}
+ containerClassName="bg-transparent border-transparent h-9"
+ />
+ <div className="flex">
+ <IconButton
+ ariaLabel="submit password"
+ colorSchema="secondary"
+ className="group relative size-9 hover:opacity-70"
+ onClick={handleSubmit(onFormSubmit)}
+ style={inputStyle}
+ >
+ <FontAwesomeIcon
+ className={isSubmitting ? "fa-spin" : ""}
+ icon={isSubmitting ? faSpinner : faArrowRight}
+ />
+ </IconButton>
+ </div>
</div>
- </div>
- </FormControl>
+ </FormControl>
+ </div>
)}
/>
</form>
- <Button
- className="w-full bg-mineshaft-700 py-3 text-bunker-200"
- colorSchema="primary"
- variant="outline_bg"
- size="sm"
- onClick={() => window.open("/share-secret", "_blank", "noopener")}
- rightIcon={<FontAwesomeIcon icon={faArrowRight} className="pl-2" />}
- >
- Share Your Own Secret
- </Button>
+ {!brandingTheme && (
+ <Button
+ className="w-full bg-mineshaft-700 py-3 text-bunker-200"
+ colorSchema="primary"
+ variant="outline_bg"
+ size="sm"
+ onClick={() => window.open("/share-secret", "_blank", "noopener")}
+ rightIcon={<FontAwesomeIcon icon={faArrowRight} className="pl-2" />}
+ >
+ Share Your Own Secret
+ </Button>
+ )}
</div>
);
};
diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx
index 3193a1bf5b..f2136bcbd9 100644
--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx
+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx
@@ -11,16 +11,18 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { decryptSymmetric } from "@app/components/utilities/cryptography/crypto";
import { Button, IconButton } from "@app/components/v2";
import { useTimedReset, useToggle } from "@app/hooks";
-import { TViewSharedSecretResponse } from "@app/hooks/api/secretSharing";
+import { TSharedSecretResponse } from "@app/hooks/api/secretSharing";
+import { BrandingTheme } from "../ViewSharedSecretByIDPage";
import { SecretShareInfo } from "./SecretShareInfo";
type Props = {
- secret: TViewSharedSecretResponse["secret"];
+ secret: TSharedSecretResponse;
secretKey: string | null;
+ brandingTheme?: BrandingTheme;
};
-export const SecretContainer = ({ secret, secretKey: key }: Props) => {
+export const SecretContainer = ({ secret, secretKey: key, brandingTheme }: Props) => {
const [isVisible, setIsVisible] = useToggle(false);
const [, isCopyingSecret, setCopyTextSecret] = useTimedReset<string>({
initialState: "Copy to clipboard"
@@ -45,9 +47,38 @@ export const SecretContainer = ({ secret, secretKey: key }: Props) => {
const hiddenSecret = decryptedSecret ? "*".repeat(decryptedSecret.length) : "";
+ const panelStyle = brandingTheme
+ ? {
+ backgroundColor: brandingTheme.panelBg,
+ borderColor: brandingTheme.panelBorder
+ }
+ : undefined;
+
+ const secretDisplayStyle = brandingTheme
+ ? {
+ backgroundColor: brandingTheme.inputBg,
+ color: brandingTheme.textColor
+ }
+ : undefined;
+
+ const iconButtonStyle = brandingTheme
+ ? {
+ backgroundColor: brandingTheme.buttonBg,
+ color: brandingTheme.textColor
+ }
+ : undefined;
+
return (
- <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-4">
- <div className="flex items-center justify-between rounded-md bg-white/5 p-2 text-base text-gray-400">
+ <div
+ className={`rounded-lg border p-4 ${brandingTheme ? "" : "border-mineshaft-600 bg-mineshaft-800"}`}
+ style={panelStyle}
+ >
+ <div
+ className={`flex items-center justify-between rounded-md p-2 text-base ${
+ brandingTheme ? "" : "bg-white/5 text-gray-400"
+ }`}
+ style={secretDisplayStyle}
+ >
<p className="break-all whitespace-pre-wrap">
{isVisible ? decryptedSecret : hiddenSecret}
</p>
@@ -55,35 +86,39 @@ export const SecretContainer = ({ secret, secretKey: key }: Props) => {
<IconButton
ariaLabel="copy icon"
colorSchema="secondary"
- className="group relative"
+ className="group relative size-9 hover:opacity-70"
onClick={() => {
navigator.clipboard.writeText(decryptedSecret);
setCopyTextSecret("Copied");
}}
+ style={iconButtonStyle}
>
<FontAwesomeIcon icon={isCopyingSecret ? faCheck : faCopy} />
</IconButton>
<IconButton
- ariaLabel="copy icon"
+ ariaLabel="toggle visibility"
colorSchema="secondary"
- className="group relative ml-2"
+ className="group relative ml-2 size-9 hover:opacity-70"
onClick={() => setIsVisible.toggle()}
+ style={iconButtonStyle}
>
<FontAwesomeIcon icon={isVisible ? faEyeSlash : faEye} />
</IconButton>
</div>
</div>
- <SecretShareInfo secret={secret} />
- <Button
- className="mt-4 w-full bg-mineshaft-700 py-3 text-bunker-200"
- colorSchema="primary"
- variant="outline_bg"
- size="sm"
- onClick={() => window.open("/share-secret", "_blank", "noopener")}
- rightIcon={<FontAwesomeIcon icon={faArrowRight} className="pl-2" />}
- >
- Share Your Own Secret
- </Button>
+ <SecretShareInfo secret={secret} brandingTheme={brandingTheme} />
+ {!brandingTheme && (
+ <Button
+ className="mt-4 w-full bg-mineshaft-700 py-3 text-bunker-200"
+ colorSchema="primary"
+ variant="outline_bg"
+ size="sm"
+ onClick={() => window.open("/share-secret", "_blank", "noopener")}
+ rightIcon={<FontAwesomeIcon icon={faArrowRight} className="pl-2" />}
+ >
+ Share Your Own Secret
+ </Button>
+ )}
</div>
);
};
diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretErrorContainer.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretErrorContainer.tsx
index 173fa1b788..5868f3b376 100644
--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretErrorContainer.tsx
+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretErrorContainer.tsx
@@ -1,12 +1,33 @@
import { faKey } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { twMerge } from "tailwind-merge";
+
+import { BrandingTheme } from "../ViewSharedSecretByIDPage";
+
+type Props = {
+ brandingTheme?: BrandingTheme;
+};
+
+export const SecretErrorContainer = ({ brandingTheme }: Props) => {
+ const panelStyle = brandingTheme
+ ? {
+ backgroundColor: brandingTheme.panelBg,
+ borderColor: brandingTheme.panelBorder,
+ color: brandingTheme.textColor
+ }
+ : undefined;
-export const SecretErrorContainer = () => {
return (
- <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-8">
+ <div
+ className={twMerge(
+ "rounded-lg border p-8",
+ !brandingTheme && "border-mineshaft-600 bg-mineshaft-800"
+ )}
+ style={panelStyle}
+ >
<div className="text-center">
<FontAwesomeIcon icon={faKey} size="2x" />
- <p className="mt-4">The secret you are looking is missing or has expired</p>
+ <p className="mt-4">The secret you are looking for is missing or has expired</p>
</div>
</div>
);
diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx
index 1c4b863776..e23d5c5446 100644
--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx
+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx
@@ -2,13 +2,16 @@ import { faClock, faEye } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { format } from "date-fns";
-import { TViewSharedSecretResponse } from "@app/hooks/api/secretSharing";
+import { TSharedSecretResponse } from "@app/hooks/api/secretSharing";
+
+import { BrandingTheme } from "../ViewSharedSecretByIDPage";
type Props = {
- secret: TViewSharedSecretResponse["secret"];
+ secret: TSharedSecretResponse;
+ brandingTheme?: BrandingTheme;
};
-export const SecretShareInfo = ({ secret }: Props) => {
+export const SecretShareInfo = ({ secret, brandingTheme }: Props) => {
let timeRemaining: string | null = null;
if (secret.expiresAt) {
@@ -29,17 +32,40 @@ export const SecretShareInfo = ({ secret }: Props) => {
return null;
}
+ const infoStyle = brandingTheme
+ ? {
+ backgroundColor: brandingTheme.inputBg,
+ borderColor: brandingTheme.panelBorder,
+ color: brandingTheme.textMutedColor
+ }
+ : undefined;
+
+ const iconStyle = brandingTheme ? { color: brandingTheme.textMutedColor } : undefined;
+
return (
- <div className="mt-4 flex flex-col gap-2 rounded-md border border-mineshaft-600 bg-mineshaft-700/50 p-3 text-sm text-gray-300">
+ <div
+ className={`mt-4 flex flex-col gap-2 rounded-md border p-3 text-sm ${
+ brandingTheme ? "" : "border-mineshaft-600 bg-mineshaft-700/50 text-gray-300"
+ }`}
+ style={infoStyle}
+ >
{timeRemaining && (
<div className="flex items-center gap-2">
- <FontAwesomeIcon icon={faClock} className="text-mineshaft-400" />
+ <FontAwesomeIcon
+ icon={faClock}
+ className={brandingTheme ? "" : "text-mineshaft-400"}
+ style={iconStyle}
+ />
<span>Expires on {timeRemaining}</span>
</div>
)}
{viewsRemaining !== null && (
<div className="flex items-center gap-2">
- <FontAwesomeIcon icon={faEye} className="text-mineshaft-400" />
+ <FontAwesomeIcon
+ icon={faEye}
+ className={brandingTheme ? "" : "text-mineshaft-400"}
+ style={iconStyle}
+ />
<span>
{viewsRemaining === 0
? "This is the last time you can view this secret"