samlesa 2.12.3 → 2.12.6
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 +54 -64
- package/build/index.js.map +1 -1
- package/build/src/api.js +24 -23
- package/build/src/api.js.map +1 -1
- package/build/src/binding-post.js +358 -368
- package/build/src/binding-post.js.map +1 -1
- package/build/src/binding-redirect.js +333 -332
- package/build/src/binding-redirect.js.map +1 -1
- package/build/src/binding-simplesign.js +222 -232
- package/build/src/binding-simplesign.js.map +1 -1
- package/build/src/entity-idp.js +132 -130
- package/build/src/entity-idp.js.map +1 -1
- package/build/src/entity-sp.js +96 -96
- package/build/src/entity-sp.js.map +1 -1
- package/build/src/entity.js +225 -235
- package/build/src/entity.js.map +1 -1
- package/build/src/extractor.js +369 -369
- package/build/src/extractor.js.map +1 -1
- package/build/src/flow.js +320 -319
- package/build/src/flow.js.map +1 -1
- package/build/src/libsaml.js +660 -641
- package/build/src/libsaml.js.map +1 -1
- package/build/src/metadata-idp.js +127 -127
- package/build/src/metadata-idp.js.map +1 -1
- package/build/src/metadata-sp.js +231 -231
- package/build/src/metadata-sp.js.map +1 -1
- package/build/src/metadata.js +166 -176
- package/build/src/metadata.js.map +1 -1
- package/build/src/types.js +11 -11
- package/build/src/urn.js +212 -212
- package/build/src/urn.js.map +1 -1
- package/build/src/utility.js +292 -248
- package/build/src/utility.js.map +1 -1
- package/build/src/validator.js +27 -26
- package/build/src/validator.js.map +1 -1
- package/index.d.ts +10 -10
- package/index.js +18 -18
- package/package.json +1 -5
- package/qodana.yaml +29 -29
- package/src/binding-post.ts +1 -1
- package/src/binding-redirect.ts +83 -64
- package/src/entity-idp.ts +26 -20
- package/src/libsaml.ts +79 -48
- package/src/utility.ts +147 -76
- package/types/index.d.ts +10 -10
- package/types/src/api.d.ts +13 -13
- package/types/src/binding-post.d.ts +46 -46
- package/types/src/binding-redirect.d.ts +52 -52
- package/types/src/binding-simplesign.d.ts +39 -39
- package/types/src/entity-idp.d.ts +35 -42
- package/types/src/entity-sp.d.ts +36 -36
- package/types/src/entity.d.ts +101 -99
- package/types/src/extractor.d.ts +25 -25
- package/types/src/flow.d.ts +6 -6
- package/types/src/libsaml.d.ts +200 -210
- package/types/src/metadata-idp.d.ts +24 -24
- package/types/src/metadata-sp.d.ts +36 -36
- package/types/src/metadata.d.ts +59 -57
- package/types/src/types.d.ts +129 -127
- package/types/src/urn.d.ts +194 -194
- package/types/src/utility.d.ts +134 -134
- package/types/src/validator.d.ts +3 -3
- package/.idea/compiler.xml +0 -6
- package/.idea/deployment.xml +0 -14
- package/.idea/jsLibraryMappings.xml +0 -6
- package/build/.idea/workspace.xml +0 -58
package/build/src/entity-idp.js
CHANGED
|
@@ -1,131 +1,133 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.IdentityProvider = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
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
|
-
* @param
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IdentityProvider = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* @file entity-idp.ts
|
|
9
|
+
* @author tngan
|
|
10
|
+
* @desc Declares the actions taken by identity provider
|
|
11
|
+
*/
|
|
12
|
+
const urn_js_1 = require("./urn.js");
|
|
13
|
+
const binding = urn_js_1.wording.binding;
|
|
14
|
+
const entity_js_1 = __importDefault(require("./entity.js"));
|
|
15
|
+
const libsaml_js_1 = __importDefault(require("./libsaml.js"));
|
|
16
|
+
const urn_js_2 = require("./urn.js");
|
|
17
|
+
const binding_post_js_1 = __importDefault(require("./binding-post.js"));
|
|
18
|
+
const binding_redirect_js_1 = __importDefault(require("./binding-redirect.js"));
|
|
19
|
+
const binding_simplesign_js_1 = __importDefault(require("./binding-simplesign.js"));
|
|
20
|
+
const flow_js_1 = require("./flow.js");
|
|
21
|
+
const utility_js_1 = require("./utility.js");
|
|
22
|
+
/**
|
|
23
|
+
* Identity provider can be configured using either metadata importing or idpSetting
|
|
24
|
+
*/
|
|
25
|
+
function default_1(props) {
|
|
26
|
+
return new IdentityProvider(props);
|
|
27
|
+
}
|
|
28
|
+
exports.default = default_1;
|
|
29
|
+
/**
|
|
30
|
+
* Identity provider can be configured using either metadata importing or idpSetting
|
|
31
|
+
*/
|
|
32
|
+
class IdentityProvider extends entity_js_1.default {
|
|
33
|
+
constructor(idpSetting) {
|
|
34
|
+
const defaultIdpEntitySetting = {
|
|
35
|
+
wantAuthnRequestsSigned: false,
|
|
36
|
+
tagPrefix: {
|
|
37
|
+
encryptedAssertion: 'saml',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const entitySetting = Object.assign(defaultIdpEntitySetting, idpSetting);
|
|
41
|
+
// build attribute part
|
|
42
|
+
if (idpSetting.loginResponseTemplate) {
|
|
43
|
+
if ((0, utility_js_1.isString)(idpSetting.loginResponseTemplate.context) && Array.isArray(idpSetting.loginResponseTemplate.attributes)) {
|
|
44
|
+
let attributeStatementTemplate;
|
|
45
|
+
let attributeTemplate;
|
|
46
|
+
if (!idpSetting.loginResponseTemplate.additionalTemplates || !idpSetting.loginResponseTemplate.additionalTemplates.attributeStatementTemplate) {
|
|
47
|
+
attributeStatementTemplate = libsaml_js_1.default.defaultAttributeStatementTemplate;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
attributeStatementTemplate = idpSetting.loginResponseTemplate.additionalTemplates.attributeStatementTemplate;
|
|
51
|
+
}
|
|
52
|
+
if (!idpSetting.loginResponseTemplate.additionalTemplates || !idpSetting.loginResponseTemplate.additionalTemplates.attributeTemplate) {
|
|
53
|
+
attributeTemplate = libsaml_js_1.default.defaultAttributeTemplate;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
attributeTemplate = idpSetting.loginResponseTemplate.additionalTemplates.attributeTemplate;
|
|
57
|
+
}
|
|
58
|
+
const replacement = {
|
|
59
|
+
AttributeStatement: libsaml_js_1.default.attributeStatementBuilder(idpSetting.loginResponseTemplate.attributes, attributeTemplate, attributeStatementTemplate),
|
|
60
|
+
};
|
|
61
|
+
entitySetting.loginResponseTemplate = {
|
|
62
|
+
...entitySetting.loginResponseTemplate,
|
|
63
|
+
context: libsaml_js_1.default.replaceTagsByValue(entitySetting.loginResponseTemplate.context, replacement),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.warn('Invalid login response template');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
super(entitySetting, 'idp');
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @desc Generates the login response for developers to design their own method
|
|
74
|
+
* @param params
|
|
75
|
+
*/
|
|
76
|
+
async createLoginResponse(params) {
|
|
77
|
+
const bindType = params?.binding ?? 'post';
|
|
78
|
+
const { sp, requestInfo = {}, user = {}, customTagReplacement, encryptThenSign = false, relayState = '' } = params;
|
|
79
|
+
const protocol = urn_js_2.namespace.binding[bindType];
|
|
80
|
+
// can support post, redirect and post simple sign bindings for login response
|
|
81
|
+
let context = null;
|
|
82
|
+
switch (protocol) {
|
|
83
|
+
case urn_js_2.namespace.binding.post:
|
|
84
|
+
context = await binding_post_js_1.default.base64LoginResponse(requestInfo, {
|
|
85
|
+
idp: this,
|
|
86
|
+
sp,
|
|
87
|
+
}, user, customTagReplacement, encryptThenSign);
|
|
88
|
+
break;
|
|
89
|
+
case urn_js_2.namespace.binding.simpleSign:
|
|
90
|
+
context = await binding_simplesign_js_1.default.base64LoginResponse(requestInfo, {
|
|
91
|
+
idp: this, sp,
|
|
92
|
+
}, user, relayState, customTagReplacement);
|
|
93
|
+
break;
|
|
94
|
+
case urn_js_2.namespace.binding.redirect:
|
|
95
|
+
return binding_redirect_js_1.default.loginResponseRedirectURL(requestInfo, {
|
|
96
|
+
idp: this,
|
|
97
|
+
sp,
|
|
98
|
+
}, user, relayState, customTagReplacement);
|
|
99
|
+
default:
|
|
100
|
+
context = await binding_post_js_1.default.base64LoginResponse(requestInfo, {
|
|
101
|
+
idp: this,
|
|
102
|
+
sp,
|
|
103
|
+
}, user, customTagReplacement, encryptThenSign);
|
|
104
|
+
/* throw new Error('ERR_CREATE_RESPONSE_UNDEFINED_BINDING');*/
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
...context,
|
|
108
|
+
relayState,
|
|
109
|
+
entityEndpoint: sp.entityMeta.getAssertionConsumerService(bindType ?? 'post'),
|
|
110
|
+
type: 'SAMLResponse'
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Validation of the parsed URL parameters
|
|
115
|
+
* @param sp ServiceProvider instance
|
|
116
|
+
* @param binding Protocol binding
|
|
117
|
+
* @param req RequesmessageSigningOrderst
|
|
118
|
+
*/
|
|
119
|
+
parseLoginRequest(sp, binding, req) {
|
|
120
|
+
const self = this;
|
|
121
|
+
return (0, flow_js_1.flow)({
|
|
122
|
+
from: sp,
|
|
123
|
+
self: self,
|
|
124
|
+
checkSignature: self.entityMeta.isWantAuthnRequestsSigned(),
|
|
125
|
+
parserType: 'SAMLRequest',
|
|
126
|
+
type: 'login',
|
|
127
|
+
binding: binding,
|
|
128
|
+
request: req
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.IdentityProvider = IdentityProvider;
|
|
131
133
|
//# 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,qCAEkB;AAClB,MAAM,OAAO,GAAG,gBAAO,CAAC,OAAO,CAAA;AAI/B,4DAAuD;AAOvD,8DAAmC;AACnC,qCAAqC;AACrC,wEAA4C;AAC5C,gFAAoD;AACpD,oFAAwD;AACxD,uCAA8C;AAC9C,6CAAwC;AAGxC;;GAEG;AACH,mBAAwB,KAA+B;IACrD,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAFD,4BAEC;AAED;;GAEG;AACH,MAAa,gBAAiB,SAAQ,mBAAM;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;QACvB,IAAI,UAAU,CAAC,qBAAqB,EAAE;YACpC,IAAI,IAAA,qBAAQ,EAAC,UAAU,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE;gBACpH,IAAI,0BAA0B,CAAC;gBAC/B,IAAI,iBAAiB,CAAC;gBACtB,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,mBAAmB,IAAI,CAAC,UAAU,CAAC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C;YACV,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,IAAI;YACV,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,yBAAyB,EAAE;YAC3D,UAAU,EAAE,aAAa;YACzB,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,GAAG;SACb,CAAC,CAAC;IACL,CAAC;CACF;AAhHD,4CAgHC"}
|
package/build/src/entity-sp.js
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ServiceProvider = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @desc Service provider can be configured using either metadata importing or spSetting
|
|
27
|
-
* @param {object} spSettingimport { FlowResult } from '../types/src/flow.d';
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
class ServiceProvider extends entity_js_1.default {
|
|
31
|
-
/**
|
|
32
|
-
* @desc Inherited from Entity
|
|
33
|
-
* @param {object} spSetting setting of service provider
|
|
34
|
-
*/
|
|
35
|
-
constructor(spSetting) {
|
|
36
|
-
const entitySetting = Object.assign({
|
|
37
|
-
authnRequestsSigned: false,
|
|
38
|
-
wantAssertionsSigned: false,
|
|
39
|
-
wantMessageSigned: false,
|
|
40
|
-
}, spSetting);
|
|
41
|
-
super(entitySetting, 'sp');
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* @desc Generates the login request for developers to design their own method
|
|
45
|
-
* @param {IdentityProvider} idp object of identity provider
|
|
46
|
-
* @param {string} binding protocol binding
|
|
47
|
-
* @param {function} customTagReplacement used when developers have their own login response template
|
|
48
|
-
*/
|
|
49
|
-
createLoginRequest(idp, binding = 'redirect', customTagReplacement) {
|
|
50
|
-
const nsBinding = urn_js_1.namespace.binding;
|
|
51
|
-
const protocol = nsBinding[binding];
|
|
52
|
-
if (this.entityMeta.isAuthnRequestSigned() !== idp.entityMeta.isWantAuthnRequestsSigned()) {
|
|
53
|
-
throw new Error('ERR_METADATA_CONFLICT_REQUEST_SIGNED_FLAG');
|
|
54
|
-
}
|
|
55
|
-
let context = null;
|
|
56
|
-
switch (protocol) {
|
|
57
|
-
case nsBinding.redirect:
|
|
58
|
-
return binding_redirect_js_1.default.loginRequestRedirectURL({ idp, sp: this }, customTagReplacement);
|
|
59
|
-
case nsBinding.post:
|
|
60
|
-
context = binding_post_js_1.default.base64LoginRequest("/*[local-name(.)='AuthnRequest']", { idp, sp: this }, customTagReplacement);
|
|
61
|
-
break;
|
|
62
|
-
case nsBinding.simpleSign:
|
|
63
|
-
// Object context = {id, context, signature, sigAlg}
|
|
64
|
-
context = binding_simplesign_js_1.default.base64LoginRequest({ idp, sp: this }, customTagReplacement);
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
// Will support artifact in the next release
|
|
68
|
-
throw new Error('ERR_SP_LOGIN_REQUEST_UNDEFINED_BINDING');
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
...context,
|
|
72
|
-
relayState: this.entitySetting.relayState,
|
|
73
|
-
entityEndpoint: idp.entityMeta.getSingleSignOnService(binding),
|
|
74
|
-
type: 'SAMLRequest',
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* @desc Validation of the parsed the URL parameters
|
|
79
|
-
* @param {IdentityProvider} idp object of identity provider
|
|
80
|
-
* @param {string} binding protocol binding
|
|
81
|
-
* @param {request} req request
|
|
82
|
-
*/
|
|
83
|
-
parseLoginResponse(idp, binding, request) {
|
|
84
|
-
const self = this;
|
|
85
|
-
return (0, flow_js_1.flow)({
|
|
86
|
-
from: idp,
|
|
87
|
-
self: self,
|
|
88
|
-
checkSignature: true,
|
|
89
|
-
parserType: 'SAMLResponse',
|
|
90
|
-
type: 'login',
|
|
91
|
-
binding: binding,
|
|
92
|
-
request: request
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.ServiceProvider = ServiceProvider;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ServiceProvider = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* @file entity-sp.ts
|
|
9
|
+
* @author tngan
|
|
10
|
+
* @desc Declares the actions taken by service provider
|
|
11
|
+
*/
|
|
12
|
+
const entity_js_1 = __importDefault(require("./entity.js"));
|
|
13
|
+
const urn_js_1 = require("./urn.js");
|
|
14
|
+
const binding_redirect_js_1 = __importDefault(require("./binding-redirect.js"));
|
|
15
|
+
const binding_post_js_1 = __importDefault(require("./binding-post.js"));
|
|
16
|
+
const binding_simplesign_js_1 = __importDefault(require("./binding-simplesign.js"));
|
|
17
|
+
const flow_js_1 = require("./flow.js");
|
|
18
|
+
/*
|
|
19
|
+
* @desc interface function
|
|
20
|
+
*/
|
|
21
|
+
function default_1(props) {
|
|
22
|
+
return new ServiceProvider(props);
|
|
23
|
+
}
|
|
24
|
+
exports.default = default_1;
|
|
25
|
+
/**
|
|
26
|
+
* @desc Service provider can be configured using either metadata importing or spSetting
|
|
27
|
+
* @param {object} spSettingimport { FlowResult } from '../types/src/flow.d';
|
|
28
|
+
|
|
29
|
+
*/
|
|
30
|
+
class ServiceProvider extends entity_js_1.default {
|
|
31
|
+
/**
|
|
32
|
+
* @desc Inherited from Entity
|
|
33
|
+
* @param {object} spSetting setting of service provider
|
|
34
|
+
*/
|
|
35
|
+
constructor(spSetting) {
|
|
36
|
+
const entitySetting = Object.assign({
|
|
37
|
+
authnRequestsSigned: false,
|
|
38
|
+
wantAssertionsSigned: false,
|
|
39
|
+
wantMessageSigned: false,
|
|
40
|
+
}, spSetting);
|
|
41
|
+
super(entitySetting, 'sp');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @desc Generates the login request for developers to design their own method
|
|
45
|
+
* @param {IdentityProvider} idp object of identity provider
|
|
46
|
+
* @param {string} binding protocol binding
|
|
47
|
+
* @param {function} customTagReplacement used when developers have their own login response template
|
|
48
|
+
*/
|
|
49
|
+
createLoginRequest(idp, binding = 'redirect', customTagReplacement) {
|
|
50
|
+
const nsBinding = urn_js_1.namespace.binding;
|
|
51
|
+
const protocol = nsBinding[binding];
|
|
52
|
+
if (this.entityMeta.isAuthnRequestSigned() !== idp.entityMeta.isWantAuthnRequestsSigned()) {
|
|
53
|
+
throw new Error('ERR_METADATA_CONFLICT_REQUEST_SIGNED_FLAG');
|
|
54
|
+
}
|
|
55
|
+
let context = null;
|
|
56
|
+
switch (protocol) {
|
|
57
|
+
case nsBinding.redirect:
|
|
58
|
+
return binding_redirect_js_1.default.loginRequestRedirectURL({ idp, sp: this }, customTagReplacement);
|
|
59
|
+
case nsBinding.post:
|
|
60
|
+
context = binding_post_js_1.default.base64LoginRequest("/*[local-name(.)='AuthnRequest']", { idp, sp: this }, customTagReplacement);
|
|
61
|
+
break;
|
|
62
|
+
case nsBinding.simpleSign:
|
|
63
|
+
// Object context = {id, context, signature, sigAlg}
|
|
64
|
+
context = binding_simplesign_js_1.default.base64LoginRequest({ idp, sp: this }, customTagReplacement);
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
// Will support artifact in the next release
|
|
68
|
+
throw new Error('ERR_SP_LOGIN_REQUEST_UNDEFINED_BINDING');
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
...context,
|
|
72
|
+
relayState: this.entitySetting.relayState,
|
|
73
|
+
entityEndpoint: idp.entityMeta.getSingleSignOnService(binding),
|
|
74
|
+
type: 'SAMLRequest',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @desc Validation of the parsed the URL parameters
|
|
79
|
+
* @param {IdentityProvider} idp object of identity provider
|
|
80
|
+
* @param {string} binding protocol binding
|
|
81
|
+
* @param {request} req request
|
|
82
|
+
*/
|
|
83
|
+
parseLoginResponse(idp, binding, request) {
|
|
84
|
+
const self = this;
|
|
85
|
+
return (0, flow_js_1.flow)({
|
|
86
|
+
from: idp,
|
|
87
|
+
self: self,
|
|
88
|
+
checkSignature: true,
|
|
89
|
+
parserType: 'SAMLResponse',
|
|
90
|
+
type: 'login',
|
|
91
|
+
binding: binding,
|
|
92
|
+
request: request
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.ServiceProvider = ServiceProvider;
|
|
97
97
|
//# 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,4DAKqB;AAMrB,qCAAqC;AACrC,gFAAoD;AACpD,wEAA4C;AAC5C,oFAAwD;AACxD,uCAA8C;AAE9C;;GAEG;AACH,mBAAwB,KAA8B;IACpD,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAFD,4BAEC;AAED;;;;EAIE;AACF,MAAa,eAAgB,SAAQ,mBAAM;IAGzC;;;MAGE;IACF,YAAY,SAAkC;QAC5C,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;YAClC,mBAAmB,EAAE,KAAK;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