Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Milestone1 - User authentication + database #1

Merged
merged 69 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
f7d5338
Added Database and EnvironmentReader
Duta-Sebastian Oct 26, 2024
b247263
Addded Docker run config
Duta-Sebastian Oct 26, 2024
e12c6e4
Added User class
Duta-Sebastian Oct 26, 2024
fb2991f
Trying to fix pipeline
Duta-Sebastian Oct 26, 2024
d4c5239
Implemented login/create account logic + created a docker file that d…
Duta-Sebastian Oct 27, 2024
fafd07d
Changed the way the User constructor initializes the userId. Now it u…
Duta-Sebastian Oct 27, 2024
2bb2b1e
Trying pipeline after some slight refactoring
Duta-Sebastian Oct 27, 2024
fb10a8e
Trying pipeline
Duta-Sebastian Oct 27, 2024
d88cabe
Replaced crypto.h with a new library that is cross-platform supported…
Duta-Sebastian Oct 29, 2024
122d2d2
Used a new hashing library that can be used cross-platform.
Duta-Sebastian Oct 30, 2024
5e92e71
Add logging functionality to track application events and errors
Duta-Sebastian Oct 30, 2024
a683b50
Added postgre service to the pipeline, trying to test with the login …
Duta-Sebastian Oct 30, 2024
aa94cff
Trying pipeline with a remove database instance hosted on Supabase
Duta-Sebastian Nov 1, 2024
9546c93
Installed Postgres on every pipeline build and removed the pq fetch f…
Duta-Sebastian Nov 1, 2024
8de4684
Trying to set the compiler standard to -std=c++2b
Duta-Sebastian Nov 1, 2024
503b403
Fixed unused variable in main + added system qualifier to the pqxx di…
Duta-Sebastian Nov 1, 2024
a9d7cb1
Removed build tests from pqxx
Duta-Sebastian Nov 1, 2024
c65e19c
Added system qualifier to the pqxx directories
Duta-Sebastian Nov 1, 2024
da601ae
Fixed unused variable in main
Duta-Sebastian Nov 1, 2024
eb92761
Removed build tests from pqxx
Duta-Sebastian Nov 1, 2024
ff69bd2
Merge branch 'Milestone1' of https://github.com/Duta-Sebastian/Passwo…
Duta-Sebastian Nov 1, 2024
7bf42f7
Fixed unused variable + disabled pqxx build tests
Duta-Sebastian Nov 1, 2024
404e564
Added special options for msan
Duta-Sebastian Nov 1, 2024
557bf55
Made special options for msan specific to pqxx
Duta-Sebastian Nov 1, 2024
9e753af
Removed special options + removed msan
Duta-Sebastian Nov 1, 2024
47f43ff
Removed Ubuntu Clang entirely
Duta-Sebastian Nov 2, 2024
e61fe13
Removed Ubuntu Clang entirely + trying something different with windo…
Duta-Sebastian Nov 2, 2024
de56aab
Removed Windows ASAN entirely
Duta-Sebastian Nov 2, 2024
f997186
Refactored project + added tests library
Duta-Sebastian Nov 2, 2024
26ec5f5
Finished pipeline
Duta-Sebastian Nov 2, 2024
32cbc16
Removed a forgotten cout + one last fix to the pipeline
Duta-Sebastian Nov 2, 2024
2d2343e
Overloaded the << operator for most classes ( apart from the purely s…
Duta-Sebastian Nov 2, 2024
4b40dcf
Added testing job in the pipeline -> testing it
Duta-Sebastian Nov 2, 2024
4d70774
Implemented some account creation tests
Duta-Sebastian Nov 2, 2024
b23bc0a
Used docker postgres for all pipeline builds, made the username uniqu…
Duta-Sebastian Nov 2, 2024
865c9f8
Docker cannot be used for other os than linux -> will use the new sql…
Duta-Sebastian Nov 2, 2024
897f82a
Fixing testing pipeline
Duta-Sebastian Nov 2, 2024
72385ec
Fixing testing pipeline 2
Duta-Sebastian Nov 2, 2024
2481017
Small name refactoring for pipeline + moved postgres install script t…
Duta-Sebastian Nov 3, 2024
9dbb1c2
Small refactoring + added overloaded print operator for EnvVarManager
Duta-Sebastian Nov 3, 2024
3743ef7
Small changes to code, pipeline and updated README.md
Duta-Sebastian Nov 3, 2024
0844d73
Update GitHub Actions pipeline to trigger on every push and when pull…
Duta-Sebastian Nov 3, 2024
3c3a25b
Trying to fix windows installation of Postgres, removed sample test.
Duta-Sebastian Nov 3, 2024
634875e
Trying to fix windows installation of Postgres v2
Duta-Sebastian Nov 3, 2024
bb9aa64
Trying to fix windows installation of Postgres v3
Duta-Sebastian Nov 4, 2024
6f7bbdd
Trying to fix windows installation of Postgres v4
Duta-Sebastian Nov 4, 2024
b14911a
Trying to fix windows installation of Postgres v5
Duta-Sebastian Nov 4, 2024
c6341d5
Increased timeout time for builds
Duta-Sebastian Nov 4, 2024
4a69a65
Various refactors.
Duta-Sebastian Nov 9, 2024
c739fed
More CMake refactors
Duta-Sebastian Nov 9, 2024
f51fd72
Debugging pipeline
Duta-Sebastian Nov 9, 2024
408a72c
Trying to change the copy_files function
Duta-Sebastian Nov 9, 2024
80a70c7
Trying to change the copy_files function v2
Duta-Sebastian Nov 9, 2024
bb5510e
Trying to remove tests from pqxx + adding msan back
Duta-Sebastian Nov 9, 2024
406fa4d
MSAN AND WINDOWS ASAN do not work
Duta-Sebastian Nov 9, 2024
8a87302
Trying to skip build tests again
Duta-Sebastian Nov 9, 2024
60ed223
Turned on RUN_TESTS
Duta-Sebastian Nov 9, 2024
3c03ea3
PQXX build tests
Duta-Sebastian Nov 9, 2024
ad66fe9
Trying ASAN windows now that pqxx tests are disabled
Duta-Sebastian Nov 9, 2024
242d8d3
Trying something with msvc
Duta-Sebastian Nov 9, 2024
9171adc
No asan on windows
Duta-Sebastian Nov 9, 2024
88904a7
Built the src as a library to include directly in the test + slight r…
Duta-Sebastian Nov 9, 2024
6d10b33
Fixed apple clang
Duta-Sebastian Nov 9, 2024
ef4d2aa
Slight refactoring
Duta-Sebastian Nov 10, 2024
354caa7
Slight refactoring v2
Duta-Sebastian Nov 10, 2024
8056cc4
Small refactoring
Duta-Sebastian Nov 10, 2024
21e0ee7
Updated readme to include ctest
Duta-Sebastian Nov 11, 2024
6a36f7a
Added eng README
Duta-Sebastian Nov 23, 2024
6952483
Removed useless methods
Duta-Sebastian Nov 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_NAME=<db_name>
DB_USER=<db_user>
DB_PASSWORD=<db_password>
DB_HOST=<db_host>
DB_PORT=<db_port>
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
generated/** linguist-generated
ext/** linguist-vendored
27 changes: 27 additions & 0 deletions .github/actions/install-postgres/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Install PostgreSQL'
description: 'Install PostgreSQL and its dependencies for each os'

runs:
using: "composite"
steps:
- name: Install PostgreSQL on Linux
shell: bash
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y postgresql
sudo service postgresql start

- name: Install PostgreSQL on macOS
shell: bash
if: runner.os == 'macOS'
run: |
brew update
brew install postgresql
brew services start postgresql

- name: Install PostgreSQL on Windows
shell: bash
if: runner.os == 'Windows'
run: |
choco install postgresql --version=17 -y
8 changes: 4 additions & 4 deletions .github/actions/process-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
shell: bash
if: runner.os == 'macOS'
run: |
sed -i '' -e "s/oop/${EXECUTABLE_NAME}/" "${{ env.ZIP_NAME }}/launcher.command"
sed -i '' -e "s/oop/${{ env.SRC_EXECUTABLE_NAME }}/" "${{ env.ZIP_NAME }}/launcher.command"
chmod +x "${{ env.ZIP_NAME }}/launcher.command"

- name: Copy missing dylibs
Expand All @@ -19,7 +19,7 @@ runs:
if [[ "${BUILD_TYPE}" =~ "Deb" ]]; then
mkdir lib
# cp /Library/Developer/CommandLineTools/usr/lib/clang/16/lib/darwin/libclang_rt.asan_osx_dynamic.dylib lib
# install_name_tool -change @rpath/libclang_rt.asan_osx_dynamic.dylib @executable_path/lib/libclang_rt.asan_osx_dynamic.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
# install_name_tool -change @rpath/libclang_rt.asan_osx_dynamic.dylib @executable_path/lib/libclang_rt.asan_osx_dynamic.dylib ${{ env.ZIP_NAME }}/${{ env.SRC_EXECUTABLE_NAME }}
mv lib ${{ env.ZIP_NAME }}/
fi

Expand All @@ -29,8 +29,8 @@ runs:
run: |
mkdir lib
cp /opt/homebrew/lib/gcc/13/libstdc++.6.dylib /opt/homebrew/lib/gcc/13/libgcc_s.1.1.dylib lib
install_name_tool -change /opt/homebrew/lib/gcc/13/libstdc++.6.dylib @executable_path/lib/libstdc++.6.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
install_name_tool -change /opt/homebrew/lib/gcc/13/libgcc_s.1.1.dylib @executable_path/lib/libgcc_s.1.1.dylib ${{ env.ZIP_NAME }}/${{ env.EXECUTABLE_NAME }}
install_name_tool -change /opt/homebrew/lib/gcc/13/libstdc++.6.dylib @executable_path/lib/libstdc++.6.dylib ${{ env.ZIP_NAME }}/${{ env.SRC_EXECUTABLE_NAME }}
install_name_tool -change /opt/homebrew/lib/gcc/13/libgcc_s.1.1.dylib @executable_path/lib/libgcc_s.1.1.dylib ${{ env.ZIP_NAME }}/${{ env.SRC_EXECUTABLE_NAME }}
mv lib ${{ env.ZIP_NAME }}/

- name: Copy missing dlls
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/runtime-checks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ runs:
# env:
# ASAN_OPTIONS: detect_leaks=1
run: |
cat "${INPUT_FILENAME}" | tr -d '\r' | ./${{ env.ZIP_NAME }}/"${EXECUTABLE_NAME}"
cat "${INPUT_FILENAME}" | tr -d '\r' | ./${{ env.ZIP_NAME }}/${{ env.SRC_EXECUTABLE_NAME }}

- name: Sanitizers (Windows MSVC)
shell: bash
# run one sanitizer for each OS to avoid building extra binaries
if: matrix.cxx == 'cl' && matrix.runs_asan == true
continue-on-error: true
run: |
cat "${INPUT_FILENAME}" | ./${{ env.ZIP_NAME }}/"${EXECUTABLE_NAME}".exe
cat "${INPUT_FILENAME}" | ./${{ env.ZIP_NAME }}/${{ env.SRC_EXECUTABLE_NAME }}.exe

- name: Valgrind
shell: bash
Expand All @@ -67,4 +67,4 @@ runs:
cat "${INPUT_FILENAME}" | tr -d '\r' | valgrind \
--leak-check=full --show-leak-kinds=all --track-origins=yes \
--error-exitcode=1 \
./${{ env.ZIP_NAME }}/"${EXECUTABLE_NAME}"
./${{ env.ZIP_NAME }}/${{ env.SRC_EXECUTABLE_NAME }}
133 changes: 105 additions & 28 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ name: C++ CI

on:
push:
branches: ['*'] # NOTE: replace/update with appropriate branch name(s)
tags: ['*']
branches: [ '*' ] # NOTE: replace/update with appropriate branch name(s)
tags: [ '*' ]
pull_request:
branches: ['*'] # NOTE: replace/update with appropriate branch name(s)
types: [closed]
branches: [ '*' ] # NOTE: replace/update with appropriate branch name(s)
workflow_dispatch:
inputs:
build_type:
Expand All @@ -21,14 +22,20 @@ on:

env:
BUILD_TYPE: ${{ inputs.build_type || 'Debug' }}
# NOTE: update executable name if it is changed in CMakeLists.txt
EXECUTABLE_NAME: "Password-Keeper"
SRC_EXECUTABLE_NAME: "Password-Keeper-src"
TEST_EXECUTABLE_NAME: "Password-Keeper-Test-Runner"
INPUT_FILENAME: "tastatura.txt"
BIN_DIR: "bin" # update in cmake/Options.cmake:6 if changing name here
BUILD_DIR: "build"
EXT_DIR: "ext"
GEN_DIR: "generated"

DB_NAME: ${{ secrets.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_HOST: ${{ secrets.DB_HOST }}
DB_PORT: ${{ secrets.DB_PORT }}

defaults:
run:
# Use a bash shell, so we can use the same syntax for environment variable
Expand Down Expand Up @@ -75,7 +82,7 @@ jobs:
# concurrency:
# group: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 8
timeout-minutes: 15
permissions:
attestations: write
contents: write
Expand All @@ -100,16 +107,16 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
c: clang-18
cxx: clang++-18
clang_ver: "18"
clang_ver_full: "18.1.8"
name: "MSan: Ubuntu 22.04 Clang 18"
cmake_flags: "-DUSE_MSAN=ON"
cmake_generator: Ninja
# This env runs memory sanitizers
runs_msan: true
# - os: ubuntu-22.04
# c: clang-18
# cxx: clang++-18
# clang_ver: "18"
# clang_ver_full: "18.1.8"
# name: "MSan: Ubuntu 22.04 Clang 18"
# cmake_flags: "-DUSE_MSAN=ON"
# cmake_generator: Ninja
# # This env runs memory sanitizers
# runs_msan: true

- os: ubuntu-22.04
c: gcc-12
Expand Down Expand Up @@ -147,16 +154,16 @@ jobs:
# cmake_flags:
# cmake_generator: Ninja

- os: windows-2022
c: cl
cxx: cl
name: "ASan: Windows 2022 MSVC 19.41"
cmake_flags: "-DUSE_ASAN=ON"
# Ninja is not faster on MSVC because... MSVC
# cmake_generator: "Ninja"
# cmake_generator: "Ninja Multi-Config"
# This env runs address sanitizers
runs_asan: true
# - os: windows-2022
# c: cl
# cxx: cl
# name: "ASan: Windows 2022 MSVC 19.41"
# cmake_flags: "-DUSE_ASAN=ON"
# # Ninja is not faster on MSVC because... MSVC
# # cmake_generator: "Ninja"
# # cmake_generator: "Ninja Multi-Config"
# # This env runs address sanitizers
# runs_asan: true

- os: windows-2022
c: gcc
Expand All @@ -169,6 +176,9 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

- name: Install PostgreSQL
uses: ./.github/actions/install-postgres

- name: Set timestamp and zip name
run: |
echo "TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S)" >> ${GITHUB_ENV}
Expand All @@ -188,7 +198,6 @@ jobs:
with:
custom_flags: ${{ matrix.cmake_flags }}
warnings_as_errors: 'ON'

- name: Build
run: |
bash ./scripts/cmake.sh build -t ${{ env.BUILD_TYPE }}
Expand All @@ -213,10 +222,78 @@ jobs:
name: ${{ env.ZIP_NAME }}_${{ env.TIMESTAMP }}
path: ${{ env.ZIP_NAME }}
retention-days: 30

- name: Runtime checks
uses: ./.github/actions/runtime-checks

- name: Create release
uses: ./.github/actions/create-release
if: startsWith(github.ref, 'refs/tags/')

test:
name: "Test"
runs-on: ubuntu-latest
needs: build
timeout-minutes: 5
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: pipeline_test_user
POSTGRES_PASSWORD: pipeline_test_password
POSTGRES_DB: pipeline_test_password_keeper
options: >-
--health-cmd "pg_isready -U pipeline_test_user"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
DB_HOST: localhost
DB_NAME: pipeline_test_password_keeper
DB_USER: pipeline_test_user
DB_PASSWORD: pipeline_test_password
DB_PORT: 5432
RUNS_TESTS: 1

steps:
- name: "Checkout code"
uses: actions/checkout@v4

- name: "Set up GCC"
run: sudo apt-get install -y build-essential gcc

- name: "Install dependencies"
run: |
sudo apt-get update
sudo apt-get install -y postgresql

- name: "Install CMake and Ninja"
run: |
sudo apt-get install -y cmake ninja-build

- name: "Build project"
run: |
cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER=gcc-12 -DCMAKE_CXX_COMPILER=g++-12 -DRUN_TESTS=ON -DSKIP_BUILD_TEST=ON
cmake --build build

- name: "Postgres setup"
run: |
export PGPASSWORD=pipeline_test_password
psql -h localhost -U pipeline_test_user -d pipeline_test_password_keeper -c "CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
passwordSalt VARCHAR(150) NOT NULL,
passwordHash VARCHAR(150) NOT NULL
);"

- name: "Run tests"
env:
DB_HOST: ${{ env.DB_HOST }}
DB_NAME: ${{ env.DB_NAME }}
DB_USER: ${{ env.DB_USER }}
DB_PASSWORD: ${{ env.DB_PASSWORD }}
DB_PORT: ${{ env.DB_PORT }}
run: |
cd build
ctest --verbose --no-compress-output
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Created by https://www.toptal.com/developers/gitignore/api/c++,clion,cmake,codeblocks,emacs,gcov,sublimetext,vim,visualstudio,visualstudiocode,xcode
# Edit at https://www.toptal.com/developers/gitignore?templates=c++,clion,cmake,codeblocks,emacs,gcov,sublimetext,vim,visualstudio,visualstudiocode,xcode

# Environment file - contains secrets
*.env

### C++ ###
# Prerequisites
*.d
Expand Down
2 changes: 1 addition & 1 deletion .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading