This repository has been archived by the owner. It is now read-only.
Deprecated. Meteor package for SAML authentication, built for Brown University.
Switch branches/tags
Clone or download
Pull request Compare This branch is 47 commits ahead of ritstudentgovernment:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
client
server
.gitignore
.versions
LICENSE
README.md
package.js

README.md

accounts-saml2 is no longer used by SignMeUp in production, deprecated in favor of Google login. If you would like to take on maintenance, please email signmeup-dev@lists.cs.brown.edu.

accounts-saml2

This Meteor package implements SAML2 authentication. It is a wrapper for the node passport-saml module. It provides middleware routes for processing login, callback, and metadata requests.

Install

meteor add athyuttamre:accounts-saml2

Setup

1. Meteor Setup

To get SAML authentication working on your local machine, you need three things:

  1. Run Meteor on SSL using nourhardy:ssl or an nginx proxy.
  2. If developing for Brown University, add an entry to your computer's hosts file for 127.0.0.1 to local.cis-dev.brown.edu. Also make sure SSL is running on port 3000; your app can run on any other port, such as 3100.
  3. Add the settings below to settings.json.

Finally, run your app so: meteor --settings settings.json --port 3100, and navigate to https://local.cis-dev.brown.edu:3000 in an incognito window. It's important to run this in a private window so that you can debug your login session. Right now, logout isn't supported.

Couple of tips to help you debug:

  • Monitor the Network tab within Chrome Developer Tools as you go through the login flow. Make sure Preserve Logs is checked; this way logs persist even after redirects.
  • Use http://samltools.com/decode.php to read the values of SAMLRequest and SAMLResponse, the two pieces of information that'll be sent around during these redirects. You can read the values from the Network tab above.

2. Package Setup

For the package itself, supply passport-saml SAML properties in the Meteor settings.json like so:

"saml": {
  "loginUrl": "/login",
  "protocol": "https",
  "host": "local.cis-dev.brown.edu:3000",
  "path": "/login/callback",
  "entryPoint": "https://sso.brown.edu/idp/profile/SAML2/Redirect/SSO",
  "issuer": "https://local.cis-dev.brown.edu/shibboleth-sp",
  "cert": "INSERT-IDP-CERT-HERE",
  "serviceProviderCert": "INSERT-SELF-SIGNED-CERT-HERE",
  "decryptionPvk": "INSERT-SELF-SIGNED-KEY-HERE",
  "identifierFormat": "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
  "disableRequestedAuthnContext": true,
  "metadataUrl": "/metadata",
  "attributeMap": {
    "urn:oid:1.3.6.1.4.1.6537.1.68": "brownAdvanceId",
    "https://www.brown.edu/shibboleth/attributes/brownAuthenticationProfiles": "brownAuthenticationProfiles",
    "urn:oid:1.3.6.1.4.1.6537.1.16": "brownBannerID",
    "urn:oid:1.3.6.1.4.1.6537.1.13": "brownBruID",
    "urn:oid:1.3.6.1.4.1.6537.1.14": "brownNetID",
    "urn:oid:1.3.6.1.4.1.6537.1.15": "brownShortID",
    "urn:oid:1.3.6.1.4.1.6537.1.25": "brownStatus",
    "urn:oid:1.3.6.1.4.1.6537.1.28": "brownType",
    "urn:oid:1.3.6.1.4.1.6537.1.19": "brownUUID",
    "urn:oid:1.3.6.1.4.1.5923.1.1.1.7": "eduPersonEntitlement",
    "urn:oid:1.3.6.1.4.1.5923.1.1.1.9": "eduPersonScopedAffiliation",
    "urn:oid:1.3.6.1.4.1.5923.1.5.1.1": "isMemberOf",
    "urn:oid:1.3.6.1.4.1.6537.1.63": "machineID"
  }
}

Specify your callbackUrl in parts as protocol, host, and path. For all other URLs, specify relative paths beginning with a /. For files, inline the values.

Unfortunately, there isn't a clean way to read files from within a Package. Options include using Node's fs, or the app reading the file and passing to the package. The Assets API isn't available i.e. packages can't read user assets. For more discussion, see this issue. For a hacky fix, see this piece of code.

There are extra (non passport-saml) options that be provided. They are:

  • serviceProviderCert: Path to the Service Provider certificate file.
  • metadataUrl: URL which metadata can be read from.

See the Usage section of passport-saml documentation for options that can be specified.

Usage

In your app, add a button or link to initiate login, for example <a href="#" class="login">Login</a>. Then, add the following click handler to your template:

"click .login": function() {
  Meteor.loginWithSaml(function() {
    console.log("Welcome " + Meteor.user().profile.givenName + "!");
  });
}

To login with a redirect (instead of a popup), specify options like so:

"click .login-with-redirect": function() {
  Meteor.loginWithSaml({loginStyle: "redirect"}, function() {
    console.log("Welcome " + Meteor.user().profile.givenName + "!");
  });
}

Notes

This package gets the user's SAML attributes and stores them in the User object's profile. This is by default writable by the user themselves. Add a deny rule to the Users collection to avoid this.

Acknowledgements

Peter Mikitsh for the original version and Sumner Warren for very many contributions.