diff --git a/client/dialog.css b/client/dialog.css index 2e7eed2..e8df2c5 100644 --- a/client/dialog.css +++ b/client/dialog.css @@ -223,6 +223,10 @@ section>.contents { vertical-align:middle; height:250px } +#message { + position: absolute; + width: 250px; +} .message_screen { z-index:-1; -ms-filter:"alpha(opacity=0)"; diff --git a/client/security.coffee b/client/security.coffee index 0e3dd0d..df4ce87 100644 --- a/client/security.coffee +++ b/client/security.coffee @@ -15,6 +15,9 @@ settings = {} +# Mozilla Persona service closes on +personaEnd = new Date('2016-11-30') + claim_wiki = () -> # we want to initiate a claim on a wiki # @@ -115,7 +118,10 @@ setup = (user) -> dialogHost = settings.wikiHost else dialogHost = window.location.host - settings.dialogURL = dialogProtocol + '//' + dialogHost + '/auth/loginDialog' + if settings.usingPersona + settings.dialogURL = dialogProtocol + '//' + dialogHost + '/auth/personaLogin' + else + settings.dialogURL = dialogProtocol + '//' + dialogHost + '/auth/loginDialog' settings.relayURL = dialogProtocol + '//' + dialogHost + '/auth/relay.html' update_footer ownerName, isAuthenticated, isOwner diff --git a/package.json b/package.json index 0733f79..3b4eecd 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,11 @@ "coffee-script": "1.10", "lodash": "4", "passport": "^0.3.2", - "passport-twitter": "*", - "passport-github": "*", - "passport-google-oauth20": "*", - "qs": "6.1" + "passport-github": "^1.1.0", + "passport-google-oauth20": "^1.0.0", + "passport-twitter": "^1.0.4", + "persona-pass": "^0.2.1", + "qs": "^6.2.0" }, "devDependencies": { "coffeeify": "*", diff --git a/server/social.coffee b/server/social.coffee index 5e5ee04..08e8f33 100644 --- a/server/social.coffee +++ b/server/social.coffee @@ -123,7 +123,11 @@ module.exports = exports = (log, loga, argv) -> security.isAuthorized = isAuthorized = (req) -> if usingPersona - # not added legacy support yet, so... + try + if req.session.passport.user.email is owner + return true + else + return false return false else if owner is '' # site not claimed? @@ -221,6 +225,18 @@ module.exports = exports = (log, loga, argv) -> } cb(null, profile))) + # Persona Strategy + PersonaStrategy = require('persona-pass').Strategy + + passport.use(new PersonaStrategy({ + audience: callbackProtocol + '//' + callbackHost + }, (email, cb) -> + user = { + provider: 'persona' + email: email + } + cb(null, user))) + app.use(passport.initialize()) app.use(passport.session()) @@ -242,11 +258,16 @@ module.exports = exports = (log, loga, argv) -> app.get('/auth/google/callback', passport.authenticate('google', { successRedirect: '/auth/loginDone', failureRedirect: '/auth/loginDialog'})) + # Persona + app.post('/auth/browserid', + passport.authenticate('persona', { successRedirect: '/auth/loginDone', failureRedirect: '/auth/loginDialog'})) + app.get '/auth/client-settings.json', (req, res) -> # the client needs some information to configure itself settings = { useHttps: useHttps + usingPersona: usingPersona } if wikiHost settings.wikiHost = wikiHost @@ -258,7 +279,6 @@ module.exports = exports = (log, loga, argv) -> schemeButtons = [] _(ids).forEach (scheme) -> - console.log "Scheme: ", scheme switch scheme when "twitter" then schemeButtons.push({button: "Twitter"}) when "github" then schemeButtons.push({button: "Github"}) @@ -276,6 +296,49 @@ module.exports = exports = (log, loga, argv) -> } res.render(path.join(__dirname, '..', 'views', 'securityDialog.html'), info) + app.get '/auth/personaLogin', (req, res) -> + referer = req.headers.referer + console.log "logging into: ", url.parse(referer).hostname + + schemeButtons = [] + if Date.now() < personaEnd + schemeButtons.push({ + button: "Persona + "}) + info = { + wikiName: url.parse(referer).hostname + wikiHostName: if wikiHost + "part of " + req.hostname + " wiki farm" + else + "a federated wiki site" + title: "Federated Wiki: Site Owner Sign-on" + loginText: "Sign in to" + message: "Mozilla Persona closes on 30th November 2016. Wiki owners should add an alternative identity as soon as they are able." + schemes: schemeButtons + } + else + info = { + wikiName: url.parse(referer).hostname + wikiHostName: if wikiHost + "part of " + req.hostname + " wiki farm" + else + "a federated wiki site" + title: "Federated Wiki: Site Owner Sign-on" + message: "Mozilla Persona has now closed. Wiki owners will need to contact the Wiki Farm owner to re-claim their wiki." + } + res.render(path.join(__dirname, '..', 'views', 'personaDialog.html'), info) + app.get '/auth/loginDone', (req, res) -> info = { title: if owner diff --git a/views/personaDialog.html b/views/personaDialog.html new file mode 100644 index 0000000..e558053 --- /dev/null +++ b/views/personaDialog.html @@ -0,0 +1,54 @@ + + + + + {{title}} + + + + + + + +
+
+
+
+ +

{{wikiName}}

+

{{wikiHostName}}

+
+
+
+
+
+
+
+
+

{{loginText}} {{wikiName}} with...

+ {{#schemes}} +

{{{button}}}

+ {{/schemes}} + {{#if message}} +
+

{{message}}

+
+ {{/if}} +
+
+
+
+
+
+ +
+ +
+ + diff --git a/views/securityDialog.html b/views/securityDialog.html index 359d9c3..9eb4e26 100644 --- a/views/securityDialog.html +++ b/views/securityDialog.html @@ -27,6 +27,11 @@ {{#schemes}}

{{{button}}}

{{/schemes}} + {{#if message}} +
+

{{message}}

+
+ {{/if}}