wiki-security-passportjs 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiki-security-passportjs",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Security plugin for Federated Wiki, using passport.js",
5
5
  "author": "Paul Rodwell <paul.rodwell@btinternet.com> (http://rodwell.me)",
6
6
  "license": "MIT",
@@ -28,7 +28,6 @@ module.exports = exports = (log, loga, argv) ->
28
28
 
29
29
  owner = ''
30
30
  ownerName = ''
31
- user = {}
32
31
  wikiName = argv.url
33
32
  wikiHost = argv.wiki_domain
34
33
 
@@ -215,10 +214,12 @@ module.exports = exports = (log, loga, argv) ->
215
214
  username_query = 'params.user_id'
216
215
 
217
216
  try
218
- user.oauth2 = {
219
- id: extractUserInfo(argv.oauth2_IdField, 'params.user_id')
220
- username: extractUserInfo(argv.oauth2_UsernameField, 'params.user_id')
221
- displayName: extractUserInfo(argv.oauth2_DisplayNameField, 'params.user_id')
217
+ user = {
218
+ oauth2: {
219
+ id: extractUserInfo(argv.oauth2_IdField, 'params.user_id')
220
+ username: extractUserInfo(argv.oauth2_UsernameField, 'params.user_id')
221
+ displayName: extractUserInfo(argv.oauth2_DisplayNameField, 'params.user_id')
222
+ }
222
223
  }
223
224
  catch e
224
225
  console.error('*** Error extracting user info:', e)
@@ -239,11 +240,13 @@ module.exports = exports = (log, loga, argv) ->
239
240
  # callbackURL is optional, and if it exists must match that given in
240
241
  # the OAuth application settings - so we don't specify it.
241
242
  }, (accessToken, refreshToken, profile, cb) ->
242
- user.github = {
243
- id: profile.id
244
- username: profile.username
245
- displayName: profile.displayName
246
- emails: profile.emails
243
+ user = {
244
+ github: {
245
+ id: profile.id
246
+ username: profile.username
247
+ displayName: profile.displayName
248
+ emails: profile.emails
249
+ }
247
250
  }
248
251
  cb(null, user)))
249
252
 
@@ -259,10 +262,12 @@ module.exports = exports = (log, loga, argv) ->
259
262
  consumerSecret: argv.twitter_consumerSecret
260
263
  callbackURL: callbackProtocol + '//' + callbackHost + '/auth/twitter/callback'
261
264
  }, (accessToken, refreshToken, profile, cb) ->
262
- user.twitter = {
263
- id: profile.id
264
- username: profile.username
265
- displayName: profile.displayName
265
+ user = {
266
+ twitter: {
267
+ id: profile.id
268
+ username: profile.username
269
+ displayName: profile.displayName
270
+ }
266
271
  }
267
272
  cb(null, user)))
268
273
 
@@ -278,11 +283,12 @@ module.exports = exports = (log, loga, argv) ->
278
283
  clientSecret: argv.google_clientSecret
279
284
  callbackURL: callbackProtocol + '//' + callbackHost + '/auth/google/callback'
280
285
  }, (accessToken, refreshToken, profile, cb) ->
281
- user.google = {
286
+ user = { google: {
282
287
  id: profile.id
283
288
  displayName: profile.displayName
284
289
  emails: profile.emails
285
- }
290
+ }
291
+ }
286
292
  cb(null, user)))
287
293
 
288
294
  app.use(passport.initialize())
@@ -408,7 +414,7 @@ module.exports = exports = (log, loga, argv) ->
408
414
  res.header 'Access-Control-Allow-Origin', req.get('Origin')||'*'
409
415
  res.header 'Access-Control-Allow-Credentials', 'true'
410
416
  # protect unclaimed by adding "add owner isnt ''" - maybe via parameter
411
- return next() if (isAuthorized(req) and owner !== '') or allowedToView(req)
417
+ return next() if (isAuthorized(req) and (owner isnt '')) or allowedToView(req)
412
418
  return res.redirect("/view/#{m[1]}") if m = req.url.match /\/(.*)\.html/
413
419
  return res.json(['Login Required']) if req.url == '/system/sitemap.json'
414
420
 
@@ -535,7 +541,7 @@ module.exports = exports = (log, loga, argv) ->
535
541
 
536
542
  app.get '/logout', (req, res) ->
537
543
  console.log 'Logout...'
538
- req.logout()
544
+ req.session.reset()
539
545
  res.send("OK")
540
546
 
541
547
  security