From 430d94eb670b4958f0524a2b612107d73e243d41 Mon Sep 17 00:00:00 2001 From: Oliver Lockwood Date: Tue, 26 Mar 2024 13:37:30 +0000 Subject: [PATCH] StrategyOptionsCallback shouldn't have to pass all SAML options (#838) Co-authored-by: Chris Barth --- src/types.ts | 5 ++++- test/multiSamlStrategy.spec.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index dded2775..ff23f061 100644 --- a/src/types.ts +++ b/src/types.ts @@ -36,7 +36,10 @@ export type VerifyWithoutRequest = (profile: Profile | null, done: VerifiedCallb export type PassportSamlConfig = SamlConfig & StrategyOptions; -export type StrategyOptionsCallback = (err: Error | null, samlOptions?: PassportSamlConfig) => void; +export type StrategyOptionsCallback = ( + err: Error | null, + samlOptions?: Partial +) => void; interface BaseMultiStrategyConfig { getSamlOptions(req: express.Request, callback: StrategyOptionsCallback): void; diff --git a/test/multiSamlStrategy.spec.ts b/test/multiSamlStrategy.spec.ts index 0949f655..e123ee24 100644 --- a/test/multiSamlStrategy.spec.ts +++ b/test/multiSamlStrategy.spec.ts @@ -25,6 +25,15 @@ describe("MultiSamlStrategy()", function () { expect(strategy).to.be.an.instanceOf(Strategy); }); + it("does not require any properties in the SamlOptionsCallback", function () { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const getSamlOptions: StrategyOptionsCallback = (err, samlOptions) => { + // do nothing; the return type is void + }; + + getSamlOptions(null, {}); + }); + it("throws if wrong finder is provided", function () { function createStrategy() { return new MultiSamlStrategy({} as MultiStrategyConfig, noop, noop);