A web service to manage our projects
Перейти к файлу
Stephen Donner c419c37674
Merge pull request #180 from mozilla/dependabot/pip/tox-3.7.0
Bump tox from 3.5.3 to 3.7.0
2019-01-22 14:04:57 -08:00
.circleci Fix reference to CIRCLE_PROJECT_REPONAME environment variable 2018-08-15 11:43:16 +01:00
requirements Bump tox from 3.5.3 to 3.7.0 2019-01-22 21:53:15 +00:00
servicebook fix the migration 2018-10-09 20:49:39 +02:00
.coveragerc added coveragerc to exclude tests dir 2016-12-23 08:41:45 +01:00
.gitignore cleanup 2016-11-16 09:09:17 +01:00
.travis.yml Moved pipenv and tox requirements files to requirements directory 2018-08-17 19:58:15 +01:00
Dockerfile Moved pipenv and tox requirements files to requirements directory 2018-08-17 19:58:15 +01:00
LICENSE.txt Add MPL 2.0 license 2017-12-06 13:50:33 -08:00
MANIFEST.in adding the json file 2016-11-22 14:40:29 +01:00
Makefile Switch to Pipenv dev workflow 2018-02-02 18:39:09 +00:00
Pipfile Update all dependencies 2018-08-17 20:00:25 +01:00
Pipfile.lock Merge pull request #181 from mozilla/dependabot/pip/sqlalchemy-1.2.16 2019-01-22 13:48:18 -08:00
README.rst Update Readme.srt 2018-10-26 01:39:18 +05:30
entrypoint.sh default command not firing; remove debug line 2017-09-29 14:25:14 -05:00
init_db.py tweaks for dockerflow 2017-02-15 21:05:50 +01:00
servicebook.ini added sentry support 2017-09-06 18:41:08 +02:00
setup.py Switch to Pipenv dev workflow 2018-02-02 18:39:09 +00:00
tox.ini Moved pipenv and tox requirements files to requirements directory 2018-08-17 19:58:15 +01:00
uwsgi.ini Let's use 5001 everywhere 2017-02-15 16:55:14 +01:00
wsgiapp.py switched to mysql and made Dockerfile dockerflow-compatible 2017-02-15 15:43:55 +01:00

README.rst

Service Book
============

Mozilla Services projects API. Provides a Database of all projects and
a set of API to interact with them.

.. image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg
   :target: https://github.com/mozilla/servicebook-web/blob/master/LICENSE.txt
   :alt: License
.. image:: https://img.shields.io/circleci/project/github/mozilla/servicebook/master.svg?logo=circleci
   :alt: CircleCI
   :target: https://circleci.com/gh/mozilla/servicebook/tree/master
.. image:: https://img.shields.io/travis/mozilla/servicebook/master.svg?logo=travis
   :target: https://travis-ci.org/mozilla/servicebook
   :alt: Travis CI
.. image:: https://img.shields.io/coveralls/github/mozilla/servicebook/master.svg
   :alt: Coverage
   :target: https://coveralls.io/github/mozilla/servicebook?branch=master
.. image:: https://api.dependabot.com/badges/status?host=github&repo=mozilla/servicebook
   :target: https://dependabot.com
   :alt: Dependabot

Use the Service Book
--------------------

The Service Book provides a RESTFul HTTP API. If you are using Python, you can
use the restjson client: https://github.com/tarekziade/restjson

It provides a simple tool to interact with the Service Book.


Running locally
---------------

The servicebook uses a MySQL database by default, but you can use
SQLITE3 or postgres by tweaking the **sqluri** option in **servicebook.ini**.

Create a local virtualenv, install requirements, initialize the DB
then run the service::

    $ pipenv install --dev
    $ pipenv shell
    $ servicebook-import --sqluri mysql+pymysql://book:book@0.0.0.0/book
    $ servicebook

The app runs on the 5001 port by default.


Running with Docker
-------------------

You can run the app using the provided Dockerfile, by building the docker
image, then running it. It will bind the app to your 5001 port::

    $ make docker-build
    $ make docker-run

The Docker image will reach out for the database that's set
**servicebook.ini**.

Running with external DB
------------------------

If you would like to use an external DB for storage, be sure to set the default
character set for the database to UTF-8 (utf8mr for mysql).


Authentication
--------------

The application can secure the HTTP API access for reads and/or writes.

You can define how anonymous accesses are handled with the
**anonymous_access** variable in the **common** section of the config file.

The value to set is a permission **scope**. Possible values:

- **read**: access to GET and HEAD calls - **default value when non specified**
- **readwrite**: access to PATCH, PUT, POST, DELETE, GET, HEAD
- **admin**: like readwrite - will be used for specific admin tasks

Client can also have a privileged access with an API key.
The key is passed in the Authorization header, prefixed by APIKey::

    Authorization APIKey ZGJkYWI3ZmQtZDEwNy00MzJiLWJlNDgtMjZkNTQyZGFiZDhi

The value is a base64-encoded UUID. Each application that wishes to get a
privileged access should have its own API key and scope.

You can list/add/revoke keys using the **servicebook-keys** command::

    $ servicebook-keys --sqluri mysql+pymysql://book:book@0.0.0.0/book list
    No keys!

    $ servicebook-keys --sqluri mysql+pymysql://book:book@0.0.0.0/book add MyApp
    App: MyApp, Key: 399c1365-3700-4ce6-8fd1-f304a32a0794, Scope: read

    $ servicebook-keys --sqluri mysql+pymysql://book:book@0.0.0.0/book add MyApp2 --scope readwrite
    App: MyApp2, Key: e87271fd-ca31-46cf-8cc5-48b1f9348e4e, Scope: readwrite

    $ servicebook-keys --sqluri mysql+pymysql://book:book@0.0.0.0/book list
    App: MyApp, Key: 399c1365-3700-4ce6-8fd1-f304a32a0794, Scope: read
    App: MyApp2, Key: e87271fd-ca31-46cf-8cc5-48b1f9348e4e, Scope: readwrite

    $ servicebook-keys --sqluri mysql+pymysql://book:book@0.0.0.0/book revoke MyApp
    Key revoked for MyApp

    $ servicebook-keys --sqluri mysql+pymysql://book:book@0.0.0.0/book list
    App: MyApp2, Key: e87271fd-ca31-46cf-8cc5-48b1f9348e4e, Scope: readwrite


The default setup will make the data read-only and will require a privileged
access with **readwrite** scope for writing in the database.

You should have one separate key per calling service so it's easier to revoke or
renew a specific service access if required.