Code Monkey home page Code Monkey logo

browserid-local-verify's Introduction

Build Status

A node.js BrowserID verification library

This repository contains a node.js library for local verification of BrowserID assertions. It is used by this standalone verifier.

The library has the following scope and features:

  • authoritative domain lookup - given a domain, follow the browserid standard to resolve it (following authority delagation) into the ultimatly responsible domain and its public key.
  • .well-known document parsing
  • (multiple) secondary IdP support - The library can be initialized with a set of trusted "fallback IdPs" that are considered authoritative when lookup fails (no support document can be found).
  • external HTTP implementation - You can use node.js's http implementation, or override it and support your own (useful for HTTP proxied environments)
  • command line tools - all of these features are exposed via command line tools for manual inspection of domain's persona configuration.
  • assertion verification - the features above all fuel a simple yet flexible API for local verification of assertions.

Alternatives

This library is targeted at robust local verification, to subsume all of the features required by mozilla's implementation of assertion verification in Persona. If you're looking for a clean and simple library appropriate for website use (using the verifier hosted by persona), see browserid-verify.

USAGE

npm install browserid-local-verify

(simple) verifying an assertion

var browserid = require('browserid-local-verify');

browserid.verify({
  assertion: assertion,
  audience:  "http://example.com"
}, function(err, details) {
  console.log(details);
});

looking up an authority for a domain

var browserid = require('browserid-local-verify');

browserid.lookup({
  domain: "mozilla.org"
}, function(err, details) {
  // check err
  console.log(details.authority);
  console.log(details.pubKey);
  console.log(details.delegationChain);
});

configuration

All functions accept configuration parameters documented below.

browserid.lookup({
  httpTimeout: 5.0,
  domain: "mozilla.org"
}, function(err, details) {
  ...
});

Or you can allocate a library instance. This allows you to specify configuration once at instantiation time. Any configuration parameters or function arguments may be specified a instantiation time and become the default for subsequently invoked functions:

var BrowserID = require('browserid-local-verify');

var b = new BrowserID({ httpTimeout: 20.0 });
b.lookup({ domain: "mozilla.org" }, function(err, details) {
  // ...
});

Configuration and Arguments

Common Arguments

  • httpRequest: A function that allows the client to control how http requests are performed.
    • input arguments: (domain, path, callback)
    • callback argbuments: (err, statusCode, headers, body)
  • httpTimeout: How long in seconds we should wait for a response when looking up a well-known document over HTTP. (default: 10)
  • maxDelegations: How many times authority may be delegated.
  • insecureSSL: When true, invalid SSL certificates are ignored (NEVER use this in production).
  • fallback: A domain that is authoritative when support document lookup fails for the prinicpal email address's domain.

lookup specific

  • domain: the domain for which we should lookup the support document
  • principalDomain: the domain of the email address for which we should discover the support document of the authority

verification specific

  • now: override the current time for purposes of assertion verification. (useful for testing)
  • assertion: the assertion to verify
  • audience: the expected assertion audience
  • trustedIssuers: An array of domains that will be trusted to vouch for any identity, regardless of the authority as determined from the email addresses domain.

debug output and metrics

The BrowserID class emits events:

var b = new BrowserID();

b.on('debug', function(msg) {
  console.log('debug output:', msg);
});

b.on('metric', function(metric, value) {
  console.log(metric + ":", value);
});

b.lookup("mozilla.org", function(err, details) {
  // ...
});

browserid-local-verify's People

Contributors

dannycoates avatar fmarier avatar lloyd avatar mozilla-github-standards avatar rfk avatar seanmonstar avatar vladikoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

browserid-local-verify's Issues

testing of events

We should write an automated test to ensure we don't regress on events emitted, especially the important ones (metrics).

improved api

distinguis between config and arguments. Allow a single library instance to have over-ridden configuration parameters. verify all required paramters are present.

nsp advisory 1488 (acorn DoS via browserid-crypto)

Seeing this in our fxa browserid-verifier package npm audit results today:

┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate      │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ acorn                                                        │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=7.1.1                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ browserid-local-verify                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ browserid-local-verify > browserid-crypto > browserify >     │
│               │ module-deps > detective > acorn                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://npmjs.com/advisories/1488                            │
└───────────────┴──────────────────────────────────────────────────────────────┘

Support larger DSA keys

If a user agent has enough power to generate and use larger DSA keys (e.g. native Persona support in Firefox desktop), then the verifier should honour them.

What needs to happen:

  • add support for larger DSA keys in jwcrypto
  • add support for larger DSA keys in the verifier library

/cc @warner

write (t)ests to (d)rive (d)evelopment

  • rsa: RSA various lengths: verify a properly formulated assertion from a supported secondary
  • dsa: DSA various lengths: verify a properly formulated assertion from a supported secondary
  • assertion verification: basic IdP / Fallback issued assertions should verify
  • secondaries: verify failure of an assertion from an unsupported secondary
  • time checking: expired or future issued assertions and certificates should be detected
  • domain authority: a fallback may not speak for a domain that supports persona (in the absence of trustedIssuers)
  • audience-matching: audience matching tests
  • lookup: using built in HTTP
  • lookup: over-riding request function
  • lookup: HTTP redirect handling
  • lookup: HTTP timeout
  • delegation: too many redirects
  • delegation: cycle detection
  • delegation: basic success case
  • well-known: malformed public key
  • well-known: missing required fields
  • well-known: parsing disabled: true
  • regression: regression tests from a set of assertions issued in the past
  • domain GET param: should always pass in domain= get param for dynamic well-knowns (required for bridging support)
  • idp-claims: extraction of idp custom extensions - new fields like uid
  • unverified email: (specific case of idp-claims) test to prove the library is flexible enough to support an extension like unverified-email

Defend against hostile IdPs with too many keys

If an IdP wanted to DoS a verifier, it could for example provide 1000 pubkeys and therefore significantly increase the time it takes a verifier to check the signature on an assertion.

I suggest we defend against these attacks by only looking at the first 10 keys.

remove support for poorly behaved fallback

current persona fallback likes to serve a support document without authenticate and provisioning keys. We support this to allow zero-knowledge local verification external to the persona deployment. allowURLOmission is the parameter that implements this.

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please reach out to [email protected].

(Message COC001)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.