authd/makefile

88 lines
2.4 KiB
Makefile
Raw Normal View History

2024-03-23 11:47:30 +01:00
all: build-server
2023-05-29 20:41:12 +02:00
Q ?= @
OPTS ?= --progress
2023-05-29 20:41:12 +02:00
NAME ?= John
EMAIL ?= john@example.com
2023-06-08 17:33:43 +02:00
2023-06-14 21:00:15 +02:00
# For requests where authentication is required.
LOGIN ?=
ifeq ($(LOGIN),)
LOGIN_OPT =
else
LOGIN_OPT = -l $(LOGIN)
endif
2023-06-08 17:33:43 +02:00
2024-06-22 00:54:22 +02:00
SOURCE_FILES = $(wildcard src/*.cr src/*/*.cr src/*/*/*.cr)
2023-06-14 21:00:15 +02:00
##################
### SETUP COMMANDS
##################
PASSWORD_FILE ?= /tmp/PASSWORD
2023-06-08 17:33:43 +02:00
setup:
@[ -f $(PASSWORD_FILE) ] || echo -n "coucou" > $(PASSWORD_FILE)
2023-06-14 21:00:15 +02:00
DATA_DIRECTORY ?= /tmp/DATA-AUTHD
2023-06-08 17:33:43 +02:00
run-authd: setup
2023-06-16 01:28:10 +02:00
./bin/authd -k $(PASSWORD_FILE) -R -E --storage $(DATA_DIRECTORY)
2023-05-29 20:41:12 +02:00
2023-06-14 21:00:15 +02:00
# First user always is the admin.
add-first-user:
./bin/authc bootstrap $(NAME) $(EMAIL)
####################
### REQUEST EXAMPLES
####################
2023-06-15 02:43:24 +02:00
ACTIVATION_KEY ?= put-your-key-here
2024-06-22 00:54:22 +02:00
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)
2024-06-08 19:23:20 +02:00
2023-06-15 00:03:12 +02:00
SERVICE ?= 'auth'
RESOURCE ?= '*'
UID ?= 1000
PERMISSION ?= Read
2024-06-22 00:54:22 +02:00
permission-check:; ./bin/authc permission check $(UID) $(SERVICE) $(RESOURCE) $(LOGIN_OPT)
permission-set:; ./bin/authc permission set $(UID) $(SERVICE) $(RESOURCE) $(PERMISSION) $(LOGIN_OPT)
2023-06-15 00:03:12 +02:00
2023-06-14 21:00:15 +02:00
###################
### DEVELOPER TOOLS
###################
2024-06-22 00:54:22 +02:00
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
2023-06-14 21:00:15 +02:00
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)
2024-06-22 00:54:22 +02:00
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"
2024-11-17 18:07:32 +01:00
-include migration.mk