Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get same user from different user login #92

Open
nhduong29 opened this issue Feb 17, 2021 · 1 comment
Open

Get same user from different user login #92

nhduong29 opened this issue Feb 17, 2021 · 1 comment

Comments

@nhduong29
Copy link

nhduong29 commented Feb 17, 2021

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?

@TheBryanMac
Copy link

I can confirm this same issue. We setup a basic nodeSSPIObj.authenticate as middleware on a single route as an extra test. We disabled retrieveGroups just in case, but the issue is easy to replicate now.

If two users hit the endpoint and are challenged, we return the username in the response to all users. All near-concurrent responses get the same username returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants