Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: derive SamlConfig from SAMLOptions #515

Merged
merged 3 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/passport-saml/saml-post-signing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SignedXml } from 'xml-crypto';
import * as algorithms from './algorithms';
import { SAMLOptions } from './saml';
import { SAMLOptions } from './types';

const authnRequestXPath = '/*[local-name(.)="AuthnRequest" and namespace-uri(.)="urn:oasis:names:tc:SAML:2.0:protocol"]';
const issuerXPath = '/*[local-name(.)="Issuer" and namespace-uri(.)="urn:oasis:names:tc:SAML:2.0:assertion"]';
Expand Down
40 changes: 1 addition & 39 deletions src/passport-saml/saml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { AudienceRestrictionXML,
LogoutRequestXML,
Profile,
RequestWithUser,
SAMLOptions,
SamlIDPListConfig,
SamlIDPEntryConfig,
SamlScopingConfig,
Expand Down Expand Up @@ -101,45 +102,6 @@ function callBackWithNameID(nameid: Node, callback: (err: Error | null, value: N
});
}

export interface SAMLOptions {
scoping: SamlScopingConfig;
xmlSignatureTransforms: string[];
digestAlgorithm: string;
providerName: string;
attributeConsumingServiceIndex: string | null;
RACComparison: string;
authnContext: string | string[];
disableRequestedAuthnContext: boolean;
disableRequestACSUrl: boolean;
acceptedClockSkewMs: number;
protocol: string;
host: string;
callbackUrl: string;
signatureAlgorithm: string;
path: string;
privateCert?: string;
privateKey: string;
logoutUrl: string;
entryPoint: string;
skipRequestCompression: boolean;
idpIssuer: string;
additionalParams: Record<string, string>;
additionalAuthorizeParams: Record<string, string>;
additionalLogoutParams: Record<string, string>;
cacheProvider: InMemoryCacheProvider;
issuer: string;
identifierFormat: string;
cert: string | string[] | CertCallback;
passive: boolean;
decryptionPvk: string;
logoutCallbackUrl: string;
validateInResponseTo: boolean;
requestIdExpirationPeriodMs: number;
audience: string;
forceAuthn: boolean;
}


class SAML {
options: SAMLOptions;
cacheProvider: InMemoryCacheProvider;
Expand Down
80 changes: 45 additions & 35 deletions src/passport-saml/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,60 @@ export interface AuthorizeOptions extends AuthenticateOptions {
samlFallback?: 'login-request' | 'logout-request';
}

export interface SamlConfig {
export interface SAMLOptions {
// Core
callbackUrl?: string;
path?: string;
protocol?: string;
host?: string;
entryPoint?: string;
issuer?: string;
callbackUrl: string;
path: string;
protocol: string;
host: string;
entryPoint: string;
issuer: string;
/** @deprecated use privateKey field instead */
privateCert?: string;
cert?: string | string[] | CertCallback;
decryptionPvk?: string;
signatureAlgorithm?: 'sha1' | 'sha256' | 'sha512';
privateKey: string;
cert: string | string[] | CertCallback;
decryptionPvk: string;
signatureAlgorithm: 'sha1' | 'sha256' | 'sha512';

// Additional SAML behaviors
additionalParams?: any;
additionalAuthorizeParams?: any;
identifierFormat?: string;
acceptedClockSkewMs?: number;
attributeConsumingServiceIndex?: string | null;
disableRequestedAuthnContext?: boolean;
authnContext?: string;
forceAuthn?: boolean;
skipRequestCompression?: boolean;
authnRequestBinding?: string;
RACComparison?: 'exact' | 'minimum' | 'maximum' | 'better';
providerName?: string;
passive?: boolean;
idpIssuer?: string;
audience?: string;
scoping? : SamlScopingConfig;
additionalParams: Record<string, string>;
additionalAuthorizeParams: Record<string, string>;
identifierFormat: string;
acceptedClockSkewMs: number;
attributeConsumingServiceIndex: string | null;
disableRequestedAuthnContext: boolean;
authnContext: string | string[];
forceAuthn: boolean;
skipRequestCompression: boolean;
RACComparison: 'exact' | 'minimum' | 'maximum' | 'better';
providerName: string;
passive: boolean;
idpIssuer: string;
audience: string;
scoping : SamlScopingConfig;

// InResponseTo Validation
validateInResponseTo?: boolean;
requestIdExpirationPeriodMs?: number;
cacheProvider?: CacheProvider;
validateInResponseTo: boolean;
requestIdExpirationPeriodMs: number;
cacheProvider: CacheProvider;

// Logout
logoutUrl: string;
additionalLogoutParams: Record<string, string>;
logoutCallbackUrl: string;

// extras
xmlSignatureTransforms: string[];
digestAlgorithm: string;
disableRequestACSUrl: boolean;
}

// Passport
export type SamlConfig = Partial<SAMLOptions> & StrategyOptions

interface StrategyOptions {
name?: string;
passReqToCallback?: boolean;

// Logout
logoutUrl?: string;
additionalLogoutParams?: any;
logoutCallbackUrl?: string;
authnRequestBinding?: string;
}

export interface SamlScopingConfig {
Expand Down