Merge pull request #30813 from ksamborski/passport-saml/multiSamlStrategy

Type definitions for passport-saml/multiSamlStrategy
This commit is contained in:
Andrew Casey
2018-12-03 13:29:32 -08:00
committed by GitHub
4 changed files with 38 additions and 1 deletions
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/bergie/passport-saml
// Definitions by: Chris Barth <https://github.com/cjbarth>
// Damian Assennato <https://github.com/dassennato>
// Karol Samborski <https://github.com/ksamborski>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
+10
View File
@@ -0,0 +1,10 @@
import express = require('express');
import { Strategy, SamlConfig, VerifyWithRequest, VerifyWithoutRequest } from './index';
export interface MultiSamlConfig extends SamlConfig {
getSamlOptions(req: express.Request, callback: (err: Error | null, samlOptions: SamlConfig) => void): void;
}
export class MultiSamlStrategy extends Strategy {
constructor(config: MultiSamlConfig, verify: VerifyWithRequest | VerifyWithoutRequest);
}
@@ -1,6 +1,7 @@
import express = require('express');
import passport = require('passport');
import SamlStrategy = require('passport-saml');
import MultiSamlStrategy = require('passport-saml/multiSamlStrategy');
import fs = require('fs');
const samlStrategy = new SamlStrategy.Strategy(
@@ -33,3 +34,27 @@ passport.use(samlStrategy);
passport.authenticate('samlCustomName', {failureRedirect: '/', failureFlash: true});
const metadata = samlStrategy.generateServiceProviderMetadata("decryptionCert");
const multiSamlStrategy = new MultiSamlStrategy.MultiSamlStrategy(
{
name: 'samlCustomName',
path: '/login/callback',
entryPoint: 'https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php',
issuer: 'passport-saml',
getSamlOptions(req: express.Request, callback: (err: Error | null, samlOptions: SamlStrategy.SamlConfig) => void) {
callback(null, {
name: 'samlCustomName',
path: '/login/callback2',
entryPoint: 'https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php',
issuer: 'passport-saml',
});
}
},
(profile: {}, done: (err: Error | null, user: {}, info?: {}) => void) => {
const user = {};
done(null, user);
}
);
passport.use(multiSamlStrategy);
passport.authenticate('samlCustomName', {failureRedirect: '/', failureFlash: true});
+2 -1
View File
@@ -18,6 +18,7 @@
},
"files": [
"index.d.ts",
"multiSamlStrategy.d.ts",
"passport-saml-tests.ts"
]
}
}