refactor: Update SSO.ts and StatusPageSSO.ts to include issuer URL in SAML request

This commit is contained in:
Simon Larsen 2024-05-06 13:13:52 +01:00
parent 8a5adfd589
commit 26683914bc
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
7 changed files with 30 additions and 16 deletions

View File

@ -23,6 +23,7 @@ import UpdateActiveMonitorCountToBillingProvider from './UpdateActiveMonitorCoun
import UpdateGlobalConfigFromEnv from './UpdateGlobalCongfigFromEnv'; import UpdateGlobalConfigFromEnv from './UpdateGlobalCongfigFromEnv';
import AddTelemetryServiceColor from './AddTelemetryServiceColor'; import AddTelemetryServiceColor from './AddTelemetryServiceColor';
import MoveGreenlockCertsToAcmeCerts from './MoveGreenlockCertsToAcmeCerts'; import MoveGreenlockCertsToAcmeCerts from './MoveGreenlockCertsToAcmeCerts';
import GenerateNewCertsForStatusPage from './GenerateNewCertsForStatusPage';
// This is the order in which the migrations will be run. Add new migrations to the end of the array. // This is the order in which the migrations will be run. Add new migrations to the end of the array.
@ -51,6 +52,7 @@ const DataMigrations: Array<DataMigrationBase> = [
new AddSecretKeyToIncomingRequestMonitor(), new AddSecretKeyToIncomingRequestMonitor(),
new AddTelemetryServiceColor(), new AddTelemetryServiceColor(),
new MoveGreenlockCertsToAcmeCerts(), new MoveGreenlockCertsToAcmeCerts(),
new GenerateNewCertsForStatusPage(),
]; ];
export default DataMigrations; export default DataMigrations;

View File

@ -396,7 +396,12 @@ describe('UserMiddleware', () => {
); );
expect( expect(
spyGetUserTenantAccessPermissionWithTenantId spyGetUserTenantAccessPermissionWithTenantId
).toHaveBeenCalledWith(req, projectId, userId); ).toHaveBeenCalledWith({
req,
tenantId: projectId,
userId,
isGlobalLogin: true,
});
expect(next).not.toBeCalled(); expect(next).not.toBeCalled();
}); });
@ -424,7 +429,12 @@ describe('UserMiddleware', () => {
expect( expect(
spyGetUserTenantAccessPermissionWithTenantId spyGetUserTenantAccessPermissionWithTenantId
).toHaveBeenCalledWith(req, projectId, userId); ).toHaveBeenCalledWith({
req,
tenantId: projectId,
userId,
isGlobalLogin: true,
});
}); });
test("should not call getUserTenantAccessPermissionForMultiTenant, when is-multi-tenant-query is set in the request header and but userGlobalAccessPermission's projectIds length is zero", async () => { test("should not call getUserTenantAccessPermissionForMultiTenant, when is-multi-tenant-query is set in the request header and but userGlobalAccessPermission's projectIds length is zero", async () => {
@ -548,7 +558,12 @@ describe('UserMiddleware', () => {
expect( expect(
spyGetUserTenantAccessPermissionWithTenantId spyGetUserTenantAccessPermissionWithTenantId
).toHaveBeenCalledWith(mockedRequest, projectId, userId); ).toHaveBeenCalledWith({
req: mockedRequest,
tenantId: projectId,
userId,
isGlobalLogin: true,
});
}); });
}); });

View File

@ -25,6 +25,7 @@ import UserNotificationRuleService from '../../Services/UserNotificationRuleServ
import Errors from '../../Utils/Errors'; import Errors from '../../Utils/Errors';
import CreateBy from '../../Types/Database/CreateBy'; import CreateBy from '../../Types/Database/CreateBy';
import { Host, HttpProtocol } from '../../EnvironmentConfig';
jest.setTimeout(60000); // Increase test timeout to 60 seconds becuase GitHub runners are slow jest.setTimeout(60000); // Increase test timeout to 60 seconds becuase GitHub runners are slow
@ -210,14 +211,14 @@ describe('TeamMemberService', () => {
templateType: 'InviteMember.hbs', templateType: 'InviteMember.hbs',
toEmail: new Email(nonExistingUserEmail), toEmail: new Email(nonExistingUserEmail),
vars: { vars: {
homeUrl: 'http://localhost/', homeUrl: `${HttpProtocol}${Host}`,
isNewUser: 'true', isNewUser: 'true',
projectName: project.name, projectName: project.name,
registerLink: `http://localhost/accounts/register?email=${nonExistingUserEmail.replace( registerLink: `${HttpProtocol}${Host}/accounts/register?email=${nonExistingUserEmail.replace(
'@', '@',
'%40' '%40'
)}`, )}`,
signInLink: 'http://localhost/accounts', signInLink: '${HttpProtocol}${Host}/accounts',
}, },
}, },
{ {

View File

@ -280,7 +280,7 @@ describe('StatementGenerator', () => {
/* eslint-disable prettier/prettier */ /* eslint-disable prettier/prettier */
expectStatement(statement, SQL` expectStatement(statement, SQL`
column_1 String NOT NULL, column_1 String NOT NULL,
column_2 Nested ( column_2 Nested NULL (
nested_column_1 String NOT NULL, nested_column_1 String NOT NULL,
nested_column_2 Int32 NULL nested_column_2 Int32 NULL
) )

View File

@ -206,7 +206,7 @@ const addDefaultRoutes: PromiseVoidFunction = async (): Promise<void> => {
return Response.sendErrorResponse( return Response.sendErrorResponse(
req, req,
res, res,
new NotFoundException('Not found') new NotFoundException(`Page not found - ${req.url}`)
); );
}); });
@ -214,7 +214,7 @@ const addDefaultRoutes: PromiseVoidFunction = async (): Promise<void> => {
return Response.sendErrorResponse( return Response.sendErrorResponse(
req, req,
res, res,
new NotFoundException('Not found') new NotFoundException(`Page not found - ${req.url}`)
); );
}); });
@ -222,7 +222,7 @@ const addDefaultRoutes: PromiseVoidFunction = async (): Promise<void> => {
return Response.sendErrorResponse( return Response.sendErrorResponse(
req, req,
res, res,
new NotFoundException('Not found') new NotFoundException(`Page not found - ${req.url}`)
); );
}); });
@ -230,7 +230,7 @@ const addDefaultRoutes: PromiseVoidFunction = async (): Promise<void> => {
return Response.sendErrorResponse( return Response.sendErrorResponse(
req, req,
res, res,
new NotFoundException('Not found') new NotFoundException(`Page not found - ${req.url}`)
); );
}); });

View File

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"compile": "tsc", "compile": "tsc",
"clear-modules": "rm -rf node_modules && rm package-lock.json && npm install", "clear-modules": "rm -rf node_modules && rm package-lock.json && npm install",
"test": "jest --detectOpenHandles", "test": "jest --detectOpenHandles --summaryThreshold=1",
"coverage": "jest --detectOpenHandles --coverage", "coverage": "jest --detectOpenHandles --coverage",
"debug:test": "cd .. && export $(grep -v '^#' config.env | xargs) && cd CommonServer && node --inspect node_modules/.bin/jest --runInBand ./Tests --detectOpenHandles", "debug:test": "cd .. && export $(grep -v '^#' config.env | xargs) && cd CommonServer && node --inspect node_modules/.bin/jest --runInBand ./Tests --detectOpenHandles",
"dep-check": "npm install -g depcheck && depcheck ./ --skip-missing=true" "dep-check": "npm install -g depcheck && depcheck ./ --skip-missing=true"

View File

@ -6,7 +6,6 @@ import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabas
import AcmeWriteCertificatesJob from './Jobs/AcmeWriteCertificates'; import AcmeWriteCertificatesJob from './Jobs/AcmeWriteCertificates';
import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; import { PromiseVoidFunction } from 'Common/Types/FunctionTypes';
import InfrastructureStatus from 'CommonServer/Infrastructure/Status'; import InfrastructureStatus from 'CommonServer/Infrastructure/Status';
import FetchCertificateJobs from './Jobs/FetchCertificates';
const APP_NAME: string = process.env['SERVICE_NAME']; const APP_NAME: string = process.env['SERVICE_NAME'];
@ -36,9 +35,6 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
PostgresAppInstance.getDatasourceOptions() PostgresAppInstance.getDatasourceOptions()
); );
// init the jobs
FetchCertificateJobs.init();
AcmeWriteCertificatesJob.init(); AcmeWriteCertificatesJob.init();
// add default routes // add default routes