Some random stuff tbh
parent
a6b1b0ff76
commit
a295237863
|
@ -1,4 +1,13 @@
|
||||||
.vim/
|
*
|
||||||
out/
|
|
||||||
vendor/
|
!Cargo.lock
|
||||||
target/
|
!Cargo.toml
|
||||||
|
!Makefile
|
||||||
|
!migrations
|
||||||
|
!Rb.yaml
|
||||||
|
!rustfmt.toml
|
||||||
|
!src
|
||||||
|
!tests
|
||||||
|
!web
|
||||||
|
|
||||||
|
web/node_modules
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
FROM rust:1.54
|
||||||
|
|
||||||
|
RUN apt update && \
|
||||||
|
apt install -y --no-install-recommends \
|
||||||
|
musl-dev \
|
||||||
|
musl-tools \
|
||||||
|
libpq-dev \
|
||||||
|
libssl-dev && \
|
||||||
|
rustup target add x86_64-unknown-linux-musl
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
22
Makefile
22
Makefile
|
@ -25,6 +25,7 @@ CORES != nproc
|
||||||
export CC=musl-gcc -fPIC -pie -static
|
export CC=musl-gcc -fPIC -pie -static
|
||||||
export LD_LIBRARY_PATH=$(PREFIX)
|
export LD_LIBRARY_PATH=$(PREFIX)
|
||||||
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||||
|
export PATH := /usr/local/bin:/root/.cargo/bin:$(PATH)
|
||||||
|
|
||||||
|
|
||||||
# TODO check for header files (openssl-dev, libpq-dev) both for Arch & Ubuntu
|
# TODO check for header files (openssl-dev, libpq-dev) both for Arch & Ubuntu
|
||||||
|
@ -37,15 +38,32 @@ $(shell mkdir -p "$(PREFIX)")
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
|
.PHONY: docker
|
||||||
|
docker:
|
||||||
|
docker run \
|
||||||
|
--rm \
|
||||||
|
-v "$$PWD:/usr/src" \
|
||||||
|
--workdir "/usr/src" \
|
||||||
|
-it \
|
||||||
|
rust:1.54 \
|
||||||
|
bash build.sh
|
||||||
|
|
||||||
|
|
||||||
# libpq builds openssl as a dependency
|
# libpq builds openssl as a dependency
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: libpq
|
build: libpq
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
echo "$$PATH"
|
||||||
@ echo "Note: this only cleans the C dependencies, not the Cargo cache."
|
@ echo "Note: this only cleans the C dependencies, not the Cargo cache."
|
||||||
rm -rf "$(PQ_DIR)" "$(OPENSSL_DIR)" "$(DI_DIR)" "$(PREFIX)"
|
rm -rf "$(PQ_DIR)" "$(OPENSSL_DIR)" "$(DI_DIR)" "$(PREFIX)"
|
||||||
|
|
||||||
|
# This is used inside the Dockerfile
|
||||||
|
.PHONY: pathfile
|
||||||
|
pathfile:
|
||||||
|
echo "$(PREFIX)/lib" >> /etc/ld-musl-x86_64.path
|
||||||
|
|
||||||
|
|
||||||
# =====OPENSSL=====
|
# =====OPENSSL=====
|
||||||
# Download the source code & configure the project
|
# Download the source code & configure the project
|
||||||
|
@ -53,7 +71,7 @@ $(OPENSSL_DIR)/Configure:
|
||||||
curl -sSL "https://www.openssl.org/source/openssl-$(SSL_VER).tar.gz" | \
|
curl -sSL "https://www.openssl.org/source/openssl-$(SSL_VER).tar.gz" | \
|
||||||
tar -C "$(OUT_DIR)" -xz
|
tar -C "$(OUT_DIR)" -xz
|
||||||
cd "$(OPENSSL_DIR)" && \
|
cd "$(OPENSSL_DIR)" && \
|
||||||
CC="$$CC -idirafter /usr/include" ./Configure \
|
CC="$$CC -idirafter /usr/include -idirafter /usr/include/x86_64-linux-gnu/" ./Configure \
|
||||||
no-zlib \
|
no-zlib \
|
||||||
no-shared \
|
no-shared \
|
||||||
--prefix="$(PREFIX)" \
|
--prefix="$(PREFIX)" \
|
||||||
|
@ -63,7 +81,7 @@ $(OPENSSL_DIR)/Configure:
|
||||||
# Build OpenSSL
|
# Build OpenSSL
|
||||||
.PHONY: openssl
|
.PHONY: openssl
|
||||||
openssl: $(OPENSSL_DIR)/Configure
|
openssl: $(OPENSSL_DIR)/Configure
|
||||||
C_INCLUDE_PATH="$(PREFIX)/include" $(MAKE) -C "$(OPENSSL_DIR)" depend
|
env C_INCLUDE_PATH="$(PREFIX)/include" $(MAKE) -C "$(OPENSSL_DIR)" depend
|
||||||
$(MAKE) -C "$(OPENSSL_DIR)" -j$(CORES)
|
$(MAKE) -C "$(OPENSSL_DIR)" -j$(CORES)
|
||||||
$(MAKE) -C "$(OPENSSL_DIR)" install_sw
|
$(MAKE) -C "$(OPENSSL_DIR)" install_sw
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
|
apt update
|
||||||
|
apt install \
|
||||||
|
-y --no-install-recommends \
|
||||||
|
musl-dev \
|
||||||
|
musl-tools \
|
||||||
|
libssl-dev \
|
||||||
|
libpq-dev
|
||||||
|
|
||||||
|
make pathfile
|
||||||
|
make
|
|
@ -99,6 +99,11 @@ pub fn refresh_token(
|
||||||
return Err(RbError::AuthDuplicateRefreshToken);
|
return Err(RbError::AuthDuplicateRefreshToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Then we check if the user is blocked
|
||||||
|
if user.blocked {
|
||||||
|
return Err(RbError::AuthBlockedUser);
|
||||||
|
}
|
||||||
|
|
||||||
// Now we check if the token has already expired
|
// Now we check if the token has already expired
|
||||||
let cur_time = Utc::now().naive_utc();
|
let cur_time = Utc::now().naive_utc();
|
||||||
|
|
||||||
|
|
Reference in New Issue