Another issue regarding invalid assertion
Closed this issue · 3 comments
dpourmehr commented
I've looked through all the old issues with this involving this error, and have seen all the fixes people have gone over, but have not been able to fix this for myself.
At the moment, this is the error I'm getting...
Error
at /Users/Shared/workspace/test/passport-steam/node_modules/passport-openid/lib/passport-openid/strategy.js:184:36
at /Users/Shared/workspace/test/passport-steam/node_modules/openid/openid.js:981:12
at /Users/Shared/workspace/test/passport-steam/node_modules/openid/openid.js:1105:16
at /Users/Shared/workspace/test/passport-steam/node_modules/openid/openid.js:1212:14
at Request._callback (/Users/Shared/workspace/test/passport-steam/node_modules/openid/openid.js:242:7)
at self.callback (/Users/Shared/workspace/test/passport-steam/node_modules/request/request.js:186:22)
at emitOne (events.js:115:13)
at Request.emit (events.js:210:7)
at Request.onRequestError (/Users/Shared/workspace/test/passport-steam/node_modules/request/request.js:878:8)
at emitOne (events.js:115:13)
When I change up the failure response to show the error message, I get a more fine-tuned error: 'InternalOpenIDError: Failed to verify assertion'
The main issue thread that was opened for this was closed last July, and none of the fixes listed in there have helped me resolve this, and I need this for a project I'm doing.
If anyone at all has a resolution to this, please help.
The primary code used is below:
app.js
/**
* Basic example demonstrating passport-steam usage within Express framework
*/
var express = require('express')
, passport = require('passport')
, util = require('util')
, session = require('express-session')
, SteamStrategy = require('../../').Strategy;
// Passport session setup.
// To support persistent login sessions, Passport needs to be able to
// serialize users into and deserialize users out of the session. Typically,
// this will be as simple as storing the user ID when serializing, and finding
// the user by ID when deserializing. However, since this example does not
// have a database of user records, the complete Steam profile is serialized
// and deserialized.
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(obj, done) {
done(null, obj);
});
// Use the SteamStrategy within Passport.
// Strategies in passport require a `validate` function, which accept
// credentials (in this case, an OpenID identifier and profile), and invoke a
// callback with a user object.
passport.use(new SteamStrategy({
returnURL: 'http://localhost:3000/auth/steam/return',
realm: 'http://localhost:3000/',
apiKey: 'xxxxxxxxxxxxxxxxxxx'
},
function(identifier, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
// To keep the example simple, the user's Steam profile is returned to
// represent the logged-in user. In a typical application, you would want
// to associate the Steam account with a user record in your database,
// and return that user instead.
profile.identifier = identifier;
return done(null, profile);
});
}
));
var app = express();
// configure Express
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(session({
secret: 'your secret',
name: 'name of session id',
resave: true,
saveUninitialized: true}));
// Initialize Passport! Also use passport.session() middleware, to support
// persistent login sessions (recommended).
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static(__dirname + '/../../public'));
app.get('/', function(req, res){
res.render('index', { user: req.user });
});
app.get('/account', ensureAuthenticated, function(req, res){
res.render('account', { user: req.user });
});
app.get('/logout', function(req, res){
req.logout();
res.redirect('/');
});
// GET /auth/steam
// Use passport.authenticate() as route middleware to authenticate the
// request. The first step in Steam authentication will involve redirecting
// the user to steamcommunity.com. After authenticating, Steam will redirect the
// user back to this application at /auth/steam/return
app.get('/auth/steam',
passport.authenticate('steam', { failureRedirect: '/' }),
function(req, res) {
res.redirect('/');
});
// GET /auth/steam/return
// Use passport.authenticate() as route middleware to authenticate the
// request. If authentication fails, the user will be redirected back to the
// login page. Otherwise, the primary route function function will be called,
// which, in this example, will redirect the user to the home page.
app.get('/auth/steam/return',
passport.authenticate('steam', { failureRedirect: '/' }),
function(req, res) {
res.redirect('/');
});
app.listen(3000);
// Simple route middleware to ensure user is authenticated.
// Use this route middleware on any resource that needs to be protected. If
// the request is authenticated (typically via a persistent login session),
// the request will proceed. Otherwise, the user will be redirected to the
// login page.
function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/');
}
Eqls commented
Having same exact issue