Skip to content
Open
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
9 changes: 5 additions & 4 deletions src/binding-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { wording, namespace, StatusCode } from './urn';
import { BindingContext } from './entity';
import libsaml from './libsaml';
import utility, { get } from './utility';
import {SAMLDocumentTemplate} from './types'

const binding = wording.binding;

Expand All @@ -17,7 +18,7 @@ const binding = wording.binding;
* @param {object} entity object includes both idp and sp
* @param {function} customTagReplacement used when developers have their own login response template
*/
function base64LoginRequest(referenceTagXPath: string, entity: any, customTagReplacement?: (template: string) => BindingContext): BindingContext {
function base64LoginRequest(referenceTagXPath: string, entity: any, customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext): BindingContext {
const metadata = { idp: entity.idp.entityMeta, sp: entity.sp.entityMeta };
const spSetting = entity.sp.entitySetting;
let id: string = '';
Expand Down Expand Up @@ -79,7 +80,7 @@ function base64LoginRequest(referenceTagXPath: string, entity: any, customTagRep
* @param {function} customTagReplacement used when developers have their own login response template
* @param {boolean} encryptThenSign whether or not to encrypt then sign first (if signing). Defaults to sign-then-encrypt
*/
async function base64LoginResponse(requestInfo: any = {}, entity: any, user: any = {}, customTagReplacement?: (template: string) => BindingContext, encryptThenSign: boolean = false): Promise<BindingContext> {
async function base64LoginResponse(requestInfo: any = {}, entity: any, user: any = {}, customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext, encryptThenSign: boolean = false): Promise<BindingContext> {
const idpSetting = entity.idp.entitySetting;
const spSetting = entity.sp.entitySetting;
const id = idpSetting.generateID();
Expand Down Expand Up @@ -212,7 +213,7 @@ async function base64LoginResponse(requestInfo: any = {}, entity: any, user: any
* @param {function} customTagReplacement used when developers have their own login response template
* @return {string} base64 encoded request
*/
function base64LogoutRequest(user, referenceTagXPath, entity, customTagReplacement?: (template: string) => BindingContext): BindingContext {
function base64LogoutRequest(user, referenceTagXPath, entity, customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext): BindingContext {
const metadata = { init: entity.init.entityMeta, target: entity.target.entityMeta };
const initSetting = entity.init.entitySetting;
const nameIDFormat = initSetting.nameIDFormat;
Expand Down Expand Up @@ -270,7 +271,7 @@ function base64LogoutRequest(user, referenceTagXPath, entity, customTagReplaceme
* @param {object} entity object includes both idp and sp
* @param {function} customTagReplacement used when developers have their own login response template
*/
function base64LogoutResponse(requestInfo: any, entity: any, customTagReplacement: (template: string) => BindingContext): BindingContext {
function base64LogoutResponse(requestInfo: any, entity: any, customTagReplacement: (template: SAMLDocumentTemplate) => BindingContext): BindingContext {
const metadata = {
init: entity.init.entityMeta,
target: entity.target.entityMeta,
Expand Down
9 changes: 5 additions & 4 deletions src/binding-redirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IdentityProvider as Idp } from './entity-idp';
import { ServiceProvider as Sp } from './entity-sp';
import * as url from 'url';
import { wording, namespace } from './urn';
import {SAMLDocumentTemplate} from './types'

const binding = wording.binding;
const urlParams = wording.urlParams;
Expand Down Expand Up @@ -83,7 +84,7 @@ function buildRedirectURL(opts: BuildRedirectConfig) {
* @param {function} customTagReplacement used when developers have their own login response template
* @return {string} redirect URL
*/
function loginRequestRedirectURL(entity: { idp: Idp, sp: Sp }, customTagReplacement?: (template: string) => BindingContext): BindingContext {
function loginRequestRedirectURL(entity: { idp: Idp, sp: Sp }, customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext): BindingContext {

const metadata: any = { idp: entity.idp.entityMeta, sp: entity.sp.entityMeta };
const spSetting: any = entity.sp.entitySetting;
Expand Down Expand Up @@ -134,7 +135,7 @@ function loginRequestRedirectURL(entity: { idp: Idp, sp: Sp }, customTagReplacem
* @param {String} relayState the relaystate sent by sp corresponding request
* @param {function} customTagReplacement used when developers have their own login response template
*/
function loginResponseRedirectURL(requestInfo: any, entity: any, user: any = {}, relayState?: string, customTagReplacement?: (template: string) => BindingContext): BindingContext {
function loginResponseRedirectURL(requestInfo: any, entity: any, user: any = {}, relayState?: string, customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext): BindingContext {
const idpSetting = entity.idp.entitySetting;
const spSetting = entity.sp.entitySetting;
const metadata = {
Expand Down Expand Up @@ -231,7 +232,7 @@ function loginResponseRedirectURL(requestInfo: any, entity: any, user: any = {},
* @param {function} customTagReplacement used when developers have their own login response template
* @return {string} redirect URL
*/
function logoutRequestRedirectURL(user, entity, relayState?: string, customTagReplacement?: (template: string, tags: object) => BindingContext): BindingContext {
function logoutRequestRedirectURL(user, entity, relayState?: string, customTagReplacement?: (template: SAMLDocumentTemplate, tags: object) => BindingContext): BindingContext {
const metadata = { init: entity.init.entityMeta, target: entity.target.entityMeta };
const initSetting = entity.init.entitySetting;
let id: string = initSetting.generateID();
Expand Down Expand Up @@ -278,7 +279,7 @@ function logoutRequestRedirectURL(user, entity, relayState?: string, customTagRe
* @param {object} entity object includes both idp and sp
* @param {function} customTagReplacement used when developers have their own login response template
*/
function logoutResponseRedirectURL(requestInfo: any, entity: any, relayState?: string, customTagReplacement?: (template: string) => BindingContext): BindingContext {
function logoutResponseRedirectURL(requestInfo: any, entity: any, relayState?: string, customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext): BindingContext {
const metadata = {
init: entity.init.entityMeta,
target: entity.target.entityMeta,
Expand Down
5 changes: 3 additions & 2 deletions src/binding-simplesign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { wording, StatusCode } from './urn';
import { BindingContext, SimpleSignComputedContext } from './entity';
import libsaml from './libsaml';
import utility, { get } from './utility';
import {SAMLDocumentTemplate} from './types'

const binding = wording.binding;
const urlParams = wording.urlParams;
Expand Down Expand Up @@ -75,7 +76,7 @@ function buildSimpleSignature(opts: BuildSimpleSignConfig) : string {
* @param {object} entity object includes both idp and sp
* @param {function} customTagReplacement used when developers have their own login response template
*/
function base64LoginRequest(entity: any, customTagReplacement?: (template: string) => BindingContext): SimpleSignComputedContext {
function base64LoginRequest(entity: any, customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext): SimpleSignComputedContext {
const metadata = { idp: entity.idp.entityMeta, sp: entity.sp.entityMeta };
const spSetting = entity.sp.entitySetting;
let id: string = '';
Expand Down Expand Up @@ -134,7 +135,7 @@ function base64LoginRequest(entity: any, customTagReplacement?: (template: strin
* @param {string} relayState the relay state
* @param {function} customTagReplacement used when developers have their own login response template
*/
async function base64LoginResponse(requestInfo: any = {}, entity: any, user: any = {}, relayState?: string, customTagReplacement?: (template: string) => BindingContext): Promise<BindingSimpleSignContext> {
async function base64LoginResponse(requestInfo: any = {}, entity: any, user: any = {}, relayState?: string, customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext): Promise<BindingSimpleSignContext> {
const idpSetting = entity.idp.entitySetting;
const spSetting = entity.sp.entitySetting;
const id = idpSetting.generateID();
Expand Down
3 changes: 2 additions & 1 deletion src/entity-idp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import simpleSignBinding from './binding-simplesign';
import { flow, FlowResult } from './flow';
import { isString } from './utility';
import { BindingContext } from './entity';
import {SAMLDocumentTemplate} from './types'

/**
* Identity provider can be configured using either metadata importing or idpSetting
Expand Down Expand Up @@ -85,7 +86,7 @@ export class IdentityProvider extends Entity {
requestInfo: { [key: string]: any },
binding: string,
user: { [key: string]: any },
customTagReplacement?: (template: string) => BindingContext,
customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext,
encryptThenSign?: boolean,
relayState?: string,
) {
Expand Down
6 changes: 3 additions & 3 deletions src/entity-sp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import redirectBinding from './binding-redirect';
import postBinding from './binding-post';
import simpleSignBinding from './binding-simplesign';
import { flow, FlowResult } from './flow';

import {SAMLDocumentTemplate} from './types'
/*
* @desc interface function
*/
Expand Down Expand Up @@ -57,7 +57,7 @@ export class ServiceProvider extends Entity {
public createLoginRequest(
idp: IdentityProvider,
binding = 'redirect',
customTagReplacement?: (template: string) => BindingContext,
customTagReplacement?: (template: SAMLDocumentTemplate) => BindingContext,
): BindingContext | PostBindingContext| SimpleSignBindingContext {
const nsBinding = namespace.binding;
const protocol = nsBinding[binding];
Expand All @@ -82,7 +82,7 @@ export class ServiceProvider extends Entity {
default:
// Will support artifact in the next release
throw new Error('ERR_SP_LOGIN_REQUEST_UNDEFINED_BINDING');
}
}

return {
...context,
Expand Down