requested changes & frontend lint

This commit is contained in:
Daniel Hougaard
2025-08-14 06:53:57 +04:00
parent 2113abcfdc
commit a37f1eb1f8
7 changed files with 16 additions and 24 deletions

View File

@@ -148,7 +148,7 @@ declare module "fastify" {
interface Session { interface Session {
callbackPort: string; callbackPort: string;
isAdminLogin: boolean; isAdminLogin: boolean;
orgSlug: string; orgSlug?: string;
} }
interface FastifyRequest { interface FastifyRequest {

View File

@@ -15,7 +15,8 @@ export async function up(knex: Knex): Promise<void> {
); );
await knex.schema.alterTable(TableName.Organization, (table) => { await knex.schema.alterTable(TableName.Organization, (table) => {
if (!hasGoogleSsoAuthEnforcedColumn) table.boolean(GOOGLE_SSO_AUTH_ENFORCED_COLUMN_NAME).defaultTo(false); if (!hasGoogleSsoAuthEnforcedColumn)
table.boolean(GOOGLE_SSO_AUTH_ENFORCED_COLUMN_NAME).defaultTo(false).notNullable();
if (!hasGoogleSsoAuthLastUsedColumn) table.timestamp(GOOGLE_SSO_AUTH_LAST_USED_COLUMN_NAME).nullable(); if (!hasGoogleSsoAuthLastUsedColumn) table.timestamp(GOOGLE_SSO_AUTH_LAST_USED_COLUMN_NAME).nullable();
}); });
} }

View File

@@ -37,7 +37,7 @@ export const OrganizationsSchema = z.object({
shareSecretsProductEnabled: z.boolean().default(true).nullable().optional(), shareSecretsProductEnabled: z.boolean().default(true).nullable().optional(),
maxSharedSecretLifetime: z.number().default(2592000).nullable().optional(), maxSharedSecretLifetime: z.number().default(2592000).nullable().optional(),
maxSharedSecretViewLimit: z.number().nullable().optional(), maxSharedSecretViewLimit: z.number().nullable().optional(),
googleSsoAuthEnforced: z.boolean().default(false).nullable().optional(), googleSsoAuthEnforced: z.boolean().default(false),
googleSsoAuthLastUsed: z.date().nullable().optional() googleSsoAuthLastUsed: z.date().nullable().optional()
}); });

View File

@@ -431,6 +431,12 @@ export const orgServiceFactory = ({
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Sso); ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Sso);
} }
if (authEnforced && googleSsoAuthEnforced) {
throw new BadRequestError({
message: "SAML/OIDC auth enforcement and Google SSO auth enforcement cannot be enabled at the same time."
});
}
if (authEnforced) { if (authEnforced) {
const samlCfg = await samlConfigDAL.findOne({ const samlCfg = await samlConfigDAL.findOne({
orgId, orgId,
@@ -461,25 +467,13 @@ export const orgServiceFactory = ({
} }
} }
if (googleSsoAuthEnforced || authEnforced) { if (googleSsoAuthEnforced) {
if (googleSsoAuthEnforced && authEnforced) {
throw new BadRequestError({
message: "Google SSO and SAML/OIDC auth enforcement cannot be enabled at the same time."
});
}
if (googleSsoAuthEnforced && currentOrg.authEnforced) { if (googleSsoAuthEnforced && currentOrg.authEnforced) {
throw new BadRequestError({ throw new BadRequestError({
message: "Google SSO auth enforcement cannot be enabled when SAML/OIDC auth enforcement is enabled." message: "Google SSO auth enforcement cannot be enabled when SAML/OIDC auth enforcement is enabled."
}); });
} }
if (authEnforced && currentOrg.googleSsoAuthEnforced) {
throw new BadRequestError({
message: "SAML/OIDC auth enforcement cannot be enabled when Google SSO auth enforcement is enabled."
});
}
if (!currentOrg.googleSsoAuthLastUsed) { if (!currentOrg.googleSsoAuthLastUsed) {
throw new BadRequestError({ throw new BadRequestError({
message: message:

View File

@@ -238,7 +238,9 @@ export const Navbar = () => {
} }
window.close(); window.close();
return; return;
} else if (org.googleSsoAuthEnforced) { }
if (org.googleSsoAuthEnforced) {
await logout.mutateAsync(); await logout.mutateAsync();
window.open(`/api/v1/sso/redirect/google?org_slug=${org.slug}`); window.open(`/api/v1/sso/redirect/google?org_slug=${org.slug}`);
window.close(); window.close();

View File

@@ -85,8 +85,6 @@ export const SelectOrganizationSection = () => {
if ((organization.authEnforced || organization.googleSsoAuthEnforced) && !canBypassOrgAuth) { if ((organization.authEnforced || organization.googleSsoAuthEnforced) && !canBypassOrgAuth) {
const authToken = jwtDecode(getAuthToken()) as { authMethod: AuthMethod }; const authToken = jwtDecode(getAuthToken()) as { authMethod: AuthMethod };
await new Promise((resolve) => setTimeout(resolve, 5_000));
// org has an org-level auth method enabled (e.g. SAML) // org has an org-level auth method enabled (e.g. SAML)
// -> logout + redirect to SAML SSO // -> logout + redirect to SAML SSO
let url = ""; let url = "";
@@ -215,8 +213,6 @@ export const SelectOrganizationSection = () => {
handleCliRedirect(); handleCliRedirect();
setIsInitialOrgCheckLoading(false); setIsInitialOrgCheckLoading(false);
} else { } else {
console.log(organizations.data);
console.log("Calling this with single org?!??!?!::::", organizations.data.length);
handleSelectOrganization(organizations.data[0]); handleSelectOrganization(organizations.data[0]);
} }
} else { } else {
@@ -226,7 +222,6 @@ export const SelectOrganizationSection = () => {
useEffect(() => { useEffect(() => {
if (defaultSelectedOrg) { if (defaultSelectedOrg) {
console.log("Calling this with default org?!??!?!::::", defaultSelectedOrg);
handleSelectOrganization(defaultSelectedOrg); handleSelectOrganization(defaultSelectedOrg);
} }
}, [defaultSelectedOrg]); }, [defaultSelectedOrg]);

View File

@@ -135,7 +135,7 @@ export const OrgGeneralAuthSection = ({
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}> <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
{(isAllowed) => ( {(isAllowed) => (
<Switch <Switch
id="enforce-org-auth" id="enforce-saml-auth"
onCheckedChange={(value) => onCheckedChange={(value) =>
handleEnforceOrgAuthToggle(value, EnforceAuthType.SAML) handleEnforceOrgAuthToggle(value, EnforceAuthType.SAML)
} }
@@ -158,7 +158,7 @@ export const OrgGeneralAuthSection = ({
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}> <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
{(isAllowed) => ( {(isAllowed) => (
<Switch <Switch
id="enforce-org-auth" id="enforce-oidc-auth"
isChecked={currentOrg?.authEnforced ?? false} isChecked={currentOrg?.authEnforced ?? false}
onCheckedChange={(value) => onCheckedChange={(value) =>
handleEnforceOrgAuthToggle(value, EnforceAuthType.OIDC) handleEnforceOrgAuthToggle(value, EnforceAuthType.OIDC)