Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import { FastifyPluginAsyncZod } from 'fastify-type-provider-zod'
import { SystemJobName } from '../../../helper/system-jobs/common'
import { systemJobHandlers } from '../../../helper/system-jobs/job-handlers'
import { systemJobsSchedule } from '../../../helper/system-jobs/system-job'
import cron from 'node-cron'
import { rejectedPromiseHandler } from '../../../helper/promise-handler'
import { authnSsoSamlController } from './authn-sso-saml-controller'
import { authnSsoSamlService } from './authn-sso-saml-service'

export const authnSsoSamlModule: FastifyPluginAsyncZod = async (app) => {
systemJobHandlers.registerJobHandler(SystemJobName.EXPIRE_PENDING_SSO_DOMAINS, async () => authnSsoSamlService(app.log).expirePendingSsoDomains())
void systemJobsSchedule(app.log).upsertJob({
job: {
name: SystemJobName.EXPIRE_PENDING_SSO_DOMAINS,
data: {},
jobId: SystemJobName.EXPIRE_PENDING_SSO_DOMAINS,
},
schedule: {
type: 'repeated',
cron: '0 * * * *',
},
cron.schedule('0 * * * *', () => {
rejectedPromiseHandler(authnSsoSamlService(app.log).expirePendingSsoDomains(), app.log)
})
await app.register(authnSsoSamlController, { prefix: '/v1/authn/saml' })
}
2 changes: 0 additions & 2 deletions packages/server/api/src/app/helper/system-jobs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export enum SystemJobName {
HARD_DELETE_PROJECT = 'hard-delete-project',
HARD_DELETE_PLATFORM = 'hard-delete-platform',
RESUME_DELAY_WAITPOINT = 'resume-delay-waitpoint',
EXPIRE_PENDING_SSO_DOMAINS = 'expire-pending-sso-domains',
}

type DeleteFlowDurableSystemJobData = {
Expand Down Expand Up @@ -55,7 +54,6 @@ type SystemJobDataMap = {
[SystemJobName.HARD_DELETE_PROJECT]: HardDeleteProjectSystemJobData
[SystemJobName.HARD_DELETE_PLATFORM]: HardDeletePlatformSystemJobData
[SystemJobName.RESUME_DELAY_WAITPOINT]: ResumeDelayWaitpointSystemJobData
[SystemJobName.EXPIRE_PENDING_SSO_DOMAINS]: Record<string, never>
}

export type SystemJobData<T extends SystemJobName = SystemJobName> = T extends SystemJobName ? SystemJobDataMap[T] : never
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ async function removeDeprecatedJobs(): Promise<void> {
'seven-days-in-trial',
'issue-reminder',
'update-flow-status',
'expire-pending-sso-domains',
]
const allSystemJobs = await systemJobsQueue.getJobSchedulers()
const knownJobNames = Object.values(SystemJobName) as string[]
Expand Down
Loading