authd/makefile

92 lines
2.7 KiB
Makefile

all: build-server
Q ?= @
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
SOURCE_FILES = $(wildcard src/*.cr src/*/*.cr src/*/*/*.cr)
##################
### 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
####################
ACTIVATION_KEY ?= put-your-key-here
add-user:; $(Q)./bin/authc user add $(NAME) $(EMAIL) $(LOGIN_OPT)
register:; $(Q)./bin/authc user register $(NAME) $(EMAIL)
validate:; $(Q)./bin/authc user validate $(NAME) $(ACTIVATION_KEY)
get-user:; $(Q)./bin/authc user get $(NAME) $(LOGIN_OPT)
USER_DB ?= /tmp/migration-authd-user-db.txt
$(USER_DB): ; ./bin/migration-filter.awk < /tmp/usrdb | grep -a -v "^INVALID" | sort | uniq > $(USER_DB)
migration-file: $(USER_DB)
migrate-user:; ./bin/authc user migrate $(NAME) $(PASSWORD_HASH) $(LOGIN_OPT)
migrate-all-users:; ./bin/authc migration-script $(USER_DB) $(LOGIN_OPT)
SERVICE ?= 'auth'
RESOURCE ?= '*'
UID ?= 1000
PERMISSION ?= Read
permission-check:; ./bin/authc permission check $(UID) $(SERVICE) $(RESOURCE) $(LOGIN_OPT)
permission-set:; ./bin/authc permission set $(UID) $(SERVICE) $(RESOURCE) $(PERMISSION) $(LOGIN_OPT)
###################
### DEVELOPER TOOLS
###################
bin/authd: $(SOURCE_FILES); $(Q)shards build authd $(OPTS)
bin/authc: $(SOURCE_FILES); $(Q)shards build authc $(OPTS)
build-server: bin/authd
build-client: bin/authc
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-no-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-no-comments:; make -s print-response-messages | grep -vE '^[[:blank:]]+#'
wipe-db:
rm -r $(DATA_DIRECTORY)
release:
make build-server OPTS="--progress --release"