
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
flatiron-persona
Advanced tools
Broadway plugin for user authentication using Mozilla Persona
Get it with:
npm install flatiron-persona
# app.coffee
flatiron = require 'flatiron'
persona = require 'flatiron-persona'
connect = require "connect"
app = flatiron.app;
app.use flatiron.plugins.http
app.use persona, audience: "http://example.com/"
# You need session. Session needs cookieParser. So:
app.http.before.push do connect.cookieParser
app.http.before.push connect.session secret: "
Kiedy nikogo nie ma w domu, Katiusza maluje pazury na zielono i śmieje się po cichu do lustra. To prawda!"
app.start 4000;
If you use Creamer like I do, that's what your views/layout.coffee
might look like:
module.exports = ->
###
If user is logged in @session.username will be set to his e-mail address.
Let's make a convenient shortcut.
###
if @session?.username? then @username = @session.username
doctype 5
html ->
head ->
title "Persona authentication demo"
meta charset: "utf-8"
meta "http-equiv": "X-UA-Compatible", content: "IE=Edge"
script src: "https://login.persona.org/include.js"
# I'll use jquery here. You don't have to.
script src: "http://code.jquery.com/jquery-1.9.1.min.js"
script src: "http://code.jquery.com/jquery-migrate-1.1.1.min.js"
# data-username indicates that user is logged in - see below. Again, you can take different approach.
body "data-username": @username, ->
header ->
h1 "Persona authentication demo"
unless @username # if not logged in...
a {
id: "signin"
href: "#"
class: "persona-button dark"
}, -> span "Log in"
else
a {
id: "signout"
href: "#"
class: "persona-button blue"
}, -> span "Logout #{@username}"
section id: "main", ->
do content
footer ->
p "A juicy footer is here as well :)"
coffeescript ->
($ document).ready ->
# That's why we had to set data-username on body - this script will be compiled into JS and won't have access to outside variables like @session.
username = ($ "body").data "username" ? null
if username then console.log "Logged in as #{username}"
else console.log "Not logged in (yet?)"
# Now goes Persona stuff, see https://developer.mozilla.org/en-US/docs/Persona/Quick_Setup
navigator.id.watch {
loggedInUser: username
onlogin : (assertion) ->
console.log "Logging in..."
$.ajax {
type : "POST"
url : "/auth/login"
data :
assertion : assertion
success : -> do window.location.reload
error : (xhr, status, error) ->
console.dir xhr
do navigator.id.logout
}
onlogout : ->
console.log "Logging out..."
$.ajax {
type : "POST"
url : "/auth/logout"
success : -> do window.location.reload
error : (xhr, status, error) -> console.error "Logout failed: #{error}"
}
}
($ "#signin").click -> do navigator.id.request
($ "#signout").click -> do navigator.id.logout
When calling app.use persona you can provide following options:
FAQs
Flatiron plugin for user authentication with Mozilla Persona
The npm package flatiron-persona receives a total of 0 weekly downloads. As such, flatiron-persona popularity was classified as not popular.
We found that flatiron-persona demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.