kayleecodes1 / cas-authentication

A CAS authentication library designed to be used as middleware for an Express server.
MIT License
73 stars 77 forks source link

redirect to undefined after log in #29

Open Eryoka opened 2 years ago

Eryoka commented 2 years ago

After a successful log in on the cas website, I am redirected to mywebiste.com/undefined

A sample that produces this error :

const express = require("express");
const app = express();

const session = require("express-session");
app.use(session({
        secret : "test",
        resave : false,
        saveUninitialized : true,
        cookie : {
                maxAge : 60 * 60 * 1000,
                sameSite : "strict"
        }
}));

const casAuthentication = require("cas-authentication");
const cas = new casAuthentication({
        cas_url : "https://caswebsite.com",
        service_url : "http://mywebsite.com",
});

app.get("/", cas.bounce, (req, res) => {
        console.log(req.session);
        res.send("Hello, world!");
});

app.listen(80);

even if I can log in on cas website no session data is stored on my website, everytime I request mywebsite.com I get the cas login page.

By modifying the _handleTicket function as such :

else {
    req.session[ this.session_name ] = user;
    if (this.session_info) {
        req.session[ this.session_info ] = attributes || {};
    }
    res.send("connected");
}

The session data is stored and I can get the webpage after log in. No idea why the cas_return_to is undefined.