firex

command module
v0.0.0-...-fb67617 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2020 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Firex

Firex is a real time database backend service designed for fast mobile and web apps development.

On top of an API to C.R.U.D json documents from a MySQL database firex uses a CEL based security rules layer to manage access to documents.

Install and run

go get github.com/omecodes/firex
requirements

Firex only a need a MySQL database installed to run.

Run

Executing just ./firex command will start a server that listens to the port 80 and assumes you have a MySQL database running on 127.0.0.1:3306 accessible with firex:firex credentials.

To run it using non default port and database, excute it with --p and --dsn arguments as follow:

./firex --p=8080 --dsn=ome:code@(loclahost:3306)/firex?charset=utf8

Setting up security rules

Writing security rule consists of using Common Expression Language to create boolean expressions that are executed at runtime against requests context.

- Request context

The request context is a set of objects that hold information about:

  • the API caller
type auth {
    uid string //user id
    email string
    validated bool
    scope string
    group string
}
  • the targeted data
type data {
    id string //user id
    col string // collection
    creator string
}
  • some global information like the request time
// permissions

type perm {
    read bool
    write bool
    delete bool
    rules bool
    graft bool
}

// acl laods permissions of user 
// identified by 'uid' on data with 'did' as id 
func acl (uid string, did string) perm
- Write and apply rules

Allowing everybody to read document and allowing only creator to edit documents will give:

    read: true
    write: auth.validated && auth.uid == data.id

and to apply these rules on a server that runs at localhost send an http post request as follow:

curl --location --request POST 'http://127.0.0.1/.settings/security/rules/access/data' \
--header 'Authorization: Basic YWRtaW46YWRtaW5wYXNzd29yZA==' \
--header 'Content-Type: application/json' \
--data-raw '{
    "read": "true",
    "write": "auth.validated && auth.uid == data.id"
}'

API with swagger

Go to Swagger online editor and paste the content of the firex API specification to learn more about the Firex or generate a client code of the language you are working with.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
ent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL