Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else if (this[i] != array[i]) {
// Warning - two different object instances will never be equal: {x:20} != {x:20}
return false;
}
}
return true;
}
// Hide method from for-in loops
Object.defineProperty(Array.prototype, "equals", { enumerable: false });
/* we start a local youtube http proxy because youtube doesnt like serving monetized videos to file:// sources */
exp.listen(window.YT_PORT, () => console.log(`RSManager listening on port ${window.YT_PORT} for yt requests (/yt/:vid).`))
exp.get('/yt/:vid', (req, res) => res.send(``))
window.STEAM_AUTH_URL = "http://localhost:" + window.YT_PORT
const relyingParty = new openid.RelyingParty(
window.STEAM_AUTH_URL + "/verify-steam",
window.STEAM_AUTH_URL,
true,
false,
[]
);
const getCookie = filter => new Promise((resolve, reject) => {
window.remote.session.defaultSession.cookies.get(filter, (error, cookies) => {
if (error) reject(error);
else resolve(cookies);
})
});
exp.get('/verify-steam', async (req, res) => {
relyingParty.verifyAssertion(req, async (err, result) => {
if (err) {
module.exports = function(options) {
var extensions = [new openid.SimpleRegistration({
email: true
, fullname: true
})]
var relyingParty = new openid.RelyingParty(
urljoin(options.appUrl, '/auth/openid/verify')
, null // Realm (optional, specifies realm for OpenID authentication)
, false // Use stateless verification
, false // Strict mode
, extensions)
var log = logger.createLogger('auth-openid')
var app = express()
app.set('strict routing', true)
app.set('case sensitive routing', true)
app.get('/', function(req, res) {
res.redirect('/auth/openid/')
})
that.verifyPath = url.parse(that.callback, false).pathname;
// Build the authentication routes required
that.setupRoutes = function(server) {
server.use('/', connect.router(function routes(app){
app.get( that.verifyPath, function(req, res){
req.authenticate([that.name], function(error, authenticated) {
res.writeHead(303, { 'Location': req.session.openid_redirect_url });
res.end('');
});
});
}));
};
var relyingParty = new openid.RelyingParty(
that.callback, // Verification URL (yours)
that.realm, // Realm (optional, specifies realm for OpenID authentication)
that.stateless, // Use stateless verification
that.strictMode, // Strict mode
that.extensions); // List of extensions to enable and include
that.authenticate= function(request, response, callback) {
var self= this;
var parsedUrl= url.parse(request.url, true);
if( request.getAuthDetails()['openid_login_attempt_failed'] === true ) {
// Because we bounce through authentication calls across multiple requests
// we use this to keep track of the fact we *Really* have failed to authenticate
// so that we don't keep re-trying to authenticate forever.
delete request.getAuthDetails()['openid_login_attempt_failed'];
.definit( function () {
this.relyingParty =
new oid.RelyingParty(this._myHostname + this._callbackPath, null, false, false, [
new oid.AttributeExchange({
'http://axschema.org/contact/email': 'required'
, 'http://axschema.org/namePerson/first': 'required'
, 'http://axschema.org/namePerson/last': 'required'
})
, new oid.OAuthHybrid({
consumerKey: this._consumerKey
, scope: this._scope.join('+')
})
]);
this.oauth = new OAuth(
'https://www.google.com/accounts/OAuthGetRequestToken'
, 'https://www.google.com/accounts/OAuthGetAccessToken'
, this._consumerKey
, this._consumerSecret
.definit( function () {
this.relyingParty = new oid.RelyingParty(this.myHostname() + this.callbackPath(), null, false, false, [
new oid.UserInterface()
, new oid.SimpleRegistration(this.simpleRegistration())
, new oid.AttributeExchange(this.attributeExchange())
]);
})
.get('entryPath',
.definit( function () {
this.relyingParty = new oid.RelyingParty(this.myHostname() + this.callbackPath(), null, false, false, [
new oid.UserInterface()
, new oid.SimpleRegistration(this.simpleRegistration())
, new oid.AttributeExchange(this.attributeExchange())
]);
})
.get('entryPath',
module.exports.middleware = function(opts)
{
relyingParty = new openid.RelyingParty(
opts.verify,
opts.realm,
true,
true,
[]
);
apiKey = opts.apiKey;
useSession = true;
if(opts.useSession !== undefined)
{
useSession = opts.useSession;
}
return function(req, res, next) {
if(req.session && req.session.steamUser)
}
}
var pape = new openid.PAPE(papeOptions);
extensions.push(pape);
}
if (options.oauth) {
var oauthOptions = {};
oauthOptions.consumerKey = options.oauth.consumerKey;
oauthOptions.scope = options.oauth.scope;
var oauth = new openid.OAuthHybrid(oauthOptions);
extensions.push(oauth);
}
this._relyingParty = new openid.RelyingParty(
options.returnURL,
options.realm,
(options.stateless === undefined) ? false : options.stateless,
(options.secure === undefined) ? true : options.secure,
extensions);
this._providerURL = options.providerURL;
this._identifierField = options.identifierField || 'openid_identifier';
}
exports.authenticate = function(hostname, url, res, query) {
var exts= [];
var attr = new openid.AttributeExchange({
"http://axschema.org/contact/country/home": "required",
"http://axschema.org/namePerson/first": "required",
"http://axschema.org/pref/language": "required",
"http://axschema.org/namePerson/last": "required",
"http://axschema.org/contact/email": "required",
"http://axschema.org/namePerson/friendly": "required",
"http://axschema.org/namePerson": "required",
"http://axschema.org/media/image/default": "required",
"http://axschema.org/person/gender/": "required"
});
exts.push(attr);
rely = new openid.RelyingParty('https://'+hostname+':'+
session.configuration.port.farm_webServerPort+'/main.html?cmd=verify&id='+query.id,
null,
false,
false,
exts);
rely.authenticate(url, false, function(error, authUrl) {
if(error){
log.error(error);
} else if (!authUrl) {
log.error('authentication failed as url to redirect after authentication is missing');
} else {
res.writeHeader(200, 'application/x-javascript');
res.write(JSON.stringify({type:"prop", payload: {status:'authenticate-google', url: authUrl}}));
res.end();
}
});
app.get('/main/:useremail/request-access-verify', function (req, res) {
//Args: External user's PZH URL
//Args: External user's PZH certificate
//Auth: Check that the certificate is valid and that the certificate is valid for this URL.
//Auth: OpenID credential. THis is the redirect from a provider.
//UI: Present some confirmation
var externalRelyingParty = new openid.RelyingParty(
'https://' + address + ':' + port + '/main/' + encodeURIComponent(req.params.useremail) + '/request-access-verify',
null, false, false, [attr]);
externalRelyingParty.verifyAssertion(req, function (error, result) {
if (error) {
res.writeHead(200);
res.end('Authentication failed');
} else {
logger.log("Successfully authenticated external user: " + result.email +
"who claims to have: " + req.session.expectedExternalAuth.externalCertUrl +
" and " + req.session.expectedExternalAuth.externalPZHUrl);
if (!req.session.expectedExternalAuth.externalCertUrl) {
res.writeHead(200);
res.end('Failed to read cookies');
}