samlesa 2.12.113 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of samlesa might be problematic. Click here for more details.
- package/build/index.js +18 -54
- package/build/index.js.map +1 -1
- package/build/src/api.js +18 -24
- package/build/src/api.js.map +1 -1
- package/build/src/binding-post.js +337 -365
- package/build/src/binding-post.js.map +1 -1
- package/build/src/binding-redirect.js +312 -340
- package/build/src/binding-redirect.js.map +1 -1
- package/build/src/binding-simplesign.js +201 -229
- package/build/src/binding-simplesign.js.map +1 -1
- package/build/src/entity-idp.js +119 -127
- package/build/src/entity-idp.js.map +1 -1
- package/build/src/entity-sp.js +88 -96
- package/build/src/entity-sp.js.map +1 -1
- package/build/src/entity.js +193 -225
- package/build/src/entity.js.map +1 -1
- package/build/src/extractor.js +361 -369
- package/build/src/extractor.js.map +1 -1
- package/build/src/flow.js +313 -320
- package/build/src/flow.js.map +1 -1
- package/build/src/libsaml.js +693 -721
- package/build/src/libsaml.js.map +1 -1
- package/build/src/metadata-idp.js +119 -127
- package/build/src/metadata-idp.js.map +1 -1
- package/build/src/metadata-sp.js +223 -231
- package/build/src/metadata-sp.js.map +1 -1
- package/build/src/metadata.js +138 -166
- package/build/src/metadata.js.map +1 -1
- package/build/src/types.js +4 -11
- package/build/src/types.js.map +1 -1
- package/build/src/urn.js +204 -212
- package/build/src/urn.js.map +1 -1
- package/build/src/utility.js +277 -292
- package/build/src/utility.js.map +1 -1
- package/build/src/validator.js +24 -27
- package/build/src/validator.js.map +1 -1
- package/package.json +13 -7
- package/types/api.d.ts +15 -0
- package/types/api.d.ts.map +1 -0
- package/types/binding-post.d.ts +48 -0
- package/types/binding-post.d.ts.map +1 -0
- package/types/binding-redirect.d.ts +54 -0
- package/types/binding-redirect.d.ts.map +1 -0
- package/types/binding-simplesign.d.ts +41 -0
- package/types/binding-simplesign.d.ts.map +1 -0
- package/types/entity-idp.d.ts +38 -0
- package/types/entity-idp.d.ts.map +1 -0
- package/types/entity-sp.d.ts +38 -0
- package/types/entity-sp.d.ts.map +1 -0
- package/types/entity.d.ts +100 -0
- package/types/entity.d.ts.map +1 -0
- package/types/extractor.d.ts +26 -0
- package/types/extractor.d.ts.map +1 -0
- package/types/flow.d.ts +7 -0
- package/types/flow.d.ts.map +1 -0
- package/types/index.d.ts +11 -10
- package/types/index.d.ts.map +1 -0
- package/types/libsaml.d.ts +208 -0
- package/types/libsaml.d.ts.map +1 -0
- package/types/metadata-idp.d.ts +25 -0
- package/types/metadata-idp.d.ts.map +1 -0
- package/types/metadata-sp.d.ts +37 -0
- package/types/metadata-sp.d.ts.map +1 -0
- package/types/metadata.d.ts +58 -0
- package/types/metadata.d.ts.map +1 -0
- package/types/src/api.d.ts +15 -13
- package/types/src/api.d.ts.map +1 -0
- package/types/src/binding-post.d.ts +48 -47
- package/types/src/binding-post.d.ts.map +1 -0
- package/types/src/binding-redirect.d.ts +54 -53
- package/types/src/binding-redirect.d.ts.map +1 -0
- package/types/src/binding-simplesign.d.ts +41 -40
- package/types/src/binding-simplesign.d.ts.map +1 -0
- package/types/src/entity-idp.d.ts +38 -37
- package/types/src/entity-idp.d.ts.map +1 -0
- package/types/src/entity-sp.d.ts +38 -36
- package/types/src/entity-sp.d.ts.map +1 -0
- package/types/src/entity.d.ts +100 -101
- package/types/src/entity.d.ts.map +1 -0
- package/types/src/extractor.d.ts +26 -25
- package/types/src/extractor.d.ts.map +1 -0
- package/types/src/flow.d.ts +7 -6
- package/types/src/flow.d.ts.map +1 -0
- package/types/src/libsaml.d.ts +208 -209
- package/types/src/libsaml.d.ts.map +1 -0
- package/types/src/metadata-idp.d.ts +25 -24
- package/types/src/metadata-idp.d.ts.map +1 -0
- package/types/src/metadata-sp.d.ts +37 -36
- package/types/src/metadata-sp.d.ts.map +1 -0
- package/types/src/metadata.d.ts +58 -59
- package/types/src/metadata.d.ts.map +1 -0
- package/types/src/types.d.ts +128 -129
- package/types/src/types.d.ts.map +1 -0
- package/types/src/urn.d.ts +195 -194
- package/types/src/urn.d.ts.map +1 -0
- package/types/src/utility.d.ts +133 -134
- package/types/src/utility.d.ts.map +1 -0
- package/types/src/validator.d.ts +4 -3
- package/types/src/validator.d.ts.map +1 -0
- package/types/types.d.ts +128 -0
- package/types/types.d.ts.map +1 -0
- package/types/urn.d.ts +195 -0
- package/types/urn.d.ts.map +1 -0
- package/types/utility.d.ts +133 -0
- package/types/utility.d.ts.map +1 -0
- package/types/validator.d.ts +4 -0
- package/types/validator.d.ts.map +1 -0
- package/.editorconfig +0 -19
- package/.github/FUNDING.yml +0 -1
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/samlify.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/.pre-commit.sh +0 -15
- package/.snyk +0 -8
- package/.travis.yml +0 -29
- package/Makefile +0 -25
- package/index.d.ts +0 -10
- package/index.js +0 -19
- package/index.js.map +0 -1
- package/index.ts +0 -28
- package/qodana.yaml +0 -29
- package/src/.idea/modules.xml +0 -8
- package/src/.idea/src.iml +0 -12
- package/src/.idea/vcs.xml +0 -6
- package/src/api.ts +0 -36
- package/src/binding-post.ts +0 -348
- package/src/binding-redirect.ts +0 -356
- package/src/binding-simplesign.ts +0 -238
- package/src/entity-idp.ts +0 -153
- package/src/entity-sp.ts +0 -114
- package/src/entity.ts +0 -243
- package/src/extractor.ts +0 -392
- package/src/flow.ts +0 -467
- package/src/libsaml.ts +0 -895
- package/src/metadata-idp.ts +0 -146
- package/src/metadata-sp.ts +0 -268
- package/src/metadata.ts +0 -166
- package/src/types.ts +0 -153
- package/src/urn.ts +0 -211
- package/src/utility.ts +0 -319
- package/src/validator.ts +0 -39
- package/tsconfig.json +0 -38
- package/tslint.json +0 -35
- package/types.d.ts +0 -2
package/build/src/entity-idp.js
CHANGED
|
@@ -1,128 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Identity provider can be configured using either metadata importing or idpSetting
|
|
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
|
-
parserType: 'SAMLRequest',
|
|
121
|
-
type: 'login',
|
|
122
|
-
binding: binding,
|
|
123
|
-
request: req
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.IdentityProvider = IdentityProvider;
|
|
1
|
+
/**
|
|
2
|
+
* @file entity-idp.ts
|
|
3
|
+
* @author tngan
|
|
4
|
+
* @desc Declares the actions taken by identity provider
|
|
5
|
+
*/
|
|
6
|
+
import { wording, } from './urn.js';
|
|
7
|
+
const binding = wording.binding;
|
|
8
|
+
import Entity from './entity.js';
|
|
9
|
+
import { namespace } from './urn.js';
|
|
10
|
+
import postBinding from './binding-post.js';
|
|
11
|
+
import redirectBinding from './binding-redirect.js';
|
|
12
|
+
import simpleSignBinding from './binding-simplesign.js';
|
|
13
|
+
import { flow } from './flow.js';
|
|
14
|
+
/**
|
|
15
|
+
* Identity provider can be configured using either metadata importing or idpSetting
|
|
16
|
+
*/
|
|
17
|
+
export default function (props) {
|
|
18
|
+
return new IdentityProvider(props);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Identity provider can be configured using either metadata importing or idpSetting
|
|
22
|
+
*/
|
|
23
|
+
export class IdentityProvider extends Entity {
|
|
24
|
+
constructor(idpSetting) {
|
|
25
|
+
const defaultIdpEntitySetting = {
|
|
26
|
+
wantAuthnRequestsSigned: false,
|
|
27
|
+
tagPrefix: {
|
|
28
|
+
encryptedAssertion: 'saml',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const entitySetting = Object.assign(defaultIdpEntitySetting, idpSetting);
|
|
32
|
+
// build attribute part
|
|
33
|
+
/* if (idpSetting.loginResponseTemplate) {
|
|
34
|
+
if (isString(idpSetting.loginResponseTemplate.context) && Array.isArray(idpSetting.loginResponseTemplate.attributes)) {
|
|
35
|
+
let attributeStatementTemplate;
|
|
36
|
+
let attributeTemplate;
|
|
37
|
+
if (!idpSetting.loginResponseTemplate.additionalTemplates || !idpSetting.loginResponseTemplate.additionalTemplates!.attributeStatementTemplate) {
|
|
38
|
+
attributeStatementTemplate = libsaml.defaultAttributeStatementTemplate;
|
|
39
|
+
} else {
|
|
40
|
+
attributeStatementTemplate = idpSetting.loginResponseTemplate.additionalTemplates!.attributeStatementTemplate!;
|
|
41
|
+
}
|
|
42
|
+
if (!idpSetting.loginResponseTemplate.additionalTemplates || !idpSetting.loginResponseTemplate.additionalTemplates!.attributeTemplate) {
|
|
43
|
+
attributeTemplate = libsaml.defaultAttributeTemplate;
|
|
44
|
+
} else {
|
|
45
|
+
attributeTemplate = idpSetting.loginResponseTemplate.additionalTemplates!.attributeTemplate!;
|
|
46
|
+
}
|
|
47
|
+
const replacement = {
|
|
48
|
+
AttributeStatement: libsaml.attributeStatementBuilder(idpSetting.loginResponseTemplate.attributes, attributeTemplate, attributeStatementTemplate),
|
|
49
|
+
};
|
|
50
|
+
entitySetting.loginResponseTemplate = {
|
|
51
|
+
...entitySetting.loginResponseTemplate,
|
|
52
|
+
context: libsaml.replaceTagsByValue(entitySetting.loginResponseTemplate!.context, replacement),
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
55
|
+
console.warn('Invalid login response template');
|
|
56
|
+
}
|
|
57
|
+
}*/
|
|
58
|
+
super(entitySetting, 'idp');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @desc Generates the login response for developers to design their own method
|
|
62
|
+
* @param params
|
|
63
|
+
*/
|
|
64
|
+
async createLoginResponse(params) {
|
|
65
|
+
const bindType = params?.binding ?? 'post';
|
|
66
|
+
const { sp, requestInfo = {}, user = {}, customTagReplacement, encryptThenSign = false, relayState = '', AttributeStatement = [] } = params;
|
|
67
|
+
const protocol = namespace.binding[bindType];
|
|
68
|
+
// can support post, redirect and post simple sign bindings for login response
|
|
69
|
+
let context = null;
|
|
70
|
+
switch (protocol) {
|
|
71
|
+
case namespace.binding.post:
|
|
72
|
+
context = await postBinding.base64LoginResponse(requestInfo, {
|
|
73
|
+
idp: this,
|
|
74
|
+
sp,
|
|
75
|
+
}, user, customTagReplacement, encryptThenSign, AttributeStatement);
|
|
76
|
+
break;
|
|
77
|
+
case namespace.binding.simpleSign:
|
|
78
|
+
context = await simpleSignBinding.base64LoginResponse(requestInfo, {
|
|
79
|
+
idp: this, sp,
|
|
80
|
+
}, user, relayState, customTagReplacement, AttributeStatement);
|
|
81
|
+
break;
|
|
82
|
+
case namespace.binding.redirect:
|
|
83
|
+
return redirectBinding.loginResponseRedirectURL(requestInfo, {
|
|
84
|
+
idp: this,
|
|
85
|
+
sp,
|
|
86
|
+
}, user, relayState, customTagReplacement, AttributeStatement);
|
|
87
|
+
default:
|
|
88
|
+
context = await postBinding.base64LoginResponse(requestInfo, {
|
|
89
|
+
idp: this,
|
|
90
|
+
sp,
|
|
91
|
+
}, user, customTagReplacement, encryptThenSign, AttributeStatement);
|
|
92
|
+
/* throw new Error('ERR_CREATE_RESPONSE_UNDEFINED_BINDING');*/
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
...context,
|
|
96
|
+
relayState,
|
|
97
|
+
entityEndpoint: sp.entityMeta.getAssertionConsumerService(bindType ?? 'post'),
|
|
98
|
+
type: 'SAMLResponse'
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Validation of the parsed URL parameters
|
|
103
|
+
* @param sp ServiceProvider instance
|
|
104
|
+
* @param binding Protocol binding
|
|
105
|
+
* @param req RequesmessageSigningOrderst
|
|
106
|
+
*/
|
|
107
|
+
parseLoginRequest(sp, binding, req) {
|
|
108
|
+
const self = this;
|
|
109
|
+
return flow({
|
|
110
|
+
from: sp,
|
|
111
|
+
self: self,
|
|
112
|
+
checkSignature: self.entityMeta.isWantAuthnRequestsSigned(),
|
|
113
|
+
parserType: 'SAMLRequest',
|
|
114
|
+
type: 'login',
|
|
115
|
+
binding: binding,
|
|
116
|
+
request: req
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
128
120
|
//# sourceMappingURL=entity-idp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-idp.js","sourceRoot":"","sources":["../../src/entity-idp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entity-idp.js","sourceRoot":"","sources":["../../src/entity-idp.ts"],"names":[],"mappings":"AAAA;;;;EAIE;AACF,OAAO,EACL,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAI/B,OAAO,MAAiC,MAAM,aAAa,CAAC;AAQ5D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAmB,MAAO,WAAW,CAAC;AAInD;;GAEG;AACH,MAAM,CAAC,OAAO,WAAU,KAA+B;IACrD,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,MAAM;IAI1C,YAAY,UAAoC;QAC9C,MAAM,uBAAuB,GAAG;YAC9B,uBAAuB,EAAE,KAAK;YAC9B,SAAS,EAAE;gBACT,kBAAkB,EAAE,MAAM;aAC3B;SACF,CAAC;QACF,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;QACzE,uBAAuB;QAC3B;;;;;;;;;;;;;;;;;;;;;;;;eAwBO;QACH,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAC9B,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
|
|
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
|
-
parserType: 'SAMLResponse',
|
|
90
|
-
type: 'login',
|
|
91
|
-
binding: binding,
|
|
92
|
-
request: request
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.ServiceProvider = ServiceProvider;
|
|
1
|
+
/**
|
|
2
|
+
* @file entity-sp.ts
|
|
3
|
+
* @author tngan
|
|
4
|
+
* @desc Declares the actions taken by service provider
|
|
5
|
+
*/
|
|
6
|
+
import Entity from './entity.js';
|
|
7
|
+
import { namespace } from './urn.js';
|
|
8
|
+
import redirectBinding from './binding-redirect.js';
|
|
9
|
+
import postBinding from './binding-post.js';
|
|
10
|
+
import simpleSignBinding from './binding-simplesign.js';
|
|
11
|
+
import { flow } from './flow.js';
|
|
12
|
+
/*
|
|
13
|
+
* @desc interface function
|
|
14
|
+
*/
|
|
15
|
+
export default function (props) {
|
|
16
|
+
return new ServiceProvider(props);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @desc Service provider can be configured using either metadata importing or spSetting
|
|
20
|
+
* @param {object} spSettingimport { FlowResult } from '../types/src/flow.d';
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
export class ServiceProvider extends Entity {
|
|
24
|
+
/**
|
|
25
|
+
* @desc Inherited from Entity
|
|
26
|
+
* @param {object} spSetting setting of service provider
|
|
27
|
+
*/
|
|
28
|
+
constructor(spSetting) {
|
|
29
|
+
const entitySetting = Object.assign({
|
|
30
|
+
authnRequestsSigned: false,
|
|
31
|
+
wantAssertionsSigned: false,
|
|
32
|
+
wantMessageSigned: false,
|
|
33
|
+
}, spSetting);
|
|
34
|
+
super(entitySetting, 'sp');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @desc Generates the login request for developers to design their own method
|
|
38
|
+
* @param {IdentityProvider} idp object of identity provider
|
|
39
|
+
* @param {string} binding protocol binding
|
|
40
|
+
* @param {function} customTagReplacement used when developers have their own login response template
|
|
41
|
+
*/
|
|
42
|
+
createLoginRequest(idp, binding = 'redirect', customTagReplacement) {
|
|
43
|
+
const nsBinding = namespace.binding;
|
|
44
|
+
const protocol = nsBinding[binding];
|
|
45
|
+
if (this.entityMeta.isAuthnRequestSigned() !== idp.entityMeta.isWantAuthnRequestsSigned()) {
|
|
46
|
+
throw new Error('ERR_METADATA_CONFLICT_REQUEST_SIGNED_FLAG');
|
|
47
|
+
}
|
|
48
|
+
let context = null;
|
|
49
|
+
switch (protocol) {
|
|
50
|
+
case nsBinding.redirect:
|
|
51
|
+
return redirectBinding.loginRequestRedirectURL({ idp, sp: this }, customTagReplacement);
|
|
52
|
+
case nsBinding.post:
|
|
53
|
+
context = postBinding.base64LoginRequest("/*[local-name(.)='AuthnRequest']", { idp, sp: this }, customTagReplacement);
|
|
54
|
+
break;
|
|
55
|
+
case nsBinding.simpleSign:
|
|
56
|
+
// Object context = {id, context, signature, sigAlg}
|
|
57
|
+
context = simpleSignBinding.base64LoginRequest({ idp, sp: this }, customTagReplacement);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
// Will support artifact in the next release
|
|
61
|
+
throw new Error('ERR_SP_LOGIN_REQUEST_UNDEFINED_BINDING');
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
...context,
|
|
65
|
+
relayState: this.entitySetting.relayState,
|
|
66
|
+
entityEndpoint: idp.entityMeta.getSingleSignOnService(binding),
|
|
67
|
+
type: 'SAMLRequest',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @desc Validation of the parsed the URL parameters
|
|
72
|
+
* @param {IdentityProvider} idp object of identity provider
|
|
73
|
+
* @param {string} binding protocol binding
|
|
74
|
+
* @param {request} req request
|
|
75
|
+
*/
|
|
76
|
+
parseLoginResponse(idp, binding, request) {
|
|
77
|
+
const self = this;
|
|
78
|
+
return flow({
|
|
79
|
+
from: idp,
|
|
80
|
+
self: self,
|
|
81
|
+
checkSignature: true, // saml response must have signature
|
|
82
|
+
parserType: 'SAMLResponse',
|
|
83
|
+
type: 'login',
|
|
84
|
+
binding: binding,
|
|
85
|
+
request: request
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
97
89
|
//# sourceMappingURL=entity-sp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-sp.js","sourceRoot":"","sources":["../../src/entity-sp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entity-sp.js","sourceRoot":"","sources":["../../src/entity-sp.ts"],"names":[],"mappings":"AAAA;;;;EAIE;AACF,OAAO,MAEN,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAmB,MAAO,WAAW,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,OAAO,WAAU,KAA8B;IACpD,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED;;;;EAIE;AACF,MA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