Skip to content

Commit

Permalink
StrategyOptionsCallback shouldn't have to pass all SAML options (#838)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Barth <[email protected]>
  • Loading branch information
oliverlockwood and cjbarth authored Mar 26, 2024
1 parent eacbbbb commit 430d94e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PassportSamlConfig>
) => void;

interface BaseMultiStrategyConfig {
getSamlOptions(req: express.Request, callback: StrategyOptionsCallback): void;
Expand Down
9 changes: 9 additions & 0 deletions test/multiSamlStrategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 430d94e

Please sign in to comment.