Some random stuff tbh

develop
Jef Roosens 2021-09-05 09:59:16 +02:00
parent a6b1b0ff76
commit a295237863
Signed by untrusted user: Jef Roosens
GPG Key ID: 955C0660072F691F
5 changed files with 64 additions and 6 deletions

View File

@ -1,4 +1,13 @@
.vim/
out/
vendor/
target/
*
!Cargo.lock
!Cargo.toml
!Makefile
!migrations
!Rb.yaml
!rustfmt.toml
!src
!tests
!web
web/node_modules

11
Dockerfile 100644
View File

@ -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

View File

@ -25,6 +25,7 @@ CORES != nproc
export CC=musl-gcc -fPIC -pie -static
export LD_LIBRARY_PATH=$(PREFIX)
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
@ -37,15 +38,32 @@ $(shell mkdir -p "$(PREFIX)")
.PHONY: all
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
.PHONY: build
build: libpq
.PHONY: clean
clean:
echo "$$PATH"
@ echo "Note: this only cleans the C dependencies, not the Cargo cache."
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=====
# 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" | \
tar -C "$(OUT_DIR)" -xz
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-shared \
--prefix="$(PREFIX)" \
@ -63,7 +81,7 @@ $(OPENSSL_DIR)/Configure:
# Build OpenSSL
.PHONY: openssl
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)" install_sw

15
build.sh 100644
View File

@ -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

View File

@ -99,6 +99,11 @@ pub fn refresh_token(
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
let cur_time = Utc::now().naive_utc();