Services/Sync/Server/Archived/0.3/Setup

From MozillaWiki
Jump to navigation Jump to search

Pre-Setup Considerations

It is strongly recommended that the Weave Server be set up under https, or behind a firewall with an https proxy in front of it, especially if you are planning to use Apache basic authorization for access control.

The Weave Server requires PHP with PDO and JSON support installed. This should be the case if you are running PHP 5.1+. PDO will need drivers for whatever storage and authentications engines are used.

Setting up the Server

1) Unzip the weave_server.zip directory into the location you plan to serve the files from.

3) Edit your apache conf files to add the following:

Alias /weave/0.3 <full path to weave directory>/index.php


Setting up Weave Authentication

Add the following to your apache conf:

SetEnv WEAVE_AUTH_ENGINE [sqlite|mysql|none]

Sqlite

Add the following parameter to your apache conf:

SetEnv WEAVE_SQLITE_AUTH_DIRECTORY <path to stores directory>

additionally, under the same user as your apache, create the users table

$ sqlite3 <path to stores directory>/_users
SQLite version 3.4.0
sqlite> create table users (username text primary key, md5 text);
sqlite> .quit

Mysql

Create the mysql database. Add the following tables:

create table users 
(
 username varchar(32) primary key, 
 md5 varchar(32)
) engine=InnoDB;

Edit your apache conf files to add the following:

SetEnv WEAVE_MYSQL_AUTH_HOST <db host>
SetEnv WEAVE_MYSQL_AUTH_DB <db name>
SetEnv WEAVE_MYSQL_AUTH_USER <db username>
SetEnv WEAVE_MYSQL_AUTH_PASS <db password>

Setting up Weave Storage

Add the following to your apache conf:

SetEnv WEAVE_STORAGE_ENGINE [sqlite|mysql]

Sqlite

Add the following parameter to your apache conf:

SetEnv WEAVE_SQLITE_STORE_DIRECTORY <path to stores directory>

To create a user db, run the following php code:

<?php
  putenv(WEAVE_SQLITE_STORE_DIRECTORY, $your_path);
  $db = new WeaveStorageMysql($username, $auth_obj->get_connection());
  $db->create_user($username);
?>

Mysql

Create the mysql database. Add the following tables:

create table wbo
(
 username varchar(32),
 collection varchar(64),
 id varchar(64),
 parentid varchar(64),
 encryption text,
 modified float,
 encoding varchar(16),
 payload text,
 primary key(username, collection, id),
 index parentindex(username, collection, parentid),
 index modified(username, collection, modified)
) engine=InnoDB;


Edit your apache conf files to add the following:

SetEnv WEAVE_MYSQL_STORE_HOST <db host>
SetEnv WEAVE_MYSQL_STORE_DB <db name>
SetEnv WEAVE_MYSQL_STORE_USER <db username>
SetEnv WEAVE_MYSQL_STORE_PASS <db password>

Optional Apache Parameters

SetEnv WEAVE_USER_MATCH_READ 1

Requires the http-authenticated user to match the name of the user in the path in order to read from the store (recommended)

SetEnv WEAVE_USER_MATCH_WRITE 1

Requires the http-authenticated user to match the name of the user in the path in order to write to the store (recommended)

SetEnv WEAVE_SHARE_DBH 1

If both the storage engine and authentication engine are using the same database, setting this makes both engines use the same database handler rather than opening different ones. Note that SQLite cannot use the same db for authentication and storage.

Setting up Weave Admin

You can create, update passwords and delete users through the Server Admin API.

Add the following to your apache conf:

Alias /weave/admin <path to the admin.php script>

Due to the security concerns, this script should be additionally protected, either through denying most IPs, or using htaccess. Additionally, the following envronment variable, if set, is required to be passed in for all transactions to the server:

SetEnv WEAVE_USER_ADMIN_SECRET <secret>

The admin interface requires post, and accepts the following parameters:

Parameter Description
function update|delete]
username The username to be operated on.
password Required if creating a user or changing the password
secret The secret, if one has been required by WEAVE_USER_ADMIN_SECRET }

Testing the Weave Server

The load_data.pl script will run a series of tests against your server, creating, modifying, selecting from and deleting a collection. Make sure to change the parameters at the top before running it. Also, the script requires the libwww-perl module.