peerlibrary/meteor-accounts-sandstorm

Name: meteor-accounts-sandstorm

Owner: PeerLibrary

Description: Sandstorm.io login integration for Meteor applications.

Forked from: sandstorm-io/meteor-accounts-sandstorm

Created: 2016-04-18 03:56:29.0

Updated: 2016-10-12 17:00:24.0

Pushed: 2016-03-14 11:36:07.0

Homepage: null

Size: 28

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Sandstorm.io login integration for Meteor.js

Sandstorm is a platform for personal clouds that makes installing apps to your personal server as easy as installing apps to your phone.

Meteor is a revolutionary web app framework. Sandstorm's own UI is built using Meteor, and Meteor is also a great way to build Sandstorm apps.

This package is meant to be used by Meteor apps built to run on Sandstorm. It integrates with Sandstorm's built-in login system to log the user in automatically when they open the app. The user's profile.name will be populated from Sandstorm. When using this package, you should not use accounts-ui at all; just let login happen automatically.

To use this package in your Meteor project, simply install it from the Meteor package repository:

meteor add kenton:accounts-sandstorm

To package a Meteor app for Sandstorm, use the meteor-spk tool.

Usage

Either of these will return an object containing the following fields:

See the Sandstorm docs for more information about these fields.

Note that sandstormUser() may return null on the client side if the login handshake has not completed yet (Meteor.loggingIn() returns true during this time). It never returns null on the server, but it may throw an exception if the client skipped the authentication handshake (which indicates the client is not running accounts-sandstorm, which is rather suspicious!).

Synchronization with Meteor Accounts

accounts-sandstorm does NOT require accounts-base. However, if you do include accounts-base in your dependencies, then accounts-sandstorm will integrate with it in order to store information about users seen previously. In particular:

Please note, however, that you should prefer sandstormUser() over Meteor.user().services.sandstorm whenever possible, especially for enforcing permissions, for a few reasons:

Development aids

accounts-sandstorm normally works its magic when running inside Sandstorm. However, it's often a lot more convenient to develop Meteor apps using Meteor's normal dev tools which currently cannot run inside Sandstorm.

Therefore, when not running inside Sansdtorm, you may use the following console function to fake your user information:

SandstormAccounts.setTestUserInfo({
  id: "12345",
  name: "Alice",
  // ... other parameters, as listed above ...
});

This will cause accounts-sandstorm to spoof the X-Sandstorm-* headers with the parameters you provided when it attempts to log in. When actually running inside Sandstorm, such spoofing is blocked by Sandstorm, but when running outside it will work and now you can test your app.

Migrating from 0.1

In version 0.1.x of this puackage, there was no sandstormUser() function; the only mode of operation was through Meteor accounts. This had problems with permissions and anonymous users as described adove. Introducing sandstormUser() is a huge update.

For almost all users, 0.2 should be a drop-in replacement for 0.1, only adding new features. Please note, though, two possible issues:


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.