mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Add type defintion for Profile and fix multiSamlStrategy types. (#33851)
* Add missing types and fix typings for multiSamlStrategy * Update SamlConfig required fields
This commit is contained in:
committed by
Wesley Wigham
parent
c00200d2ad
commit
70fbf57f7b
Vendored
+21
-4
@@ -20,9 +20,9 @@ export interface CacheProvider {
|
||||
remove(key: string, callback: (err: Error | null, key: string) => void | null): void;
|
||||
}
|
||||
|
||||
export type VerifiedCallback = (err: Error | null, user: object, info: object) => void;
|
||||
export type VerifiedCallback = (err: Error | null, user?: object, info?: object) => void;
|
||||
|
||||
export type VerifyWithRequest = (req: express.Request, profile: object, done: VerifiedCallback) => void;
|
||||
export type VerifyWithRequest = (req: express.Request, profile: Profile, done: VerifiedCallback) => void;
|
||||
|
||||
export type VerifyWithoutRequest = (profile: object, done: VerifiedCallback) => void;
|
||||
|
||||
@@ -41,8 +41,8 @@ export interface SamlConfig {
|
||||
path?: string;
|
||||
protocol?: string;
|
||||
host?: string;
|
||||
entryPoint: string;
|
||||
issuer: string;
|
||||
entryPoint?: string;
|
||||
issuer?: string;
|
||||
privateCert?: string;
|
||||
cert?: string | string[] | CertCallback;
|
||||
decryptionPvk?: string;
|
||||
@@ -82,3 +82,20 @@ export interface AuthenticateOptions extends passport.AuthenticateOptions {
|
||||
export interface AuthorizeOptions extends AuthenticateOptions {
|
||||
samlFallback?: string;
|
||||
}
|
||||
|
||||
export type Profile = {
|
||||
issuer?: string;
|
||||
sessionIndex?: string;
|
||||
nameID?: string;
|
||||
nameIDFormat?: string;
|
||||
nameQualifier?: string;
|
||||
spNameQualifier?: string;
|
||||
ID?: string;
|
||||
mail?: string; // InCommon Attribute urn:oid:0.9.2342.19200300.100.1.3
|
||||
email?: string; // `mail` if not present in the assertion
|
||||
getAssertionXml(): string; // get the raw assertion XML
|
||||
getAssertion(): object; // get the assertion XML parsed as a JavaScript object
|
||||
getSamlResponseXml(): string; // get the raw SAML response XML
|
||||
} & {
|
||||
[attributeName: string]: string; // arbitrary `AttributeValue`s
|
||||
};
|
||||
|
||||
+10
-4
@@ -1,10 +1,16 @@
|
||||
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;
|
||||
declare namespace MultiSamlStrategy {
|
||||
type SamlOptionsCallback = (err: Error | null, samlOptions?: SamlConfig) => void;
|
||||
|
||||
interface MultiSamlConfig extends SamlConfig {
|
||||
getSamlOptions(req: express.Request, callback: SamlOptionsCallback): void;
|
||||
}
|
||||
}
|
||||
|
||||
export class MultiSamlStrategy extends Strategy {
|
||||
constructor(config: MultiSamlConfig, verify: VerifyWithRequest | VerifyWithoutRequest);
|
||||
declare class MultiSamlStrategy extends Strategy {
|
||||
constructor(config: MultiSamlStrategy.MultiSamlConfig, verify: VerifyWithRequest | VerifyWithoutRequest);
|
||||
}
|
||||
|
||||
export = MultiSamlStrategy;
|
||||
|
||||
@@ -35,24 +35,26 @@ passport.authenticate('samlCustomName', {failureRedirect: '/', failureFlash: tru
|
||||
|
||||
const metadata = samlStrategy.generateServiceProviderMetadata("decryptionCert");
|
||||
|
||||
const multiSamlStrategy = new MultiSamlStrategy.MultiSamlStrategy(
|
||||
const multiSamlStrategy = new 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) {
|
||||
getSamlOptions(req: express.Request, callback: MultiSamlStrategy.SamlOptionsCallback) {
|
||||
callback(null, {
|
||||
name: 'samlCustomName',
|
||||
path: '/login/callback2',
|
||||
entryPoint: 'https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php',
|
||||
issuer: 'passport-saml',
|
||||
});
|
||||
});
|
||||
callback(new Error("SAML Options Error"));
|
||||
}
|
||||
},
|
||||
(profile: {}, done: (err: Error | null, user: {}, info?: {}) => void) => {
|
||||
(profile: {}, done: (err: Error | null, user?: {}, info?: {}) => void) => {
|
||||
const user = {};
|
||||
done(null, user);
|
||||
done(new Error("Verify Request Error"));
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user