All Projects → mozilla → servicebook

mozilla / servicebook

Licence: MPL-2.0 license
A web service to manage our projects

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects
Dockerfile
14818 projects
Makefile
30231 projects

Projects that are alternatives of or similar to servicebook

trellio
Python3 asyncio based microframework for microservice architecture
Stars: ✭ 19 (+35.71%)
Mutual labels:  python35
Driftwood
Driftwood 2D Tiling Game Engine and Development Suite
Stars: ✭ 23 (+64.29%)
Mutual labels:  python35
open-solution-ship-detection
Open solution to the Airbus Ship Detection Challenge
Stars: ✭ 54 (+285.71%)
Mutual labels:  python35
aarch64-tensorflow
tensorflow and bazel for aarch64: binaries at...
Stars: ✭ 14 (+0%)
Mutual labels:  python35
Artistic-Style-Transfer-using-Keras-Tensorflow
Art to Image Style Transfer using Keras and Tensorflow.
Stars: ✭ 22 (+57.14%)
Mutual labels:  python35
adp-portfolio-selection
Approximate Dynamic Programming for Portfolio Selection Problem
Stars: ✭ 29 (+107.14%)
Mutual labels:  python35
django-radiogrid
Django radio grid field
Stars: ✭ 28 (+100%)
Mutual labels:  python35
lt2circuitikz
Python (3.5) tool to convert .asc files into circuiTikz graphics
Stars: ✭ 57 (+307.14%)
Mutual labels:  python35
VNet
Prostate MR Image Segmentation 2012
Stars: ✭ 54 (+285.71%)
Mutual labels:  python35
fastuuid
FastUUID is a library which provides CPython bindings to Rust's UUID library
Stars: ✭ 83 (+492.86%)
Mutual labels:  python35
sozlukus.com
sozlukus.com source code
Stars: ✭ 11 (-21.43%)
Mutual labels:  python35

Service Book

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

License CircleCI Travis CI Coverage 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:[email protected]/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:[email protected]/book list
No keys!

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

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

$ servicebook-keys --sqluri mysql+pymysql://book:[email protected]/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:[email protected]/book revoke MyApp
Key revoked for MyApp

$ servicebook-keys --sqluri mysql+pymysql://book:[email protected]/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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].