openid 2.0.12 → 2.0.13
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.
- package/.gitattributes +5 -5
- package/LICENSE +19 -19
- package/README.md +137 -137
- package/SECURITY.md +5 -5
- package/http.js +63 -58
- package/lib/xrds.js +102 -102
- package/openid.js +1373 -1610
- package/package.json +47 -45
- package/sample.js +118 -129
- package/test/cancelled_authentication.test.js +37 -38
- package/test/extensions.test.js +65 -66
- package/test/faulty_assertions.test.js +51 -51
- package/test/full_authentication_tests.test.js +89 -0
- package/test/integration_tests.test.js +161 -166
- package/test/xrds.test.js +42 -42
- package/test/xrds_discovery.test.js +60 -59
- package/expressjs_sample/authentication_controller.js +0 -43
- package/expressjs_sample/login.jade +0 -11
package/package.json
CHANGED
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "openid",
|
|
3
|
-
"description": "OpenID 1.1/2.0 library for Node.js",
|
|
4
|
-
"keywords": [
|
|
5
|
-
"openid",
|
|
6
|
-
"auth",
|
|
7
|
-
"authentication",
|
|
8
|
-
"identity",
|
|
9
|
-
"identifier",
|
|
10
|
-
"relying",
|
|
11
|
-
"party",
|
|
12
|
-
"relying party",
|
|
13
|
-
"1.1",
|
|
14
|
-
"2.0",
|
|
15
|
-
"library"
|
|
16
|
-
],
|
|
17
|
-
"author": {
|
|
18
|
-
"name": "Håvard Stranden",
|
|
19
|
-
"email": "havard.stranden@gmail.com"
|
|
20
|
-
},
|
|
21
|
-
"version": "2.0.
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "http://github.com/havard/node-openid.git"
|
|
25
|
-
},
|
|
26
|
-
"bugs": "http://github.com/havard/node-openid/issues",
|
|
27
|
-
"license": "MIT",
|
|
28
|
-
"directories": {
|
|
29
|
-
"lib": "./lib"
|
|
30
|
-
},
|
|
31
|
-
"main": "./openid.js",
|
|
32
|
-
"scripts": {
|
|
33
|
-
"test": "jest"
|
|
34
|
-
},
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">= 0.6.0"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "openid",
|
|
3
|
+
"description": "OpenID 1.1/2.0 library for Node.js",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"openid",
|
|
6
|
+
"auth",
|
|
7
|
+
"authentication",
|
|
8
|
+
"identity",
|
|
9
|
+
"identifier",
|
|
10
|
+
"relying",
|
|
11
|
+
"party",
|
|
12
|
+
"relying party",
|
|
13
|
+
"1.1",
|
|
14
|
+
"2.0",
|
|
15
|
+
"library"
|
|
16
|
+
],
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Håvard Stranden",
|
|
19
|
+
"email": "havard.stranden@gmail.com"
|
|
20
|
+
},
|
|
21
|
+
"version": "2.0.13",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "http://github.com/havard/node-openid.git"
|
|
25
|
+
},
|
|
26
|
+
"bugs": "http://github.com/havard/node-openid/issues",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"directories": {
|
|
29
|
+
"lib": "./lib"
|
|
30
|
+
},
|
|
31
|
+
"main": "./openid.js",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "jest"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">= 0.6.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"axios-cookiejar-support": "^5.0.5",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"tough-cookie": "^5.1.2"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"axios": "^1.6.0",
|
|
45
|
+
"qs": "^6.5.2"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/sample.js
CHANGED
|
@@ -1,129 +1,118 @@
|
|
|
1
|
-
/* A simple sample demonstrating OpenID for node.js
|
|
2
|
-
*
|
|
3
|
-
* http://ox.no/software/node-openid
|
|
4
|
-
* http://github.com/havard/node-openid
|
|
5
|
-
*
|
|
6
|
-
* Copyright (C) 2010 by Håvard Stranden
|
|
7
|
-
*
|
|
8
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
* in the Software without restriction, including without limitation the rights
|
|
11
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
* furnished to do so, subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in
|
|
16
|
-
* all copies or substantial portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
var openid = require('./openid');
|
|
27
|
-
var url = require('url');
|
|
28
|
-
var querystring = require('querystring');
|
|
29
|
-
|
|
30
|
-
var extensions = [new openid.UserInterface(),
|
|
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
|
-
var relyingParty = new openid.RelyingParty(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var server = require('http').createServer(
|
|
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
|
-
// Deliver an OpenID form on all other URLs
|
|
120
|
-
res.writeHead(200, { 'Content-Type' : 'text/html; charset=utf-8' });
|
|
121
|
-
res.end('<!DOCTYPE html><html><body>'
|
|
122
|
-
+ '<form method="get" action="/authenticate">'
|
|
123
|
-
+ '<p>Login using OpenID</p>'
|
|
124
|
-
+ '<input name="openid_identifier" />'
|
|
125
|
-
+ '<input type="submit" value="Login" />'
|
|
126
|
-
+ '</form></body></html>');
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
server.listen(80);
|
|
1
|
+
/* A simple sample demonstrating OpenID for node.js
|
|
2
|
+
*
|
|
3
|
+
* http://ox.no/software/node-openid
|
|
4
|
+
* http://github.com/havard/node-openid
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2010 by Håvard Stranden
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in
|
|
16
|
+
* all copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
var openid = require('./openid');
|
|
27
|
+
var url = require('url');
|
|
28
|
+
var querystring = require('querystring');
|
|
29
|
+
|
|
30
|
+
var extensions = [new openid.UserInterface(),
|
|
31
|
+
new openid.SimpleRegistration(
|
|
32
|
+
{
|
|
33
|
+
"nickname": true,
|
|
34
|
+
"email": true,
|
|
35
|
+
"fullname": true,
|
|
36
|
+
"dob": true,
|
|
37
|
+
"gender": true,
|
|
38
|
+
"postcode": true,
|
|
39
|
+
"country": true,
|
|
40
|
+
"language": true,
|
|
41
|
+
"timezone": true
|
|
42
|
+
}),
|
|
43
|
+
new openid.AttributeExchange(
|
|
44
|
+
{
|
|
45
|
+
"http://axschema.org/contact/email": "required",
|
|
46
|
+
"http://axschema.org/namePerson/friendly": "required",
|
|
47
|
+
"http://axschema.org/namePerson": "required"
|
|
48
|
+
}),
|
|
49
|
+
new openid.PAPE(
|
|
50
|
+
{
|
|
51
|
+
"max_auth_age": 24 * 60 * 60, // one day
|
|
52
|
+
"preferred_auth_policies": "none" //no auth method preferred.
|
|
53
|
+
})];
|
|
54
|
+
|
|
55
|
+
var relyingParty = new openid.RelyingParty(
|
|
56
|
+
'http://example.com/verify', // Verification URL (yours)
|
|
57
|
+
null, // Realm (optional, specifies realm for OpenID authentication)
|
|
58
|
+
false, // Use stateless verification
|
|
59
|
+
false, // Strict mode
|
|
60
|
+
extensions); // List of extensions to enable and include
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
var server = require('http').createServer(
|
|
64
|
+
function (req, res) {
|
|
65
|
+
var parsedUrl = url.parse(req.url);
|
|
66
|
+
if (parsedUrl.pathname == '/authenticate') {
|
|
67
|
+
// User supplied identifier
|
|
68
|
+
var query = querystring.parse(parsedUrl.query);
|
|
69
|
+
var identifier = query.openid_identifier;
|
|
70
|
+
|
|
71
|
+
// Resolve identifier, associate, and build authentication URL
|
|
72
|
+
relyingParty.authenticate(identifier, false, function (error, authUrl) {
|
|
73
|
+
if (error) {
|
|
74
|
+
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
75
|
+
res.end('Authentication failed: ' + error.message);
|
|
76
|
+
}
|
|
77
|
+
else if (!authUrl) {
|
|
78
|
+
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
79
|
+
res.end('Authentication failed');
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
res.writeHead(302, { Location: authUrl });
|
|
83
|
+
res.end();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else if (parsedUrl.pathname == '/verify') {
|
|
88
|
+
// Verify identity assertion
|
|
89
|
+
// NOTE: Passing just the URL is also possible
|
|
90
|
+
relyingParty.verifyAssertion(req, function (error, result) {
|
|
91
|
+
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
92
|
+
|
|
93
|
+
if (error) {
|
|
94
|
+
res.end('Authentication failed: ' + error.message);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Result contains properties:
|
|
98
|
+
// - authenticated (true/false)
|
|
99
|
+
// - answers from any extensions (e.g.
|
|
100
|
+
// "http://axschema.org/contact/email" if requested
|
|
101
|
+
// and present at provider)
|
|
102
|
+
res.end((result.authenticated ? 'Success :)' : 'Failure :(') +
|
|
103
|
+
'\n\n' + JSON.stringify(result));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// Deliver an OpenID form on all other URLs
|
|
109
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
110
|
+
res.end('<!DOCTYPE html><html><body>'
|
|
111
|
+
+ '<form method="get" action="/authenticate">'
|
|
112
|
+
+ '<p>Login using OpenID</p>'
|
|
113
|
+
+ '<input name="openid_identifier" />'
|
|
114
|
+
+ '<input type="submit" value="Login" />'
|
|
115
|
+
+ '</form></body></html>');
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
server.listen(80);
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
/* OpenID for node.js
|
|
2
|
-
*
|
|
3
|
-
* http://ox.no/software/node-openid
|
|
4
|
-
* http://github.com/havard/node-openid
|
|
5
|
-
*
|
|
6
|
-
* Copyright (C) 2010 by Håvard Stranden
|
|
7
|
-
*
|
|
8
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
* in the Software without restriction, including without limitation the rights
|
|
11
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
* furnished to do so, subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in
|
|
16
|
-
* all copies or substantial portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const openid = require('../openid');
|
|
27
|
-
|
|
28
|
-
test('Cancelled verification does not authenticate', () => {
|
|
29
|
-
openid.verifyAssertion(
|
|
30
|
-
'http://host/?openid.mode=cancel' +
|
|
31
|
-
'&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0',
|
|
32
|
-
'http://example.com/verify',
|
|
33
|
-
(error, result) => {
|
|
34
|
-
expect(error).toBeTruthy();
|
|
35
|
-
expect(result).toBeFalsy();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
/* OpenID for node.js
|
|
2
|
+
*
|
|
3
|
+
* http://ox.no/software/node-openid
|
|
4
|
+
* http://github.com/havard/node-openid
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2010 by Håvard Stranden
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in
|
|
16
|
+
* all copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const openid = require('../openid');
|
|
27
|
+
|
|
28
|
+
test('Cancelled verification does not authenticate', () => {
|
|
29
|
+
openid.verifyAssertion(
|
|
30
|
+
'http://host/?openid.mode=cancel' +
|
|
31
|
+
'&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0',
|
|
32
|
+
'http://example.com/verify',
|
|
33
|
+
(error, result) => {
|
|
34
|
+
expect(error).toBeTruthy();
|
|
35
|
+
expect(result).toBeFalsy();
|
|
36
|
+
});
|
|
37
|
+
});
|
package/test/extensions.test.js
CHANGED
|
@@ -1,66 +1,65 @@
|
|
|
1
|
-
/* OpenID for node.js
|
|
2
|
-
*
|
|
3
|
-
* http://ox.no/software/node-openid
|
|
4
|
-
* http://github.com/havard/node-openid
|
|
5
|
-
*
|
|
6
|
-
* Copyright (C) 2010 by Håvard Stranden
|
|
7
|
-
*
|
|
8
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
* in the Software without restriction, including without limitation the rights
|
|
11
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
* furnished to do so, subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in
|
|
16
|
-
* all copies or substantial portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const openid = require('../openid');
|
|
27
|
-
|
|
28
|
-
test('Attribute Exchange (AX) values are parsed', () => {
|
|
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
|
-
|
|
1
|
+
/* OpenID for node.js
|
|
2
|
+
*
|
|
3
|
+
* http://ox.no/software/node-openid
|
|
4
|
+
* http://github.com/havard/node-openid
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2010 by Håvard Stranden
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in
|
|
16
|
+
* all copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const openid = require('../openid');
|
|
27
|
+
|
|
28
|
+
test('Attribute Exchange (AX) values are parsed', () => {
|
|
29
|
+
const ax = new openid.AttributeExchange(),
|
|
30
|
+
results = {},
|
|
31
|
+
exampleParams = {
|
|
32
|
+
'openid.ax.type.email': 'http://axschema.org/contact/email',
|
|
33
|
+
'openid.ax.value.email': 'fred.example@gmail.com',
|
|
34
|
+
'openid.ax.type.language': 'http://axschema.org/pref/language',
|
|
35
|
+
'openid.ax.value.language': 'english',
|
|
36
|
+
'openid.ax.type.phones': 'http://axschema.org/contact/phone/cell',
|
|
37
|
+
'openid.ax.count.phones': '2',
|
|
38
|
+
'openid.ax.value.phones.1': '+1 (555) 555-5555',
|
|
39
|
+
'openid.ax.value.phones.2': '+33 6 55 55 55 55',
|
|
40
|
+
'openid.ax.value.phones.3': '+46 5 5555 5555',
|
|
41
|
+
}
|
|
42
|
+
ax.fillResult(exampleParams, results);
|
|
43
|
+
|
|
44
|
+
expect(results['email']).toBe('fred.example@gmail.com');
|
|
45
|
+
expect(results['http://axschema.org/contact/email']).toBe('fred.example@gmail.com');
|
|
46
|
+
expect(results['language']).toBe('english');
|
|
47
|
+
expect(results['http://axschema.org/pref/language']).toBe('english');
|
|
48
|
+
expect(results['phones'].length).toBe(2);
|
|
49
|
+
expect(results['phones'][0]).toBe('+1 (555) 555-5555');
|
|
50
|
+
expect(results['phones'][1]).toBe('+33 6 55 55 55 55');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('PAPE values are parsed', () => {
|
|
54
|
+
const authDate = new Date().toISOString();
|
|
55
|
+
const exampleParams = {
|
|
56
|
+
"openid.pape.auth_time": authDate,
|
|
57
|
+
"openid.pape.auth_policies": 'http://schemas.openid.net/pape/policies/2007/06/multi-factor http://schemas.openid.net/pape/policies/2007/06/phishing-resistant'
|
|
58
|
+
};
|
|
59
|
+
const pape = new openid.PAPE(),
|
|
60
|
+
results = {};
|
|
61
|
+
|
|
62
|
+
pape.fillResult(exampleParams, results);
|
|
63
|
+
expect(results['auth_time']).toBe(authDate);
|
|
64
|
+
expect(results['auth_policies']).toBe('multi-factor phishing-resistant');
|
|
65
|
+
});
|