adding persona for legacy
This commit is contained in:
parent
c292bba632
commit
1fed7ecee1
|
@ -223,6 +223,10 @@ section>.contents {
|
||||||
vertical-align:middle;
|
vertical-align:middle;
|
||||||
height:250px
|
height:250px
|
||||||
}
|
}
|
||||||
|
#message {
|
||||||
|
position: absolute;
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
.message_screen {
|
.message_screen {
|
||||||
z-index:-1;
|
z-index:-1;
|
||||||
-ms-filter:"alpha(opacity=0)";
|
-ms-filter:"alpha(opacity=0)";
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
|
|
||||||
settings = {}
|
settings = {}
|
||||||
|
|
||||||
|
# Mozilla Persona service closes on
|
||||||
|
personaEnd = new Date('2016-11-30')
|
||||||
|
|
||||||
claim_wiki = () ->
|
claim_wiki = () ->
|
||||||
# we want to initiate a claim on a wiki
|
# we want to initiate a claim on a wiki
|
||||||
#
|
#
|
||||||
|
@ -115,7 +118,10 @@ setup = (user) ->
|
||||||
dialogHost = settings.wikiHost
|
dialogHost = settings.wikiHost
|
||||||
else
|
else
|
||||||
dialogHost = window.location.host
|
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'
|
settings.relayURL = dialogProtocol + '//' + dialogHost + '/auth/relay.html'
|
||||||
|
|
||||||
update_footer ownerName, isAuthenticated, isOwner
|
update_footer ownerName, isAuthenticated, isOwner
|
||||||
|
|
|
@ -11,10 +11,11 @@
|
||||||
"coffee-script": "1.10",
|
"coffee-script": "1.10",
|
||||||
"lodash": "4",
|
"lodash": "4",
|
||||||
"passport": "^0.3.2",
|
"passport": "^0.3.2",
|
||||||
"passport-twitter": "*",
|
"passport-github": "^1.1.0",
|
||||||
"passport-github": "*",
|
"passport-google-oauth20": "^1.0.0",
|
||||||
"passport-google-oauth20": "*",
|
"passport-twitter": "^1.0.4",
|
||||||
"qs": "6.1"
|
"persona-pass": "^0.2.1",
|
||||||
|
"qs": "^6.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"coffeeify": "*",
|
"coffeeify": "*",
|
||||||
|
|
|
@ -123,7 +123,11 @@ module.exports = exports = (log, loga, argv) ->
|
||||||
|
|
||||||
security.isAuthorized = isAuthorized = (req) ->
|
security.isAuthorized = isAuthorized = (req) ->
|
||||||
if usingPersona
|
if usingPersona
|
||||||
# not added legacy support yet, so...
|
try
|
||||||
|
if req.session.passport.user.email is owner
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
return false
|
return false
|
||||||
else if owner is ''
|
else if owner is ''
|
||||||
# site not claimed?
|
# site not claimed?
|
||||||
|
@ -221,6 +225,18 @@ module.exports = exports = (log, loga, argv) ->
|
||||||
}
|
}
|
||||||
cb(null, profile)))
|
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.initialize())
|
||||||
app.use(passport.session())
|
app.use(passport.session())
|
||||||
|
@ -242,11 +258,16 @@ module.exports = exports = (log, loga, argv) ->
|
||||||
app.get('/auth/google/callback',
|
app.get('/auth/google/callback',
|
||||||
passport.authenticate('google', { successRedirect: '/auth/loginDone', failureRedirect: '/auth/loginDialog'}))
|
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) ->
|
app.get '/auth/client-settings.json', (req, res) ->
|
||||||
# the client needs some information to configure itself
|
# the client needs some information to configure itself
|
||||||
settings = {
|
settings = {
|
||||||
useHttps: useHttps
|
useHttps: useHttps
|
||||||
|
usingPersona: usingPersona
|
||||||
}
|
}
|
||||||
if wikiHost
|
if wikiHost
|
||||||
settings.wikiHost = wikiHost
|
settings.wikiHost = wikiHost
|
||||||
|
@ -258,7 +279,6 @@ module.exports = exports = (log, loga, argv) ->
|
||||||
|
|
||||||
schemeButtons = []
|
schemeButtons = []
|
||||||
_(ids).forEach (scheme) ->
|
_(ids).forEach (scheme) ->
|
||||||
console.log "Scheme: ", scheme
|
|
||||||
switch scheme
|
switch scheme
|
||||||
when "twitter" then schemeButtons.push({button: "<a href='/auth/twitter' class='scheme-button twitter-button'><span>Twitter</span></a>"})
|
when "twitter" then schemeButtons.push({button: "<a href='/auth/twitter' class='scheme-button twitter-button'><span>Twitter</span></a>"})
|
||||||
when "github" then schemeButtons.push({button: "<a href='/auth/github' class='scheme-button github-button'><span>Github</span></a>"})
|
when "github" then schemeButtons.push({button: "<a href='/auth/github' class='scheme-button github-button'><span>Github</span></a>"})
|
||||||
|
@ -276,6 +296,49 @@ module.exports = exports = (log, loga, argv) ->
|
||||||
}
|
}
|
||||||
res.render(path.join(__dirname, '..', 'views', 'securityDialog.html'), info)
|
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: "<a href='#' id='browserid' class='scheme-button persona-button'><span>Persona</span></a>
|
||||||
|
<script>
|
||||||
|
$('#browserid').click(function(){
|
||||||
|
navigator.id.get(function(assertion) {
|
||||||
|
if (assertion) {
|
||||||
|
$('input').val(assertion);
|
||||||
|
$('form').submit();
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>"})
|
||||||
|
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) ->
|
app.get '/auth/loginDone', (req, res) ->
|
||||||
info = {
|
info = {
|
||||||
title: if owner
|
title: if owner
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
|
||||||
|
<title>{{title}}</title>
|
||||||
|
<link id='favicon' href='/favicon.png' rel='icon' type='image/png'>
|
||||||
|
<link rel="stylesheet" href="/security/dialog.css">
|
||||||
|
<script src='/js/jquery-2.2.1.min.js' type='text/javascript'></script>
|
||||||
|
<script src="https://login.persona.org/include.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="content">
|
||||||
|
<div class="wikiinfo">
|
||||||
|
<div class="table">
|
||||||
|
<div class="vertical">
|
||||||
|
<img id="wiki_logo" src="//{{wikiName}}/favicon.png" width="32px" height="32px"></img>
|
||||||
|
<h2 id=wiki_name>{{wikiName}}</h2>
|
||||||
|
<h3 id="wiki_hostname">{{wikiHostName}}</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="signIn">
|
||||||
|
<div class="table">
|
||||||
|
<div class="vertical">
|
||||||
|
<div class="contents">
|
||||||
|
<div class="scheme_section vcenter" style="width: 249px;">
|
||||||
|
<h2>{{loginText}} {{wikiName}} with...</h2>
|
||||||
|
{{#schemes}}
|
||||||
|
<p>{{{button}}}</p>
|
||||||
|
{{/schemes}}
|
||||||
|
{{#if message}}
|
||||||
|
<div id="message">
|
||||||
|
<p>{{message}}</p>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
<span id="footerText">
|
||||||
|
<strong>Federated Wiki.</strong>
|
||||||
|
Sharing ideas through federation.
|
||||||
|
<a href="http://fed.wiki/view/welcome-visitors/view/federated-wiki" target="_blank">Learn more→</a>
|
||||||
|
</span>
|
||||||
|
</footer>
|
||||||
|
<form action="/auth/browserid" method="post" style="display:none;">
|
||||||
|
<input type="text" name="assertion"/>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -27,6 +27,11 @@
|
||||||
{{#schemes}}
|
{{#schemes}}
|
||||||
<p>{{{button}}}</p>
|
<p>{{{button}}}</p>
|
||||||
{{/schemes}}
|
{{/schemes}}
|
||||||
|
{{#if message}}
|
||||||
|
<div id="message">
|
||||||
|
<p>{{message}}</p>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue