Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const kerberos = require("kerberos");
const express = require("express");
const app = express();
const krbSvc = "HTTP@centos.domain.org";
app.get('/', function (req, res) {
console.log('-----request-----');
console.log(req.headers);
if (!req.headers.authorization) {
res.set( 'WWW-Authenticate', 'Negotiate' );
console.log('-----response-----');
console.log(res._headers);
res.status(401).send();
} else {
//cut phrase "Negotiate "
let ticket = req.headers.authorization.substring(10);
//init server
kerberos.initializeServer(krbSvc, function(err, krbServer) {
if (err) console.error(err);
//check ticket
krbServer.step(ticket, function(err) {
if (err) console.error(err);
console.log(krbServer);
let response = 'User login: ' + krbServer.username;
res.send(response);
});
});
}
});
app.listen(3005);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.