CloudServices/WheresMyFox: Difference between revisions
(→API) |
|||
Line 153: | Line 153: | ||
A successful response will be formatted: | A successful response will be formatted: | ||
"<device command>":{"ok": "true", <additional response values>} | <pre>"<device command>":{"ok": "true", <additional response values>}</pre> | ||
If one of the commands results in an error, the response for that command is | If one of the commands results in an error, the response for that command is | ||
"<device comman>":{"ok": "false", "error": "<error details>"} | <pre>"<device comman>":{"ok": "false", "error": "<error details>"}</pre> | ||
See <i>Device commands</i> for | See <i>Device commands</i> for |
Revision as of 22:49, 2 December 2013
Where's My Fox
Overview
To provide a means for users to locate, track and purge devices remotely.
Project Contacts
Principal Point of Contact - Doug Turner dougt@mozilla.com
Product - vishy@, elancaster@
IRC - #services-dev
Group Email - TBD
Goals
- Be able to provide a simple, secure means for FirefoxOS users to remotely locate, track and purge their devices.
Use Cases
1) Albert can't remember the location of his phone. Going to a nearby computer, he logs into WheresMyFox and requests the phone to report it's location. The phone reports that it is nearby, so Albert requests the device to ring. Albert quickly finds that his phone is in his coat pocket.
2) Bea discovers that her phone is missing. Using a friends phone, she logs into WheresMyFox and requests the phone to report it's location. She discovers that the phone is currently headed down Broadway, and realizes she has left it in the cab. Realizing that she may never see her phone again, she requests the phone to remotely wipe itself, before calling the cab agency to see if she can recover her device.
Requirements
- The user must use a secure credentialing and authorization system to identify self and associate to a device.
- The login system is currently Out of Scope of these requirements, but should be or substantially similar to Firefox Accounts.
- A user may have one or more devices.
- A device shall have a Globally Unique Identifier (WTFID).
- A device shall be associated with a single user.
- Data exchanged between client and server shall be via JSON Web Signature format
- The secret shall be generated and stored on the client, and sent to the server ONLY on initialization.
- The secret shall be a 128bit value.
- The secret shall be stored on the device as long as the WTFID remains unchanged.
- A new WTFID shall require a new secret to be generated and the device to reconnect as if new.
- No data shall be preserved in the case of a WTFID changing.
- Data signatures shall use HMAC SHA-256 or any more secure signing method for any exchange EXCEPT for Initialization.
- The secret shall be generated and stored on the client, and sent to the server ONLY on initialization.
- A remote wipe operation will format any additional storage (e.g. SD card) on the phone and reset the phone to initial Factory conditions.
- Only allow registered user to display and remotely control devices.
- Login and user authorization is delegated to Persona/FirefoxAccounts
- Control panel is secured by https and session cookie.
- Control panel shall securely send commands to:
- report location on a regular interval (for motion tracking)
- record tracking information keeping latest location for device
- Tracking records expire after 10 minutes, with the exception of the last reported location.
- Last reported location does not expire.
- play a default audio alarm.
- Alarm will repeatedly play for a user specified period of seconds
- lock a device
- Allow a user to specify a key code if not already present on the device.
- display an optional message
- Messages shall be less than 100 non-control ASCII characters
- remove all user information from a device by performing a factory reset
- report location on a regular interval (for motion tracking)
- Securely display web based UI for device including
- current location
- previously recv'd locations, provided they are different than latest location.
- Allow multiple devices per user.
- How long to store data?
Get Involved
Call to action for folks who want to help.
Design
Points of Contact
Engineer - Name jr@
Discussions
https://etherpad.mozilla.org/wheresmyfox-2013-10-28
Client API Reference/Documentation
Client UX was presented by Epic:
https://www.dropbox.com/sh/uaxlhzz211br438/rH2UA0Tf6_/WIMF_3.0.pdf
Server API Reference/Documentation
API calls will be a combination of REST calls and BOSH where possible. This avoids some of the issues with the fragility of websockets in areas where connectivity is sub-optimal or sporadic.
In addition, packet identifiers have been reduced as much as possible. This is to both reduce bandwidth costs as well as require less time to exchange data.
To reduce risk of injection attacks, calls will use Hawk to sign requests (unless otherwise specified).
Data Schema
Since each server system will be unique, it does not make sense to strictly specify the data storage method. Instead an example storage mechanism will be offered to illustrate how the server would manage data.
A simple storage object would be keyed off of the ID returned in the /$v/init
call.
key => {"lastPosition":{"lat":lat, // The last position reported by track "lon":lon, "alt":altitude?, // Optional "altitude", if provided "tim":UTC}, // UTC Timestamp "previousPositions":[{position},...], // the last 5? position reports for the device "state":"(rtn)", // the state the server thinks the device is in "lockable"1:True|False, // does the device have a user supplied key code1 "lastExchange":UTC, // last time an exchange happened "secret":HawkSecret, "pendingCommand": {outboundCommand} } user => ["key:name",...] // A list of known keys & user friendly names for devices
1Note: this should be queried on device. User might set a passcode while the device is active or between updates.
API
Unless otherwise specified, all exchanged blocks are in JSON format and signed using HAWK (not shown here for simplicity).
Standard HTTP responses apply (401, 500, 301)
POST /$v/register
Registers the existence of a device.
The POSTed JSON payload contains the following fields:
key | value |
assert | A Firefox Accounts user assertion |
pushurl | The SimplePush channel URL that the server should use to notify the device that it has a new instruction. See <some simplepush link> for more details on acquiring a SimplePush channel. |
secret | a HAWK valid secret hash key for the device. This is used to sign the JSON responses. |
deviceid | The previous deviceid returned by the server from a register call. Used to overwrite a previous pushurl for this device if the SimplePush channel has changed. |
reply from server:
key | value |
deviceid | The unique id for this device. This id should be used in all future requests to the server, including any needed reregistration. |
After a device has registered for the first time, it should immediately call
POST /$v/cmd/$deviceUniqueId with a response as though it had just received a tracking call of:
{"t":{"p":1,"d":1}}
POST /$v/cmd/$deviceUniqueId
A request to the server for any new commands. If the device has just completed a command, the POST body will contain data with the results from the last command.
Responses contain a hash of one or more device commands keyed to a hash with information about that particular command.
A successful response will be formatted:
"<device command>":{"ok": "true", <additional response values>}
If one of the commands results in an error, the response for that command is
"<device comman>":{"ok": "false", "error": "<error details>"}
See Device commands for details about these commands. If a given $deviceUniqueId is unknown, or the HAWK wrapper fails, the URL will return a 401, requiring the device to re-register.
Other HTTP response codes (500, 301, 200, etc) perform as per normal.
Replies for the "l", "r", "m", or "e" command:
the device shall return an object containing a "status" and optionally an
"error" string.
For example, a successful lock and ring would return:
{"l":{"ok":true},"r":{"ok":true}}
In the case of an error with the ringer:
{"l":{"ok":true},"r":{"ok":false,"error":"no ringtone found"}}
For the "t" command:
the device shall return an object that includes the "ok" status, latitude,
loongitude, device time as UTC and other related positional
information, and lock key code present boolean.
If the tracking information is not available, it will also report "ok" as
false and optionally include an "error" string.
For example, a successful tracking request would return:
{"t":{"ok":true, "la":37.388017, "lo":-122.0833, "ti":1234567890, "k":true}}
Periodic updates for "t" commands do not need to include other commands. If, for whatever reason, the user has not activated or authorized geo-location for a device, the "la"/"lo" values may be specified as 0.
The body of the POST reply shall optionally contain further commands from the server. The following section describes these commands.
Device commands
Commands consist of a JSON object containing zero or more of the following:
{"command": {arguments},... }
- lock
- Specify the lock code to use, if no device lock code is present.
If a lock code already exists on the device, lock the device with the
device's lock code.
Example:
{"l":{"c":1234}} - ring
- Cause the device to ring every period seconds for a
duration of seconds. Specifying a duration of "0" stops the device
from ringing.
Example:
{"r":{"p":10,"d":60}} - message
- Display a message on the device consisting of a contact number
and text message.
contact numbers may only consist of the following:0123456789 +-()
, and is limited to 25 characters.
message text may only be 100 or less standard ASCII, non-control characters.
Example:
{"m":{"n":"+1 (408) 555-555", "m":"Help, I'm lost. Please return me!"}} - track
- Begin active location tracking on the device, reporting the devices
position every period second for a duration of seconds.
See POST /$v/cmd/$deviceUniqueId for how the device reports this
information. Specifying a duration of 0 stops the device from reporting
its location.
Example:
{"t":{"p":10,"d":300}} - erase
- Erase the device. This performs a factory reset.
Example:
{"e":{}}
Any of the above commands may be combined into a single command. For example, to lock a phone, display a message with contact number and cause the device to ring ever 30 seconds for 5 minutes:
{"l":{"c":1111}, "m":{"n":"555-555-5555","m":"Please return me!"}, "r":{"p":30,"d":300}}
Platform Requirements
What are the things this needs (OS, language, databases, etc.)?
Libraries Required
List of external project dependencies. (Stuff that's not pulled in via the installation script)
Code Repository
Links to the published code bases
Release Schedule
Predicted code delivery dates
QA
Points of Contact
Engineer - Ed Wong edwong@
Test Framework
Security and Privacy
Tracking bug: 935724
- Bug 935725 - Security Review: Where's My Fox
- Bug 935726 - Legal Review: Where's My Fox
- Bug 935727 - Privacy-Technical Review: Where's My Fox
- Bug 935728 - Privacy-Policy Review: Where's My Fox
Points of Contact
Legal - udevi@
Questionnaire Answers
1.1 Goal of Feature
2. Potential Threat Vectors and Mitigation Points
Review Status
https://bugzilla.mozilla.org/show_bug.cgi?id=935725
see https://wiki.mozilla.org/Security/Reviews
Issues and Resolutions
Operations
Points of Contact
Deployment Architecture
Bugzilla Tracking # -