TencentWSRD / connect-cas2

NodeJS implement of CAS(Central Authentication Service) client.
MIT License
107 stars 44 forks source link

EHOSTUNREACH error when validating a ticket #6

Open akooshesh opened 7 years ago

akooshesh commented 7 years ago

I use connect-cas2 with a simple server.js that I have copied at the end of this message. When validating a ticket that comes back from the CAS server, I get the following error. However, if I copy and past the request that triggers the error into a browser, I get E_TICKET_EXPIRED, which indicates that the URL that validate is using is a valid URL that can be resolved. I have pasted my server to the end of this message. Any help is appreciated.

Best Regards

Ali

// Error starting with redirect output. Secure server listening on port: 443 Address: 130.157.3.107 options.restletIntegration is set, but options.paths.restletIntegration is undefined! Maybe you forget to set all your paths. Doing authenticating... Can not find st in session Session { cookie: { path: '/', _expires: 2017-03-14T18:45:00.738Z, originalMaxAge: 60000, httpOnly: true } } use default manner redirect to login page https://login.sonoma.edu/cas-server/login?service=https%3A%2F%2Ffullmoon.sonoma.edu%2Fvalidate&sn=undefined options.restletIntegration is set, but options.paths.restletIntegration is undefined! Maybe you forget to set all your paths. Get lastUrl: https://fullmoon.sonoma.edu/ Start validating ticket... Find ticket in query ST-1489517045271-eiiPtnJkLLvDh5RClPeVuegnF Sending request to: "https://login.sonoma.edu/cas-server/serviceValidate?pgtUrl=https%3A%2F%2Ffullmoon.sonoma.edu%2Fcas%2FproxyCallback&service=https%3A%2F%2Ffullmoon.sonoma.edu%2Fvalidate&ticket=ST-1489517045271-eiiPtnJkLLvDh5RClPeVuegnF" to validate ticket. sendRequest on error { Error: connect EHOSTUNREACH 130.157.3.61:443 at Object.exports._errnoException (util.js:1022:11) at exports._exceptionWithHostPort (util.js:1045:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14) code: 'EHOSTUNREACH', errno: 'EHOSTUNREACH', syscall: 'connect', address: '130.157.3.61', port: 443 } https://login.sonoma.edu/cas-server/serviceValidate?pgtUrl=https%3A%2F%2Ffullmoon.sonoma.edu%2Fcas%2FproxyCallback&service=https%3A%2F%2Ffullmoon.sonoma.edu%2Fvalidate&ticket=ST-1489517045271-eiiPtnJkLLvDh5RClPeVuegnF { method: 'get' } |GET|https://login.sonoma.edu/cas-server/serviceValidate?pgtUrl=https%3A%2F%2Ffullmoon.sonoma.edu%2Fcas%2FproxyCallback&service=https%3A%2F%2Ffullmoon.sonoma.edu%2Fvalidate&ticket=ST-1489517045271-eiiPtnJkLLvDh5RClPeVuegnF|500|1019 Error when sending request to CAS server, error: Error: connect EHOSTUNREACH 130.157.3.61:443 { Error: connect EHOSTUNREACH 130.157.3.61:443 at Object.exports._errnoException (util.js:1022:11) at exports._exceptionWithHostPort (util.js:1045:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14) code: 'EHOSTUNREACH', errno: 'EHOSTUNREACH', syscall: 'connect', address: '130.157.3.61', port: 443 }

// end of error messages.

// server.js

// server.js 'use strict';

var express = require('express'); var bodyParser = require('body-parser'); var ssl_port = process.env.PORT || 443; //var addr = process.env.BIND_IP || "127.0.0.1"; var addr = process.env.BIND_IP || "130.157.3.107"; var app = express(); var fs = require('fs'); var https = require('https');

// CAS var session = require('express-session'); var ConnectCas = require('connect-cas2'); var cookieParser = require('cookie-parser'); var MemoryStore = require('session-memory-store')(session);

app.use(cookieParser());

app.use(session({ name: 'NSESSIONID', secret: 'some secret', cookie: { maxAge: 60000 }, resave: true, saveUninitialized: true, store: new MemoryStore() }))

// app.use(session({ // name: 'NSESSIONID', // secret: 'Hello I am a long long long secret', // store: new MemoryStore() // or other session store // }));

var casClient = new ConnectCas({ debug: true, ignore: [ /\/ignore/ ], match: [], servicePrefix: 'https://fullmoon.sonoma.edu', serverPath: 'https://login.sonoma.edu', paths: { validate: '/validate', // client service validate serviceValidate: '/cas-server/serviceValidate', // server service validate // proxy: '/buglycas/proxy', login: '/cas-server/login', // server's service name logout: '/buglycas/logout', // proxyCallback: '/buglycas/proxyCallback' }, redirect: false, gateway: false, renew: false, slo: true, cache: { enable: false, ttl: 5 60 1000, filter: [] }, fromAjax: { header: 'x-client-ajax', status: 418 }, });

app.use(casClient.core());

// end CAS

// these need to be generated or added before the application can be ran var privateKey = fs.readFileSync('sslcert/fullmoon.sonoma.edu.key', 'utf8'); var certificate = fs.readFileSync('sslcert/fullmoon.sonoma.edu.crt', 'utf8'); var credentials = {key: privateKey, cert: certificate};

app.get('/validate', function(req, res) { console.log("-----> in /cas/validate"); });

// Create the server //app.use(express.static(__dirname + '/public'));

// app.listen(ssl_port, addr);

// var httpServer = http.createServer(app); var httpsServer = https.createServer(credentials, app);

// don't listen to http traffic for login security reasons //httpServer.listen(port); httpsServer.listen(ssl_port);

//console.log('Server listening on port: ', port, " Address: ", addr); console.log('Secure server listening on port: ', ssl_port, " Address: ", addr);

fyzwjd commented 6 years ago

How did you handle the question, could you share it ?

yuyongyu08 commented 6 years ago

set options.restletIntegration: null, document is not latest, read source code.

ilyas-shah commented 5 years ago

@yuyongyu08 can you tell me, how can I test thing if it is working?