πŸ’‚β€β™‚οΈ Access Control as a Service.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
cmd
env
pkg
vendor
.dockerignore
.gitattributes
.gitignore
.goreleaser.yml
.travis.yml
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md
cli.go
cli_test.go
guardctl.go
guardctl_test.go
main.go
main_test.go

README.md

πŸ’‚β€β™‚οΈ Guard Tweet

Analytics Access Control as a Service β€” your personal paywall to protect any API or site's content.

Patreon License

Roadmap

Motivation

  • We have to limit access to some part of our content.

Quick start

Requirements:

  • Docker 18.06.0-ce or above
  • Docker Compose 1.22.0 or above
  • Go 1.11 or above
  • GNU Make 3.81 or above
$ make demo up start-migration status

      Name                     Command               State                        Ports
------------------------------------------------------------------------------------------------------------
guard_db_1          docker-entrypoint.sh postgres    Up       5432/tcp
guard_legacy_1      docker-php-entrypoint php-fpm    Up       9000/tcp
guard_migration_1   service migrate                  Exit 0
guard_server_1      nginx -g daemon off;             Up       0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
guard_service_1     service run --with-profili ...   Up       80/tcp, 8090/tcp, 8091/tcp, 8092/tcp, 8093/tcp
guard_spec_1        sh /usr/share/nginx/docker ...   Up       80/tcp, 8080/tcp

$ ./env/client/grpc/install.sh

$ open http://spec.127.0.0.1.xip.io/

$ make help

Specification

API

You can find API specification here.

CLI

You can use guard to start the HTTP server and guardctl to execute CRUD operations.

Service command-line interface
$ make service-install

$ guard --help
  Guard Service
  
  Usage:
    guard [command]
  
  Available Commands:
    completion  Print Bash or Zsh completion
    help        Help about any command
    run         Start HTTP server
    version     Show application version
  
  Flags:
    -h, --help   help for guard
  
  Use "guard [command] --help" for more information about a command.
Client command-line interface
$ make control-install

$ guardctl --help
  Guard Control
  
  Usage:
    guardctl [command]
  
  Available Commands:
    completion  Print Bash or Zsh completion
    help        Help about any command
    license     Guard License
    version     Show application version
  
  Flags:
    -h, --help   help for guardctl
  
  Use "guardctl [command] --help" for more information about a command.

$ guardctl install -f env/client/grpc/install.yaml

$ export GUARD_TOKEN=10000000-2000-4000-8000-160000000003

$ guardctl license register -f env/client/grpc/license.register.yml
id: 10000000-2000-4000-8000-160000000004

$ echo '{id: 10000000-2000-4000-8000-160000000004}' | guardctl license read
contract:
  rate:
    unit: rph
    value: 10
  requests: 1000
  since: "2018-09-29T17:11:43.264Z"
  workplaces: 10
created_at: "2018-10-04T09:32:19.102216Z"
id: 10000000-2000-4000-8000-160000000004

$ cat env/client/grpc/license.update.yml | guardctl license update
id: 10000000-2000-4000-8000-160000000004
updated_at: "2018-10-04T09:33:32.487454Z"

$ guardctl license create -f env/client/grpc/license.create.yml | guardctl license delete | guardctl license read
contract:
  rate:
    unit: rph
    value: 10
  requests: 1000
  since: "2018-09-29T17:11:43.264Z"
  workplaces: 10
created_at: "2018-10-04T09:57:16.656346Z"
deleted_at: "2018-10-04T09:57:16.666664Z"
id: 9ba7b564-3248-4401-b853-9dc32559b95b
updated_at: "2018-10-04T09:57:16.666664Z"

$ guardctl license delete -f env/client/grpc/license.delete.yml
deleted_at: "2018-10-04T09:58:27.365193Z"
id: 10000000-2000-4000-8000-160000000004

$ echo '{id: 10000000-2000-4000-8000-160000000004}' | guardctl license restore | guardctl license read
contract:
  rate:
    unit: rpd
    value: 10
  requests: 1000
  since: "2018-09-29T17:11:43.264Z"
  until: "2018-09-29T17:11:43.264Z"
  workplaces: 10
created_at: "2018-10-04T09:54:57.643041Z"
id: 10000000-2000-4000-8000-160000000004
updated_at: "2018-10-04T09:59:18.833134Z"

Bash and Zsh completions

You can find completion files here or build your own using these commands

Service:

$ guard completion -f bash > /path/to/bash_completion.d/guard.sh
$ guard completion -f zsh  > /path/to/zsh-completions/_guard.zsh

Client:

$ guardctl completion -f bash > /path/to/bash_completion.d/guardctl.sh
$ guardctl completion -f zsh  > /path/to/zsh-completions/_guardctl.zsh

Installation

Brew

$ brew install kamilsk/tap/guard

$ which guard guardctl
/usr/local/bin/guard
/usr/local/bin/guardctl

Binary

$ export REQ_VER=0.0.1  # all available versions are on https://github.com/kamilsk/guard/releases/
$ export REQ_OS=Linux   # macOS and Windows are also available
$ export REQ_ARCH=64bit # 32bit is also available
# wget -q -O guard.tar.gz
$ curl -sL -o guard.tar.gz \
       https://github.com/kamilsk/guard/releases/download/"${REQ_VER}/guard_${REQ_VER}_${REQ_OS}-${REQ_ARCH}".tar.gz
$ tar xf guard.tar.gz -C "${GOPATH}"/bin/ && rm guard.tar.gz

Docker Hub

$ docker pull kamilsk/guard:latest

From source code

$ egg github.com/kamilsk/guard -- make test install
# or use mirror
$ egg bitbucket.org/kamilsk/guard -- make test install

egg1 is an extended go get.

Update

This application is in a state of MVP and under active development. SemVer is used for releases, and you can easily be updated within minor versions, but major versions can be not BC-safe.

1 The project is still in prototyping. ↩


@kamilsk @octolab

made with ❀️ by OctoLab