forked from node-saml/passport-saml
/
types.ts
185 lines (155 loc) · 4.83 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import type * as express from "express";
import * as passport from "passport";
import type { CacheProvider } from "./inmemory-cache-provider";
export type CertCallback = (
callback: (err: Error | null, cert?: string | string[]) => void
) => void;
export type RacComparision = "exact" | "minimum" | "maximum" | "better";
export type SignatureAlgorithm = "sha1" | "sha256" | "sha512";
export interface AuthenticateOptions extends passport.AuthenticateOptions {
samlFallback?: "login-request" | "logout-request";
additionalParams?: Record<string, any>;
}
export interface AuthorizeOptions extends AuthenticateOptions {
samlFallback?: "login-request" | "logout-request";
}
export interface SamlSigningOptions {
privateKey?: string | Buffer;
signatureAlgorithm?: SignatureAlgorithm;
xmlSignatureTransforms?: string[];
digestAlgorithm?: string;
}
/**
* These are SAML options that must be provided to construct a new SAML Strategy
*/
export interface MandatorySamlOptions {
cert: string | string[] | CertCallback;
}
/**
* The options required to use a SAML strategy
* These may be provided by means of defaults specified in the constructor
*/
export interface SamlOptions extends SamlSigningOptions, MandatorySamlOptions {
// Core
callbackUrl?: string;
path: string;
protocol?: string;
host: string;
entryPoint?: string;
issuer: string;
decryptionPvk?: string | Buffer;
// Additional SAML behaviors
additionalParams: Record<string, string>;
additionalAuthorizeParams: Record<string, string>;
identifierFormat?: string | null;
acceptedClockSkewMs: number;
attributeConsumingServiceIndex?: string;
disableRequestedAuthnContext: boolean;
authnContext: string[];
forceAuthn: boolean;
skipRequestCompression: boolean;
authnRequestBinding?: string;
racComparison: RacComparision;
providerName?: string;
passive: boolean;
idpIssuer?: string;
audience?: string;
scoping?: SamlScopingConfig;
wantAssertionsSigned?: boolean;
maxAssertionAgeMs: number;
// InResponseTo Validation
validateInResponseTo: boolean;
requestIdExpirationPeriodMs: number;
cacheProvider: CacheProvider;
// Logout
logoutUrl: string;
additionalLogoutParams: Record<string, string>;
logoutCallbackUrl?: string;
// extras
disableRequestAcsUrl: boolean;
}
export interface StrategyOptions {
name?: string;
passReqToCallback?: boolean;
}
/**
* These options are availble for configuring a SAML strategy
*/
export type SamlConfig = Partial<SamlOptions> & StrategyOptions & MandatorySamlOptions;
export interface SamlScopingConfig {
idpList?: SamlIDPListConfig[];
proxyCount?: number;
requesterId?: string[] | string;
}
export type XMLValue = string | number | boolean | null | XMLObject | XMLValue[];
export type XMLObject = {
[key: string]: XMLValue;
};
export type XMLInput = XMLObject;
export interface AuthorizeRequestXML {
"samlp:AuthnRequest": XMLInput;
}
export interface LogoutRequestXML {
"samlp:LogoutRequest": {
"saml:NameID": XMLInput;
[key: string]: XMLValue;
};
}
export interface ServiceMetadataXML {
EntityDescriptor: {
[key: string]: XMLValue;
SPSSODescriptor: XMLObject;
};
}
export interface AudienceRestrictionXML {
Audience?: XMLObject[];
}
export type XMLOutput = Record<string, any>;
export interface SamlIDPListConfig {
entries: SamlIDPEntryConfig[];
getComplete?: string;
}
export interface SamlIDPEntryConfig {
providerId: string;
name?: string;
loc?: string;
}
export interface 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
["urn:oid:0.9.2342.19200300.100.1.3"]?: string;
getAssertionXml?(): string; // get the raw assertion XML
getAssertion?(): Record<string, unknown>; // get the assertion XML parsed as a JavaScript object
getSamlResponseXml?(): string; // get the raw SAML response XML
[attributeName: string]: unknown; // arbitrary `AttributeValue`s
}
export interface RequestWithUser extends express.Request {
samlLogoutRequest: any;
user?: Profile;
}
export type VerifiedCallback = (
err: Error | null,
user?: Record<string, unknown>,
info?: Record<string, unknown>
) => void;
export type VerifyWithRequest = (
req: express.Request,
profile: Profile | null | undefined,
done: VerifiedCallback
) => void;
export type VerifyWithoutRequest = (
profile: Profile | null | undefined,
done: VerifiedCallback
) => void;
export type SamlOptionsCallback = (err: Error | null, samlOptions?: SamlConfig) => void;
interface BaseMultiSamlConfig {
getSamlOptions(req: express.Request, callback: SamlOptionsCallback): void;
}
export type MultiSamlConfig = Partial<SamlConfig> & StrategyOptions & BaseMultiSamlConfig;