all: build-server Q ?= @ SHOULD_UPDATE = ./bin/should-update OPTS ?= --progress NAME ?= John EMAIL ?= john@example.com # For requests where authentication is required. LOGIN ?= ifeq ($(LOGIN),) LOGIN_OPT = else LOGIN_OPT = -l $(LOGIN) endif ################## ### SETUP COMMANDS ################## PASSWORD_FILE ?= /tmp/PASSWORD setup: @[ -f $(PASSWORD_FILE) ] || echo -n "coucou" > $(PASSWORD_FILE) DATA_DIRECTORY ?= /tmp/DATA-AUTHD run-authd: setup ./bin/authd -k $(PASSWORD_FILE) -R -E --storage $(DATA_DIRECTORY) # First user always is the admin. add-first-user: ./bin/authc bootstrap $(NAME) $(EMAIL) #################### ### REQUEST EXAMPLES #################### add-user: ./bin/authc user add $(NAME) $(EMAIL) $(LOGIN_OPT) register: ./bin/authc user register $(NAME) $(EMAIL) ACTIVATION_KEY ?= put-your-key-here validate: ./bin/authc user validate $(NAME) $(ACTIVATION_KEY) get-user: ./bin/authc user get $(NAME) $(LOGIN_OPT) SERVICE ?= 'auth' RESOURCE ?= '*' UID ?= 1000 permission-check: ./bin/authc permission check $(UID) $(SERVICE) $(RESOURCE) $(LOGIN_OPT) PERMISSION ?= Read permission-set: ./bin/authc permission set $(UID) $(SERVICE) $(RESOURCE) $(PERMISSION) $(LOGIN_OPT) ################### ### DEVELOPER TOOLS ################### build-server: $(Q)-$(SHOULD_UPDATE) bin/authd && shards build authd $(OPTS) build-client: $(Q)-$(SHOULD_UPDATE) bin/authc && shards build authc $(OPTS) build: build-server build-client doc: crystal docs HTTPD_ACCESS_LOGS ?= /tmp/access-authd-docs.log HTTPD_ADDR ?= 127.0.0.1 HTTPD_PORT ?= 9000 DIR ?= docs serve-doc: darkhttpd $(DIR) --addr $(HTTPD_ADDR) --port $(HTTPD_PORT) --log $(HTTPD_ACCESS_LOGS) print-messages: cat src/requests/*.cr | ./bin/get-messages.awk print-message-numbers: make -s print-messages | grep -E "^[0-9]" | sort -n print-messages-without-comments: make -s print-messages | grep -vE '^[[:blank:]]+#' print-response-messages: cat src/responses/*.cr | ./bin/get-messages.awk print-response-message-numbers: make -s print-response-messages | grep -E "^[0-9]" | sort -n print-response-messages-without-comments: make -s print-response-messages | grep -vE '^[[:blank:]]+#' wipe-db: rm -r $(DATA_DIRECTORY) release: make build-server OPTS="--progress --release"