Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
da2a9950
Commit
da2a9950
authored
13 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
support 'issuer' in the verifier server, also don't crash the server on a pubkey parse error
parent
54f50b5c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
verifier/server/idassertion.js
+28
-19
28 additions, 19 deletions
verifier/server/idassertion.js
with
28 additions
and
19 deletions
verifier/server/idassertion.js
+
28
−
19
View file @
da2a9950
...
...
@@ -76,7 +76,7 @@ var Webfinger = (function() {
}
else
{
var
hostmetaURL
=
"
http://
"
+
domain
+
"
/.well-known/host-meta
"
;
var
hostmetaURL
=
domain
+
"
/.well-known/host-meta
"
;
var
domainSplit
=
domain
.
split
(
"
:
"
);
var
options
=
{
host
:
domainSplit
[
0
],
...
...
@@ -117,16 +117,21 @@ var Webfinger = (function() {
}
}
function
resolvePublicKeysForAddress
(
addr
,
successCallback
,
errorCallback
)
function
resolvePublicKeysForAddress
(
addr
,
issuer
,
successCallback
,
errorCallback
)
{
var
split
=
addr
.
split
(
"
@
"
);
if
(
split
.
length
!=
2
)
{
console
.
log
(
"
Cannot parse
"
+
addr
+
"
as an email address
"
);
errorCallback
({
message
:
"
Cannot parse input as an email address
"
});
return
;
};
var
id
=
split
[
0
];
var
domain
=
split
[
1
];
var
domain
=
undefined
;
if
(
typeof
issuer
===
'
string
'
)
{
domain
=
issuer
;
}
else
{
var
split
;
try
{
split
=
addr
.
split
(
"
@
"
);
}
catch
(
e
)
{
}
if
(
split
.
length
!=
2
)
{
console
.
log
(
"
Cannot parse
"
+
addr
+
"
as an email address
"
);
errorCallback
({
message
:
"
Cannot parse input as an email address
"
});
return
;
};
domain
=
split
[
1
];
}
retrieveTemplateForDomain
(
domain
,
...
...
@@ -262,7 +267,8 @@ IDAssertion.prototype =
// but for now we will assume email-based lookup
Webfinger
.
resolvePublicKeysForAddress
(
payload
.
email
,
payload
.
email
,
payload
.
issuer
,
function
(
publicKeys
)
{
if
(
publicKeys
.
length
==
0
)
{
...
...
@@ -273,14 +279,17 @@ IDAssertion.prototype =
// In the absence of a key identifier, we need to check them all.
for
(
var
i
=
0
;
i
<
publicKeys
.
length
;
i
++
)
{
// and now, public key parse fail. :(
var
pubKey
=
new
rsa
.
RSAKey
();
pubKey
.
readPublicKeyFromPEMString
(
publicKeys
[
i
].
key
);
if
(
token
.
verify
(
pubKey
))
{
// success!
console
.
log
(
"
Token for
"
+
payload
.
email
+
"
verified successfully.
"
);
onSuccess
(
true
);
return
;
try
{
var
pubKey
=
new
rsa
.
RSAKey
();
pubKey
.
readPublicKeyFromPEMString
(
publicKeys
[
i
].
key
);
if
(
token
.
verify
(
pubKey
))
{
// success!
console
.
log
(
"
Token for
"
+
payload
.
email
+
"
verified successfully.
"
);
onSuccess
(
true
);
return
;
}
}
catch
(
e
)
{
console
.
log
(
"
failed to parse public key:
"
+
e
);
}
}
onError
(
"
None of the user's public keys verified the signature
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment