Skip to content

Get same user from different user login #92

@nhduong29

Description

@nhduong29

Hi @abbr,

I faced weird issues.
I and my colleague access the API (/test/login) at the same time(really fast) then I can get his username instead of my user name.
This is my implementation :

app.use(function(req, res, next) {
    if (req.originalUrl === '/test/login') {
        var nodeSSPI = require('node-sspi')
        var nodeSSPIObj = new nodeSSPI({
                retrieveGroups: true
            })
        nodeSSPIObj.authenticate(req, res, function(err) {
            res.finished || next()
        })
    } else {
        next()
    }
})

app.get('/test/login', (req, res) => {
    if (req.connection.user.trim() && (req.connection.user.split("\\")[1].trim())) {
        const username = req.connection.user.split("\\")[1].trim()//=====> We will get the same user name here
        res.redirect(`${process.env.LOGIN_REDIRECT}?username=${username}`);
    } else {
        res.redirect(process.env.LOGIN_REDIRECT);
    }
})

Did I miss something in the configuration?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions