• Stars
    star
    294
  • Rank 141,303 (Top 3 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple remoteStorage server written in Node.js

reStore Build Status

CAVEAT EMPTOR

Although it may have been published to the npm repo, this project is still considered experimental. It has not been widely deployed, and I am in the process of rolling it out for personal use and within my company.

As with any alpha-stage storage technology, you MUST expect that it will eat your data and take precautions against this. You SHOULD expect that its APIs and storage schemas will change before it is labelled stable. I MAY respond to bug reports but you MUST NOT expect that I will.

Per the MIT license, usage is entirely at your own risk.

What is this?

reStore RemoteStorage server written for Node.js. It is designed to be compatible with RemoteStorage.js from version 0.6 onwards, covering versions RemoteStorage-2011.10, RemoteStorage-2012.04, and draft-dejong of the protocol.

Installation

$ npm install restore

Usage

The following Node script will run a basic server:

process.umask(077);

var reStore = require('restore'),
    store   = new reStore.FileTree({path: 'path/to/storage'}),
    
    server  = new reStore({
                store:  store,
                http:   {host: '127.0.0.1', port: 8000}
              });

server.boot();

The host option is optional and specifies the hostname the server will listen on. Its default value is 0.0.0.0, meaning it will listen on all interfaces.

The server does not allow users to sign up, out of the box. If you need to allow that, use the allow.signup option:

var server = new reStore({
               store: store,
               http:  {host: '127.0.0.1', port: 8000},
               allow: {signup: true}
             });

If you navigate to http://localhost:8000/ you should then see a sign-up link in the navigation.

Storage security

In production, we recommend that you restrict access to the files managed by your reStore server as much as possible. This is particularly true if you host your storage on a machine with other web applications; you need to protect your files in the event that one of those apps is exploited.

You should take these steps to keep your storage safe:

  • Pick a unique Unix user to run your server process; no other process on the box should run as this user
  • Do not run other applications as root, or as any user that could access files owned by your reStore user
  • Use process.umask(077) as shown above so that the server creates files that can only be accessed by the process's owner
  • Make sure the directory path/to/storage cannot be read, written or executed by anyone but this user
  • Do not run reStore as root; if you need to bind to port 80 or 443 use a reverse proxy like Apache or nginx
  • Ideally, run your storage inside a container or on a dedicated machine

If you're using the Redis backend, apply similar access restrictions to the database and to any files containing the database access credentials.

Serving over HTTPS

Since RemoteStorage is a system for storing arbitrary user-specific data, and since it makes use of OAuth 2.0, we recommend you serve it over a secure connection. You can boot the server to listen for HTTP or HTTPS requests or both. This configuration boots the app on two ports, one secure and one plaintext:

var server = new reStore({
  store:  store,
  http:   {
    host: '127.0.0.1',
    port: 8000
  },
  https:  {
    force:  true,
    host:   '127.0.0.1',
    port:   4343,
    key:    'path/to/ssl.key',
    cert:   'path/to/ssl.crt',
    ca:     'path/to/ca.pem'    // optional
  }
});

server.boot();

Note that you should not run reStore as root. To make it available via port 80 or 443, use Apache, nginx or another reverse proxy.

The force: true line in the https section means the app will:

  • Return HTTPS URLs in WebFinger responses
  • Force sign-up and OAuth login pages onto an HTTPS connection
  • Refuse to process POST authentication requests over insecure connections
  • Block insecure storage requests and revoke the client's access

reStore considers a request to be secure if:

  • reStore itself acts as an SSL terminator and the connection to it is encrypted
  • The X-Forwarded-SSL header has the value on
  • The X-Forwarded-Proto header has the value https
  • The X-Forwarded-Scheme header has the value https

So you can have an SSL-terminating proxy in front of reStore as long as it sets one of those headers, and does not let external clients set them. In this setup, you can set https.force = true but omit https.port; this means reStore itself will not accept encrypted connections but will apply the above behaviour to enforce secure connections.

Storage backends

reStore supports pluggable storage backends, and comes with two implementations out of the box:

  • reStore.FileTree - Uses the filesystem hierarchy and stores each item in its own individual file. Content and metadata are stored in separate files so the content does not need base64-encoding and can be hand-edited. Must only be run using a single server process.
  • reStore.Redis - Stores data in a Redis database, and all stored data is base64-encoded. It can be run with any number of server processes.

All the backends support the same set of features, including the ability to store arbitrary binary data with content types and modification times.

They are configured as follows:

// To use the file tree store:
var store = new reStore.FileTree({path: 'path/to/storage'});

// To use the Redis store:
var store = new reStore.Redis({
  host:     'redis.example.com',    // default is 'localhost'
  port:     1234,                   // default is 6379
  database: 2,                      // default is 0
  password: 'unhosted'              // default is no password
});

// Then create the server with your store:
var server = new reStore({
                store:  store,
                http:   {port: process.argv[2]}
              });

server.boot();

License

(The MIT License)

Copyright (c) 2012-2015 James Coglan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

sylvester

Vector, matrix and geometry math JavaScript
JavaScript
1,141
star
2

jsclass

Implementation of the core of Ruby's object system in JavaScript.
JavaScript
509
star
3

vault

Generates safe passwords so you never need to remember them
JavaScript
471
star
4

canopy

A parser compiler for Java, JavaScript, Python, Ruby
JavaScript
418
star
5

heist

Scheme in as little Ruby and as much Scheme as possible. Supports macros, continuations, tail recursion and lazy evaluation.
Ruby
364
star
6

terminus

Capybara driver written mostly in client-side JavaScript for cross-browser automation
JavaScript
179
star
7

jit

The information manager from London
Ruby
172
star
8

fargo

Lisp with fibers for Node.js
JavaScript
157
star
9

eventful

Because Ruby's Observable never does quite what I want
Ruby
125
star
10

siren

JSON parser that understands cross-references and casts to typed Ruby objects. Implements JSONQuery against JSON trees and Ruby object graphs.
Ruby
116
star
11

bake

How to make a book
XSLT
99
star
12

primer

Intelligent caching, no observers necessary
Ruby
89
star
13

nand2tetris

Solutions for http://www.nand2tetris.org/
Assembly
87
star
14

jake

Builds JavaScript projects using PackR and ERB
Ruby
78
star
15

svn2git

Ruby tool for importing existing svn projects into git and github.
Ruby
71
star
16

packr

Ruby version of Dean Edwards' Packer
Ruby
65
star
17

consent

Access control layer for ActionPack, providing a DSL for writing a firewall to sit in front of Rails controllers
Ruby
52
star
18

bluff

JavaScript implementation of topfunky's Gruff graphing library
JavaScript
42
star
19

coping

An experimental type-safe/context-aware templating library
Ruby
41
star
20

unsafe_sjr

Demo of unsafe SJR in Rails
Ruby
39
star
21

jstest

The cross-platform JavaScript test framework
JavaScript
38
star
22

node-csprng

Secure random numbers of any size in any base
JavaScript
36
star
23

wake

A build tool for web stuff
JavaScript
29
star
24

rspec-eventmachine

RSpec extensions for testing EventMachine code
Ruby
26
star
25

lisp-dojo

Dojo designed to introduce interpreter writing
Ruby
24
star
26

stickup

Tiny Scheme interpreter, suitable for use as a livecoded demo
Ruby
23
star
27

kanrens

Various implementations of microKanren
JavaScript
19
star
28

oyster

Command-line input parser that doesn't hate you
Ruby
16
star
29

action_flow

Specify request sequences in Rails
Ruby
14
star
30

tnt

Proof assistant for Typographical Number Theory
JavaScript
14
star
31

infer

Interpreter for inference rules
Ruby
13
star
32

yui

Mirror of YUI releases back to 2.2.2
JavaScript
10
star
33

3s

Small Subset of Scheme
JavaScript
9
star
34

vault-cipher

High-level authenticated encryption API used by Vault
JavaScript
9
star
35

toml

Cross-platform JavaScript TOML parser
JavaScript
9
star
36

faye-cookie-auth

Ruby
8
star
37

js-loader-examples

JavaScript
8
star
38

js-test-examples

How to run JS tests using various frameworks on different platforms
JavaScript
8
star
39

birdie

Sinatra app for making portfolio sites
Ruby
8
star
40

acceptance

Reflect on your Rails validations and generate JavaScript from them
Ruby
8
star
41

dotfiles

Vim Script
8
star
42

storeroom

Portable encrypted storage for JavaScript apps
JavaScript
8
star
43

corrode

Rust
8
star
44

lemonga.rb

just a harmless prank... for laughs
Ruby
7
star
45

nicod

Experimental logic programming system, written in Rust
Rust
7
star
46

classy_inputs

Adds type-reflecting class names to input tags in Rails
Ruby
7
star
47

remotestorage-oauth

Node.js library for getting authorization from remoteStorage servers
JavaScript
7
star
48

presentations

Slides for JavaScript talks
Ruby
7
star
49

burn-your-getters

CSS
7
star
50

has_password

Simple password-hashing abstraction for Rails models
Ruby
6
star
51

soundcloud.js

SoundCloud API wrapper for client-side JavaScript
JavaScript
6
star
52

is-sandwich

Tells you whether a thing is a sandwich
JavaScript
5
star
53

frp-irc

JavaScript
5
star
54

attr_locked

Allows you to stop ActiveRecord fields changing after an object is first created
Ruby
5
star
55

pathology

The goggles: they do nothing.
JavaScript
5
star
56

acceptance-old

A port of Ojay.Forms to Prototype, with a Rails plugin to generate client-side validation code
JavaScript
5
star
57

outcast

Music Hack Day project: broadcast your iTunes library to others over the web
JavaScript
5
star
58

york

Jekyll plugin for writing about programming
Ruby
5
star
59

jsapp

JavaScript
4
star
60

frippery

Functional streams for JavaScript
JavaScript
4
star
61

reading-and-writing

Ruby
4
star
62

mu_trumps

Cannes Midem MHD project
Ruby
4
star
63

socknet

TCP over WebSockets
JavaScript
4
star
64

jsbuild

Build tool for the JS.Package dependency system
JavaScript
4
star
65

wake-assets-ruby

Ruby HTML helper for assets managed by wake
Ruby
4
star
66

cuke-web

Browse, search and run your cukes from your browser
JavaScript
4
star
67

include_by_default

Specifies that associations should be included automatically with find() calls in ActiveRecord
Ruby
4
star
68

acts_as_uploaded

File upload plugin for Rails models
Ruby
3
star
69

toledo

JavaScript
3
star
70

pinpoint

Map location editing widget, based on Ojay and Google Maps
JavaScript
3
star
71

poker

Poker simulator for learning stats
JavaScript
3
star
72

jsmod

JavaScript
3
star
73

wake-assets-python

Python HTML helper for assets managed by wake
Python
3
star
74

reiterate

Extension for Prototype that adds syntactic sugar to Enumerable methods
JavaScript
3
star
75

jsdom-example

JavaScript
3
star
76

sequin

Generate uniformly distributed ints in any base from a bit sequence
JavaScript
3
star
77

rustlings

Rust
3
star
78

scheme-dojo

Little exercises to get familiar with Scheme and recursion
Scheme
2
star
79

holly

JavaScript and CSS dependency manager for Rails projects
Ruby
2
star
80

everything

Mini-app to display random entries from Wikipedia
Ruby
2
star
81

fowd-js-testing

Demo application with JavaScript tests
JavaScript
2
star
82

recurse-lisp-workshop

Python
2
star
83

parsing-techniques

Ruby
2
star
84

george

Like vimtutor, with additional hot beverages
Ruby
2
star
85

ruby-pci

Ruby implementations of algorithms from 'Programming Collective Intelligence'
Ruby
2
star
86

bmc

Web app collecting data on journalistic accuracy
Ruby
2
star
87

guardian-politics

Prototypal Ruby client for the Guardian Politics API
Ruby
1
star
88

rust-os

Following along with https://os.phil-opp.com/
Rust
1
star
89

jstest-phantomjs

How to run JS.Test on PhantomJS
JavaScript
1
star
90

dlt

Prototype archive format and version control system
Ruby
1
star
91

horrorshow

Experiment involving JavaScript and Ruby
Ruby
1
star
92

skwizzes

Solutions to Songkick quiz problems
Ruby
1
star
93

zairecma

Music Hack Day project, SF 2011
JavaScript
1
star
94

gramophone

Listen to neighbourhoods from the past
JavaScript
1
star
95

claw

Command-line tool for searching and opening files
Ruby
1
star
96

npm-problem

I haz a problem.
JavaScript
1
star
97

cuke-macros

Experiment wherein Cucumber features are rewritten using Scheme
Ruby
1
star
98

terminus-rails

Ruby
1
star
99

ci_search

Rails implementation of search engine from 'Programming Collective Intelligence'
Ruby
1
star