mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
Fix eslint errors
This commit is contained in:
parent
c3df22070c
commit
97269b3aa8
2 changed files with 41 additions and 39 deletions
|
@ -1,8 +1,6 @@
|
|||
var http = require('http')
|
||||
var url = require('url');
|
||||
var querystring = require('querystring');
|
||||
|
||||
var openid = require('openid');
|
||||
var openid = require('openid')
|
||||
var express = require('express')
|
||||
var urljoin = require('url-join')
|
||||
|
||||
|
@ -12,17 +10,19 @@ var urlutil = require('../../util/urlutil')
|
|||
|
||||
module.exports = function(options) {
|
||||
var extensions = [new openid.SimpleRegistration({
|
||||
"email" : true,
|
||||
"fullname" : true,
|
||||
})];
|
||||
email: true
|
||||
, fullname: true
|
||||
})]
|
||||
|
||||
var relyingParty = new openid.RelyingParty(
|
||||
urljoin(options.appUrl, "/auth/openid/verify"),
|
||||
null, // Realm (optional, specifies realm for OpenID authentication)
|
||||
false, // Use stateless verification
|
||||
false, // Strict mode
|
||||
extensions)
|
||||
var log = logger.createLogger('auth-openid');
|
||||
var app = express();
|
||||
urljoin(options.appUrl, '/auth/openid/verify')
|
||||
, null // Realm (optional, specifies realm for OpenID authentication)
|
||||
, false // Use stateless verification
|
||||
, false // Strict mode
|
||||
, extensions)
|
||||
|
||||
var log = logger.createLogger('auth-openid')
|
||||
var app = express()
|
||||
|
||||
app.set('strict routing', true)
|
||||
app.set('case sensitive routing', true)
|
||||
|
@ -33,40 +33,42 @@ module.exports = function(options) {
|
|||
|
||||
app.get('/auth/openid/', function(req, res) {
|
||||
log.info('openid identifier url: %s', options.openid.identifierUrl)
|
||||
relyingParty.authenticate(options.openid.identifierUrl, false, function(err, authUrl){
|
||||
if (err){
|
||||
res.send("auth failed");
|
||||
} else if(!authUrl){
|
||||
res.send("auth failed");
|
||||
} else {
|
||||
log.info("redirect to authUrl: %s", options.openid.identifierUrl);
|
||||
res.redirect(authUrl);
|
||||
relyingParty.authenticate(options.openid.identifierUrl, false, function(err, authUrl) {
|
||||
if (err) {
|
||||
res.send('Authentication failed')
|
||||
}
|
||||
});
|
||||
else if (!authUrl) {
|
||||
res.send('Authentication failed')
|
||||
}
|
||||
else {
|
||||
log.info('redirect to authUrl: %s', options.openid.identifierUrl)
|
||||
res.redirect(authUrl)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
app.get('/auth/openid/verify', function(req, res){
|
||||
app.get('/auth/openid/verify', function(req, res) {
|
||||
log.setLocalIdentifier(req.ip)
|
||||
|
||||
relyingParty.verifyAssertion(req, function(err, result){
|
||||
log.info("openid verify assertion");
|
||||
relyingParty.verifyAssertion(req, function(err, result) {
|
||||
log.info('openid verify assertion')
|
||||
if (err || !result.authenticated) {
|
||||
res.send("Auth failed");
|
||||
res.send('Authentication failed')
|
||||
return
|
||||
}
|
||||
var email = req.query['openid.sreg.email'];
|
||||
var name = req.query['openid.sreg.fullname'];
|
||||
var email = req.query['openid.sreg.email']
|
||||
var name = req.query['openid.sreg.fullname']
|
||||
log.info('Authenticated "%s:%s"', name, email)
|
||||
var token = jwtutil.encode({
|
||||
payload: {
|
||||
email: email,
|
||||
name: name
|
||||
},
|
||||
secret: options.secret
|
||||
email: email
|
||||
, name: name
|
||||
}
|
||||
, secret: options.secret
|
||||
})
|
||||
res.redirect(urlutil.addParams(options.appUrl, {jwt: token}));
|
||||
res.redirect(urlutil.addParams(options.appUrl, {jwt: token}))
|
||||
})
|
||||
});
|
||||
})
|
||||
|
||||
http.createServer(app).listen(options.port)
|
||||
log.info('Listening on port %d', options.port)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue