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/metadata-sp.js
CHANGED
|
@@ -1,232 +1,232 @@
|
|
|
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.SpMetadata = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @desc SP Metadata is for creating Service Provider, provides a set of API to manage the actions in SP.
|
|
26
|
-
*/
|
|
27
|
-
class SpMetadata extends metadata_js_1.default {
|
|
28
|
-
/**
|
|
29
|
-
* @param {object/string} meta (either xml string or configuration in object)
|
|
30
|
-
* @return {object} prototypes including public functions
|
|
31
|
-
*/
|
|
32
|
-
constructor(meta) {
|
|
33
|
-
const isFile = (0, utility_js_1.isString)(meta) || meta instanceof Buffer;
|
|
34
|
-
// use object configuration instead of importing metadata file directly
|
|
35
|
-
if (!isFile) {
|
|
36
|
-
const { elementsOrder = urn_js_1.elementsOrder.default, entityID, signingCert, encryptCert, authnRequestsSigned = false, wantAssertionsSigned = false, wantMessageSigned = false, signatureConfig, nameIDFormat = [], singleLogoutService = [], assertionConsumerService = [], attributeConsumingService = [] } = meta;
|
|
37
|
-
const descriptors = {
|
|
38
|
-
KeyDescriptor: [],
|
|
39
|
-
NameIDFormat: [],
|
|
40
|
-
SingleLogoutService: [],
|
|
41
|
-
AssertionConsumerService: [],
|
|
42
|
-
AttributeConsumingService: [],
|
|
43
|
-
};
|
|
44
|
-
const SPSSODescriptor = [{
|
|
45
|
-
_attr: {
|
|
46
|
-
AuthnRequestsSigned: String(authnRequestsSigned),
|
|
47
|
-
WantAssertionsSigned: String(wantAssertionsSigned),
|
|
48
|
-
protocolSupportEnumeration: urn_js_1.namespace.names.protocol,
|
|
49
|
-
},
|
|
50
|
-
}];
|
|
51
|
-
if (wantMessageSigned && signatureConfig === undefined) {
|
|
52
|
-
console.warn('Construct service provider - missing signatureConfig');
|
|
53
|
-
}
|
|
54
|
-
for (const cert of (0, utility_js_1.castArrayOpt)(signingCert)) {
|
|
55
|
-
descriptors.KeyDescriptor.push(libsaml_js_1.default.createKeySection('signing', cert).KeyDescriptor);
|
|
56
|
-
}
|
|
57
|
-
for (const cert of (0, utility_js_1.castArrayOpt)(encryptCert)) {
|
|
58
|
-
descriptors.KeyDescriptor.push(libsaml_js_1.default.createKeySection('encryption', cert).KeyDescriptor);
|
|
59
|
-
}
|
|
60
|
-
if ((0, utility_js_1.isNonEmptyArray)(nameIDFormat)) {
|
|
61
|
-
nameIDFormat.forEach(f => descriptors.NameIDFormat.push(f));
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
// default value
|
|
65
|
-
descriptors.NameIDFormat.push(urn_js_1.namespace.format.emailAddress);
|
|
66
|
-
}
|
|
67
|
-
if ((0, utility_js_1.isNonEmptyArray)(singleLogoutService)) {
|
|
68
|
-
singleLogoutService.forEach(a => {
|
|
69
|
-
const attr = {
|
|
70
|
-
Binding: a.Binding,
|
|
71
|
-
Location: a.Location,
|
|
72
|
-
};
|
|
73
|
-
if (a.isDefault) {
|
|
74
|
-
attr.isDefault = true;
|
|
75
|
-
}
|
|
76
|
-
descriptors.SingleLogoutService.push([{ _attr: attr }]);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
if ((0, utility_js_1.isNonEmptyArray)(assertionConsumerService)) {
|
|
80
|
-
let indexCount = 0;
|
|
81
|
-
assertionConsumerService.forEach(a => {
|
|
82
|
-
const attr = {
|
|
83
|
-
index: String(indexCount++),
|
|
84
|
-
Binding: a.Binding,
|
|
85
|
-
Location: a.Location,
|
|
86
|
-
};
|
|
87
|
-
if (a.isDefault) {
|
|
88
|
-
attr.isDefault = true;
|
|
89
|
-
}
|
|
90
|
-
descriptors.AssertionConsumerService.push([{ _attr: attr }]);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
console.warn('Missing endpoint of AssertionConsumerService');
|
|
95
|
-
}
|
|
96
|
-
// 修改原有处理逻辑
|
|
97
|
-
if ((0, utility_js_1.isNonEmptyArray)(attributeConsumingService)) {
|
|
98
|
-
attributeConsumingService.forEach((service, index) => {
|
|
99
|
-
// 1. 构建AttributeConsumingService主元素
|
|
100
|
-
let indexCount = 0;
|
|
101
|
-
let attrConsumingService = [{
|
|
102
|
-
_attr: {
|
|
103
|
-
index: String(index + 1),
|
|
104
|
-
}
|
|
105
|
-
}];
|
|
106
|
-
if (service.isDefault) {
|
|
107
|
-
attrConsumingService[0]._attr.isDefault = true;
|
|
108
|
-
}
|
|
109
|
-
// 2. 添加ServiceName子元素
|
|
110
|
-
if ((0, utility_js_1.isNonEmptyArray)(service.serviceName)) {
|
|
111
|
-
service.serviceName.forEach(({ value, lang }) => {
|
|
112
|
-
attrConsumingService.push({
|
|
113
|
-
ServiceName: [
|
|
114
|
-
{
|
|
115
|
-
_attr: lang ? { 'xml:lang': lang } : {},
|
|
116
|
-
},
|
|
117
|
-
value
|
|
118
|
-
]
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if ((0, utility_js_1.isNonEmptyArray)(service.serviceDescription)) {
|
|
123
|
-
service.serviceDescription.forEach(({ value, lang }) => {
|
|
124
|
-
attrConsumingService.push({
|
|
125
|
-
ServiceDescription: [
|
|
126
|
-
{
|
|
127
|
-
_attr: lang ? { 'xml:lang': lang } : {},
|
|
128
|
-
},
|
|
129
|
-
value
|
|
130
|
-
]
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
// 3. 添加RequestedAttribute子元素
|
|
135
|
-
if ((0, utility_js_1.isNonEmptyArray)(service.requestedAttributes)) {
|
|
136
|
-
service.requestedAttributes.forEach(attr => {
|
|
137
|
-
const requestedAttr = {
|
|
138
|
-
_attr: {
|
|
139
|
-
...(attr.isRequired && { isRequired: String(attr.isRequired) }),
|
|
140
|
-
Name: attr.name,
|
|
141
|
-
...(attr.friendlyName && { FriendlyName: attr.friendlyName }),
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
/* // 处理属性值白名单
|
|
145
|
-
if (isNonEmptyArray(attr.attributeValue)) {
|
|
146
|
-
requestedAttr[namespace.tags.attributeValue] = attr.attributeValue.map(val => ({
|
|
147
|
-
_: val
|
|
148
|
-
}));
|
|
149
|
-
}*/
|
|
150
|
-
attrConsumingService.push({
|
|
151
|
-
RequestedAttribute: [requestedAttr]
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
// 4. 将完整元素加入描述符
|
|
156
|
-
descriptors.AttributeConsumingService.push(attrConsumingService);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
// handle element order
|
|
160
|
-
const existedElements = elementsOrder.filter(name => (0, utility_js_1.isNonEmptyArray)(descriptors[name]));
|
|
161
|
-
existedElements.forEach(name => {
|
|
162
|
-
descriptors[name].forEach(e => SPSSODescriptor.push({ [name]: e }));
|
|
163
|
-
});
|
|
164
|
-
// Re-assign the meta reference as a XML string|Buffer for use with the parent constructor
|
|
165
|
-
meta = (0, xml_1.default)([{
|
|
166
|
-
EntityDescriptor: [{
|
|
167
|
-
_attr: {
|
|
168
|
-
entityID,
|
|
169
|
-
'xmlns': urn_js_1.namespace.names.metadata,
|
|
170
|
-
'xmlns:assertion': urn_js_1.namespace.names.assertion,
|
|
171
|
-
'xmlns:ds': 'http://www.w3.org/2000/09/xmldsig#',
|
|
172
|
-
},
|
|
173
|
-
}, { SPSSODescriptor }],
|
|
174
|
-
}]);
|
|
175
|
-
}
|
|
176
|
-
// Use the re-assigned meta object reference here
|
|
177
|
-
super(meta, [
|
|
178
|
-
{
|
|
179
|
-
key: 'spSSODescriptor',
|
|
180
|
-
localPath: ['EntityDescriptor', 'SPSSODescriptor'],
|
|
181
|
-
attributes: ['WantAssertionsSigned', 'AuthnRequestsSigned'],
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
key: 'assertionConsumerService',
|
|
185
|
-
localPath: ['EntityDescriptor', 'SPSSODescriptor', 'AssertionConsumerService'],
|
|
186
|
-
attributes: ['Binding', 'Location', 'isDefault', 'index'],
|
|
187
|
-
}
|
|
188
|
-
]);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* @desc Get the preference whether it wants a signed assertion response
|
|
192
|
-
* @return {boolean} Wantassertionssigned
|
|
193
|
-
*/
|
|
194
|
-
isWantAssertionsSigned() {
|
|
195
|
-
return this.meta.spSSODescriptor.wantAssertionsSigned === 'true';
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* @desc Get the preference whether it signs request
|
|
199
|
-
* @return {boolean} Authnrequestssigned
|
|
200
|
-
*/
|
|
201
|
-
isAuthnRequestSigned() {
|
|
202
|
-
return this.meta.spSSODescriptor.authnRequestsSigned === 'true';
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* @desc Get the entity endpoint for assertion consumer service
|
|
206
|
-
* @param {string} binding protocol binding (e.g. redirect, post)
|
|
207
|
-
* @return {string/[string]} URL of endpoint(s)
|
|
208
|
-
*/
|
|
209
|
-
getAssertionConsumerService(binding) {
|
|
210
|
-
if ((0, utility_js_1.isString)(binding)) {
|
|
211
|
-
let location;
|
|
212
|
-
const bindName = urn_js_1.namespace.binding[binding];
|
|
213
|
-
if ((0, utility_js_1.isNonEmptyArray)(this.meta.assertionConsumerService)) {
|
|
214
|
-
this.meta.assertionConsumerService.forEach(obj => {
|
|
215
|
-
if (obj.binding === bindName) {
|
|
216
|
-
location = obj.location;
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
if (this.meta.assertionConsumerService.binding === bindName) {
|
|
223
|
-
location = this.meta.assertionConsumerService.location;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return location;
|
|
227
|
-
}
|
|
228
|
-
return this.meta.assertionConsumerService;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
exports.SpMetadata = SpMetadata;
|
|
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.SpMetadata = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* @file metadata-sp.ts
|
|
9
|
+
* @author tngan
|
|
10
|
+
* @desc Metadata of service provider
|
|
11
|
+
*/
|
|
12
|
+
const metadata_js_1 = __importDefault(require("./metadata.js"));
|
|
13
|
+
const urn_js_1 = require("./urn.js");
|
|
14
|
+
const libsaml_js_1 = __importDefault(require("./libsaml.js"));
|
|
15
|
+
const utility_js_1 = require("./utility.js");
|
|
16
|
+
const xml_1 = __importDefault(require("xml"));
|
|
17
|
+
/*
|
|
18
|
+
* @desc interface function
|
|
19
|
+
*/
|
|
20
|
+
function default_1(meta) {
|
|
21
|
+
return new SpMetadata(meta);
|
|
22
|
+
}
|
|
23
|
+
exports.default = default_1;
|
|
24
|
+
/**
|
|
25
|
+
* @desc SP Metadata is for creating Service Provider, provides a set of API to manage the actions in SP.
|
|
26
|
+
*/
|
|
27
|
+
class SpMetadata extends metadata_js_1.default {
|
|
28
|
+
/**
|
|
29
|
+
* @param {object/string} meta (either xml string or configuration in object)
|
|
30
|
+
* @return {object} prototypes including public functions
|
|
31
|
+
*/
|
|
32
|
+
constructor(meta) {
|
|
33
|
+
const isFile = (0, utility_js_1.isString)(meta) || meta instanceof Buffer;
|
|
34
|
+
// use object configuration instead of importing metadata file directly
|
|
35
|
+
if (!isFile) {
|
|
36
|
+
const { elementsOrder = urn_js_1.elementsOrder.default, entityID, signingCert, encryptCert, authnRequestsSigned = false, wantAssertionsSigned = false, wantMessageSigned = false, signatureConfig, nameIDFormat = [], singleLogoutService = [], assertionConsumerService = [], attributeConsumingService = [] } = meta;
|
|
37
|
+
const descriptors = {
|
|
38
|
+
KeyDescriptor: [],
|
|
39
|
+
NameIDFormat: [],
|
|
40
|
+
SingleLogoutService: [],
|
|
41
|
+
AssertionConsumerService: [],
|
|
42
|
+
AttributeConsumingService: [],
|
|
43
|
+
};
|
|
44
|
+
const SPSSODescriptor = [{
|
|
45
|
+
_attr: {
|
|
46
|
+
AuthnRequestsSigned: String(authnRequestsSigned),
|
|
47
|
+
WantAssertionsSigned: String(wantAssertionsSigned),
|
|
48
|
+
protocolSupportEnumeration: urn_js_1.namespace.names.protocol,
|
|
49
|
+
},
|
|
50
|
+
}];
|
|
51
|
+
if (wantMessageSigned && signatureConfig === undefined) {
|
|
52
|
+
console.warn('Construct service provider - missing signatureConfig');
|
|
53
|
+
}
|
|
54
|
+
for (const cert of (0, utility_js_1.castArrayOpt)(signingCert)) {
|
|
55
|
+
descriptors.KeyDescriptor.push(libsaml_js_1.default.createKeySection('signing', cert).KeyDescriptor);
|
|
56
|
+
}
|
|
57
|
+
for (const cert of (0, utility_js_1.castArrayOpt)(encryptCert)) {
|
|
58
|
+
descriptors.KeyDescriptor.push(libsaml_js_1.default.createKeySection('encryption', cert).KeyDescriptor);
|
|
59
|
+
}
|
|
60
|
+
if ((0, utility_js_1.isNonEmptyArray)(nameIDFormat)) {
|
|
61
|
+
nameIDFormat.forEach(f => descriptors.NameIDFormat.push(f));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// default value
|
|
65
|
+
descriptors.NameIDFormat.push(urn_js_1.namespace.format.emailAddress);
|
|
66
|
+
}
|
|
67
|
+
if ((0, utility_js_1.isNonEmptyArray)(singleLogoutService)) {
|
|
68
|
+
singleLogoutService.forEach(a => {
|
|
69
|
+
const attr = {
|
|
70
|
+
Binding: a.Binding,
|
|
71
|
+
Location: a.Location,
|
|
72
|
+
};
|
|
73
|
+
if (a.isDefault) {
|
|
74
|
+
attr.isDefault = true;
|
|
75
|
+
}
|
|
76
|
+
descriptors.SingleLogoutService.push([{ _attr: attr }]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if ((0, utility_js_1.isNonEmptyArray)(assertionConsumerService)) {
|
|
80
|
+
let indexCount = 0;
|
|
81
|
+
assertionConsumerService.forEach(a => {
|
|
82
|
+
const attr = {
|
|
83
|
+
index: String(indexCount++),
|
|
84
|
+
Binding: a.Binding,
|
|
85
|
+
Location: a.Location,
|
|
86
|
+
};
|
|
87
|
+
if (a.isDefault) {
|
|
88
|
+
attr.isDefault = true;
|
|
89
|
+
}
|
|
90
|
+
descriptors.AssertionConsumerService.push([{ _attr: attr }]);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
console.warn('Missing endpoint of AssertionConsumerService');
|
|
95
|
+
}
|
|
96
|
+
// 修改原有处理逻辑
|
|
97
|
+
if ((0, utility_js_1.isNonEmptyArray)(attributeConsumingService)) {
|
|
98
|
+
attributeConsumingService.forEach((service, index) => {
|
|
99
|
+
// 1. 构建AttributeConsumingService主元素
|
|
100
|
+
let indexCount = 0;
|
|
101
|
+
let attrConsumingService = [{
|
|
102
|
+
_attr: {
|
|
103
|
+
index: String(index + 1),
|
|
104
|
+
}
|
|
105
|
+
}];
|
|
106
|
+
if (service.isDefault) {
|
|
107
|
+
attrConsumingService[0]._attr.isDefault = true;
|
|
108
|
+
}
|
|
109
|
+
// 2. 添加ServiceName子元素
|
|
110
|
+
if ((0, utility_js_1.isNonEmptyArray)(service.serviceName)) {
|
|
111
|
+
service.serviceName.forEach(({ value, lang }) => {
|
|
112
|
+
attrConsumingService.push({
|
|
113
|
+
ServiceName: [
|
|
114
|
+
{
|
|
115
|
+
_attr: lang ? { 'xml:lang': lang } : {},
|
|
116
|
+
},
|
|
117
|
+
value
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if ((0, utility_js_1.isNonEmptyArray)(service.serviceDescription)) {
|
|
123
|
+
service.serviceDescription.forEach(({ value, lang }) => {
|
|
124
|
+
attrConsumingService.push({
|
|
125
|
+
ServiceDescription: [
|
|
126
|
+
{
|
|
127
|
+
_attr: lang ? { 'xml:lang': lang } : {},
|
|
128
|
+
},
|
|
129
|
+
value
|
|
130
|
+
]
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// 3. 添加RequestedAttribute子元素
|
|
135
|
+
if ((0, utility_js_1.isNonEmptyArray)(service.requestedAttributes)) {
|
|
136
|
+
service.requestedAttributes.forEach(attr => {
|
|
137
|
+
const requestedAttr = {
|
|
138
|
+
_attr: {
|
|
139
|
+
...(attr.isRequired && { isRequired: String(attr.isRequired) }),
|
|
140
|
+
Name: attr.name,
|
|
141
|
+
...(attr.friendlyName && { FriendlyName: attr.friendlyName }),
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
/* // 处理属性值白名单
|
|
145
|
+
if (isNonEmptyArray(attr.attributeValue)) {
|
|
146
|
+
requestedAttr[namespace.tags.attributeValue] = attr.attributeValue.map(val => ({
|
|
147
|
+
_: val
|
|
148
|
+
}));
|
|
149
|
+
}*/
|
|
150
|
+
attrConsumingService.push({
|
|
151
|
+
RequestedAttribute: [requestedAttr]
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// 4. 将完整元素加入描述符
|
|
156
|
+
descriptors.AttributeConsumingService.push(attrConsumingService);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
// handle element order
|
|
160
|
+
const existedElements = elementsOrder.filter(name => (0, utility_js_1.isNonEmptyArray)(descriptors[name]));
|
|
161
|
+
existedElements.forEach(name => {
|
|
162
|
+
descriptors[name].forEach(e => SPSSODescriptor.push({ [name]: e }));
|
|
163
|
+
});
|
|
164
|
+
// Re-assign the meta reference as a XML string|Buffer for use with the parent constructor
|
|
165
|
+
meta = (0, xml_1.default)([{
|
|
166
|
+
EntityDescriptor: [{
|
|
167
|
+
_attr: {
|
|
168
|
+
entityID,
|
|
169
|
+
'xmlns': urn_js_1.namespace.names.metadata,
|
|
170
|
+
'xmlns:assertion': urn_js_1.namespace.names.assertion,
|
|
171
|
+
'xmlns:ds': 'http://www.w3.org/2000/09/xmldsig#',
|
|
172
|
+
},
|
|
173
|
+
}, { SPSSODescriptor }],
|
|
174
|
+
}]);
|
|
175
|
+
}
|
|
176
|
+
// Use the re-assigned meta object reference here
|
|
177
|
+
super(meta, [
|
|
178
|
+
{
|
|
179
|
+
key: 'spSSODescriptor',
|
|
180
|
+
localPath: ['EntityDescriptor', 'SPSSODescriptor'],
|
|
181
|
+
attributes: ['WantAssertionsSigned', 'AuthnRequestsSigned'],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
key: 'assertionConsumerService',
|
|
185
|
+
localPath: ['EntityDescriptor', 'SPSSODescriptor', 'AssertionConsumerService'],
|
|
186
|
+
attributes: ['Binding', 'Location', 'isDefault', 'index'],
|
|
187
|
+
}
|
|
188
|
+
]);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* @desc Get the preference whether it wants a signed assertion response
|
|
192
|
+
* @return {boolean} Wantassertionssigned
|
|
193
|
+
*/
|
|
194
|
+
isWantAssertionsSigned() {
|
|
195
|
+
return this.meta.spSSODescriptor.wantAssertionsSigned === 'true';
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @desc Get the preference whether it signs request
|
|
199
|
+
* @return {boolean} Authnrequestssigned
|
|
200
|
+
*/
|
|
201
|
+
isAuthnRequestSigned() {
|
|
202
|
+
return this.meta.spSSODescriptor.authnRequestsSigned === 'true';
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* @desc Get the entity endpoint for assertion consumer service
|
|
206
|
+
* @param {string} binding protocol binding (e.g. redirect, post)
|
|
207
|
+
* @return {string/[string]} URL of endpoint(s)
|
|
208
|
+
*/
|
|
209
|
+
getAssertionConsumerService(binding) {
|
|
210
|
+
if ((0, utility_js_1.isString)(binding)) {
|
|
211
|
+
let location;
|
|
212
|
+
const bindName = urn_js_1.namespace.binding[binding];
|
|
213
|
+
if ((0, utility_js_1.isNonEmptyArray)(this.meta.assertionConsumerService)) {
|
|
214
|
+
this.meta.assertionConsumerService.forEach(obj => {
|
|
215
|
+
if (obj.binding === bindName) {
|
|
216
|
+
location = obj.location;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
if (this.meta.assertionConsumerService.binding === bindName) {
|
|
223
|
+
location = this.meta.assertionConsumerService.location;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return location;
|
|
227
|
+
}
|
|
228
|
+
return this.meta.assertionConsumerService;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
exports.SpMetadata = SpMetadata;
|
|
232
232
|
//# sourceMappingURL=metadata-sp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-sp.js","sourceRoot":"","sources":["../../src/metadata-sp.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"metadata-sp.js","sourceRoot":"","sources":["../../src/metadata-sp.ts"],"names":[],"mappings":";;;;;;AAAA;;;;EAIE;AACF,gEAA4D;AAE5D,qCAA6D;AAC7D,8DAAmC;AACnC,6CAAuE;AACvE,8CAAsB;AAetB;;GAEG;AACH,mBAAwB,IAA2B;IACjD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAFD,4BAEC;AAED;;EAEE;AACF,MAAa,UAAW,SAAQ,qBAAQ;IAEtC;;;MAGE;IACF,YAAY,IAA2B;QAErC,MAAM,MAAM,GAAG,IAAA,qBAAQ,EAAC,IAAI,CAAC,IAAI,IAAI,YAAY,MAAM,CAAC;QAExD,uEAAuE;QACvE,IAAI,CAAC,MAAM,EAAE;YAEX,MAAM,EACJ,aAAa,GAAG,sBAAK,CAAC,OAAO,EAC7B,QAAQ,EACR,WAAW,EACX,WAAW,EACX,mBAAmB,GAAG,KAAK,EAC3B,oBAAoB,GAAG,KAAK,EAC5B,iBAAiB,GAAG,KAAK,EACzB,eAAe,EACf,YAAY,GAAG,EAAE,EACjB,mBAAmB,GAAG,EAAE,EACxB,wBAAwB,GAAG,EAAE,EAC7B,yBAAyB,GAAG,EAAE,EAC/B,GAAG,IAAyB,CAAC;YAE9B,MAAM,WAAW,GAAgB;gBAC/B,aAAa,EAAE,EAAE;gBACjB,YAAY,EAAE,EAAE;gBAChB,mBAAmB,EAAE,EAAE;gBACvB,wBAAwB,EAAE,EAAE;gBAC5B,yBAAyB,EAAE,EAAE;aAC9B,CAAC;YAEF,MAAM,eAAe,GAAU,CAAC;oBAC9B,KAAK,EAAE;wBACL,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,CAAC;wBAChD,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,CAAC;wBAClD,0BAA0B,EAAE,kBAAS,CAAC,KAAK,CAAC,QAAQ;qBACrD;i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