TencentWSRD / connect-cas2

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

/cas/proxyCallback\' cannot be reached, it is not allowed to exercise proxy authentication #13

Closed jhyvictory closed 6 months ago

jhyvictory commented 6 years ago

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: null, originalMaxAge: null, httpOnly: true, serialize: [Function: serialize], toJSON: [Function: toJSON] }, lastUrl: 'http://106.15.231.113:3000/cas' } use default manner redirect to login page https://106.15.197.153:8443/cas/login?service=http%3A%2F%2F106.15.231.113%3A3000%2Fcas%2Fvalidate&sn=undefined GET /favicon.ico 302 1.740 ms - 132 options.restletIntegration is set, but options.paths.restletIntegration is undefined! Maybe you forget to set all your paths. Get lastUrl: http://106.15.231.113:3000/favicon.ico Start validating ticket... Find ticket in query ST-34-uANTwDrXtXcYEsQuFSkgeW6mTW4-localhost Sending request to: "https://106.15.197.153:8443/cas/serviceValidate?pgtUrl=http%3A%2F%2F106.15.231.113%3A3000%2Fcas%2FproxyCallback&service=http%3A%2F%2F106.15.231.113%3A3000%2Fcas%2Fvalidate&ticket=ST-34-uANTwDrXtXcYEsQuFSkgeW6mTW4-localhost" to validate ticket. |GET|https://106.15.197.153:8443/cas/serviceValidate?pgtUrl=http%3A%2F%2F106.15.231.113%3A3000%2Fcas%2FproxyCallback&service=http%3A%2F%2F106.15.231.113%3A3000%2Fcas%2Fvalidate&ticket=ST-34-uANTwDrXtXcYEsQuFSkgeW6mTW4-localhost|200|14 Receive from CAS server, status: 200 Receive response from CAS when validating ticket, but the validation is failed. Cas response: { '$': { 'xmlns:cas': 'http://www.yale.edu/tp/cas' }, authenticationFailure: [ { : 'The supplied proxy callback url \'http://106.15.231.113:3000/cas/proxyCallback\' could not be authenticated. Either \'http://106.15.231.113:3000/cas/proxyCallback\' cannot be reached, it is not allowed to exercise proxy authentication.', '$': [Object] } ] } GET /cas/validate?ticket=ST-34-uANTwDrXtXcYEsQuFSkgeW6mTW4-localhost 401 16.320 ms - 93

jhyvictory commented 6 years ago

var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser');

var ConnectCas = require('connect-cas2'); var session = require('express-session'); var MemoryStore = require('session-memory-store')(session);

var index = require('./routes/index'); var users = require('./routes/users');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

var app = express();

// view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade');

// uncomment after placing your favicon in /public //app.use(favicon(path.join(dirname, 'public', 'favicon.ico'))); app.use(session({ name: 'NSESSIONID', secret: 'Hello I am a long long long secret', store: new MemoryStore() // or other session store })); app.use(logger('dev')); app.use(cookieParser()); app.use(express.static(path.join(dirname, 'public')));

var casClient = new ConnectCas({ ignore: [ /\/ignore/ ], match: [], servicePrefix: 'http://106.15.231.113:3000', // 'http://localhost:3000', serverPath: 'https://106.15.197.153:8443', paths: { validate: '/cas/validate', serviceValidate: '/cas/serviceValidate', // proxy: '/cas/proxy', login: '/cas/login', logout: '/cas/logout', // proxyCallback: '/cas/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()); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true }));

app.get('/logout', casClient.logout()); // app.post('/cas/proxyCallback', function(req, res){ // res.send('Hello World!'); // }); app.use('/', index); app.use('/users', users);

// catch 404 and forward to error handler app.use(function(req, res, next) { var err = new Error('Not Found'); err.status = 404; next(err); });

// error handler app.use(function(err, req, res, next) { // set locals, only providing error in development res.locals.message = err.message; res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page res.status(err.status || 500); res.render('error'); });

module.exports = app;

ilyas-shah commented 5 years ago

@jhyvictory hey, can you share the code where you have used this module? also, can you tell me how to test this thing if it is working?