Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var _verifyDiscoveredInformation = function(params, stateless, extensions, strict, callback)
{
var claimedIdentifier = params['openid.claimed_id'];
var useLocalIdentifierAsKey = false;
if(!_isDef(claimedIdentifier))
{
if(!_isDef(params['openid.ns']))
{
// OpenID 1.0/1.1 response without a claimed identifier
// We need to load discovered information using the
// local identifier
useLocalIdentifierAsKey = true;
}
else {
// OpenID 2.0+:
// If there is no claimed identifier, then the
// assertion is not about an identity
return callback(null, { authenticated: false });
}
}
if (useLocalIdentifierAsKey) {
claimedIdentifier = params['openid.identity'];
relyingParty.verifyAssertion(request, function(error, result) {
var isGood = !error && result.authenticated ? '<h1>Success!</h1>' : '<h1>Failed</h1>';
res.writeHead(200, {
'Content-Type': 'text/html'
});
res.write(isGood);
res.write('<p>' + query['openid.assoc_handle'] + '</p>');
res.write('<p>' + query['openid.claimed_id'] + '</p>');
res.write('<p>' + query['openid.identity'] + '</p>');
res.write('<p>' + query['openid.mode'] + '</p>');
res.write('<p>' + query['openid.ns'] + '</p>');
res.write('<p>' + query['openid.op_endpoint'] + '</p>');
res.write('<p>' + query['openid.response_nonce'] + '</p>');
res.write('<p>' + query['openid.return_to'] + '</p>');
res.write('<p>' + query['openid.sig'] + '</p>');
res.write('<p>' + query['openid.signed'] + '</p>');
res.end('bye');
});
});
var _verifyAssertionAgainstProviders = function(providers, params, stateless, extensions, callback)
{
for(var i = 0; i < providers.length; ++i)
{
var provider = providers[i];
if(!!params['openid.ns'] && (!provider.version || provider.version.indexOf(params['openid.ns']) !== 0))
{
continue;
}
if(!!provider.version && provider.version.indexOf('2.0') !== -1)
{
var endpoint = params['openid.op_endpoint'];
if (provider.endpoint != endpoint)
{
continue;
}
if(provider.claimedIdentifier) {
var claimedIdentifier = _getCanonicalClaimedIdentifier(params['openid.claimed_id']);
if(provider.claimedIdentifier != claimedIdentifier) {
return callback({ message: 'Claimed identifier in assertion response does not match discovered claimed identifier' });
}
var _requestAuthentication = function(provider, assoc_handle, returnUrl, realm, immediate, extensions, callback)
{
var params = {
'openid.mode' : immediate ? 'checkid_immediate' : 'checkid_setup'
};
if(provider.version.indexOf('2.0') !== -1)
{
params['openid.ns'] = 'http://specs.openid.net/auth/2.0';
}
for (var i in extensions)
{
if(!hasOwnProperty(extensions, i))
{
continue;
}
var extension = extensions[i];
for (var key in extension.requestParams)
{
if (!hasOwnProperty(extension.requestParams, key)) { continue; }
params[key] = extension.requestParams[key];
}
}