
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
express-persona-observer
Advanced tools
Opinionated Mozilla Persona Observer API authentication for your Express application
Opinionated Mozilla Persona integration for Express. express-persona-observer adds functionality to express-persona to make integration of Persona using its Observer API even more seamless.
Install using npm: npm install express-persona-observer
Include the module inside your Express application:
var express = require("express");
var persona = require("express-persona-observer");
var app = express();
app.use(express.json());
app.use(express.urlencoded());
app.use(express.cookieParser());
app.use(express.session({
secret: "mozillapersonaiswatchingyou"
}));
persona.express(app, {
audience: "http://localhost:8888" // Must match your browser's address bar
});
Include the Persona library and login script in your web pages:
<script src="https://login.persona.org/include.js"></script>
<script src="/persona/login.js"></script>
or
<script src="https://login.persona.org/include.js"></script>
<script src="{{loginScriptUrl}}"></script>
if you're using a templating engine.
Add login and logout buttons to your page:
<button id="login">Log In</button>
<button id="logout">Log Out</button>
Like express-persona, by default the user's email address is added to req.session.email
when their email is validated.
You can view and run a complete example in the examples directory.
express-persona-observer
provides both the server and client-side code to integrate Persona
into your express application, with sensible defaults so it works right out of the box. Additionally,
it provides several useful route middleware methods, request methods, and application locals to take the
pain out of writing Persona-based applications.
ensureLoggedIn([path])
- errors or redirects if a user is not logged in
path
is an optional string specifying a redirect path; if omitted next()
will be called with an error
unless a default redirect path has been specified as an option to express()
ensureLoggedOut([path])
- errors or redirects if a user is logged in
path
is an optional string specifying a redirect path; if omitted next()
will be called with an error
unless a default redirect path has been specified as an option to express()
fromLoggedInUser
- returns true if the request session includes a userloggedInUser
- logged in user email, or nullloginScriptUrl
- path to login.js
express(app, options)
app
is an instance of the express server that you want to add routes to.options
is an object. It has one required parameter, audience
.audience
- The URL of your express app when viewed in a browser. Must include the protocol, hostname, and port.
http://example.org:80
, https://example.org:443
express-persona-observer
supports all express-persona
options.syncResponse(req, res, next)
- Response handler when your app needs to synchronize its session with Persona.
req, res, next
are the typical express middleware callback argumentslogin.js
, which handles synchronization with Persona. The path will then
be reloaded automatically.loginjsPath
- Path at which login.js
will be hosted.
/persona/login.js
redirects
- object containing default redirects for route middleware methods
notLoggedIn
- string specifying default redirect path for ensureLoggedIn
notLoggedOut
- string specifying default redirect path for ensureLoggedOut
exemptPaths
- an array of strings specifying paths that are exempt from synchronizationselectors
- object containing login and logout button selectors
#login
#logout
Tests can be run with npm test
. Test coverage can be generated with node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -R spec test/*.test.js
.
FAQs
Opinionated Mozilla Persona Observer API authentication for your Express application
We found that express-persona-observer 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.