Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
5d11e26
fix incorrect roles initiation
SuitablyMysterious Jul 7, 2025
52a192d
Create .gitattributes
HippoProgrammer Jul 9, 2025
7c52708
Merge pull request #99 from The-CS-Nerds/HippoProgrammer-patch-1
HippoProgrammer Jul 9, 2025
0abf4e1
Create CODEOWNERS
HippoProgrammer Jul 9, 2025
cda5c08
Merge pull request #100 from The-CS-Nerds/HippoProgrammer-patch-1
HippoProgrammer Jul 9, 2025
b4f3b45
Update CODEOWNERS
HippoProgrammer Jul 9, 2025
d0bbb85
Merge pull request #101 from The-CS-Nerds/HippoProgrammer-patch-1
HippoProgrammer Jul 9, 2025
3746d53
Merge branch 'dev' into casbin-integration
HippoProgrammer Jul 10, 2025
98cb736
Fix copilot requests
SuitablyMysterious Jul 10, 2025
68600b2
Merge pull request #107 from The-CS-Nerds/casbin-integration
HippoProgrammer Jul 10, 2025
41aef17
Closes I can already see the problem #92
SuitablyMysterious Jul 10, 2025
f319989
Merge pull request #108 from The-CS-Nerds/delete-patch
SuitablyMysterious Jul 10, 2025
8f6f029
Add user class to `db.py`
SuitablyMysterious Jul 10, 2025
5685633
Update `requirements.in` we need to regenerate hashes
SuitablyMysterious Jul 10, 2025
b4c7bd0
Create a `users` table
SuitablyMysterious Jul 10, 2025
9039588
Changed `sendSQLCommand` to be parameterized
SuitablyMysterious Jul 10, 2025
de5f27f
Added zitadel
HippoProgrammer Jul 11, 2025
0ef8bbf
Merge pull request #111 from The-CS-Nerds/zitadel
HippoProgrammer Jul 11, 2025
2353ab3
I have commitment issues
HippoProgrammer Jul 11, 2025
539aff8
Fixes #113
SuitablyMysterious Jul 11, 2025
80774af
Merge pull request #117 from The-CS-Nerds/docker-entrypoint-patch
SuitablyMysterious Jul 11, 2025
d308b86
Merge branch 'dev' into tommy
SuitablyMysterious Jul 11, 2025
d318a88
Merge pull request #116 from The-CS-Nerds/tommy
SuitablyMysterious Jul 11, 2025
77feb4a
update gitignore for binary files
SuitablyMysterious Jul 11, 2025
e5d2a9d
Merge pull request #118 from The-CS-Nerds/gitignore-patch
SuitablyMysterious Jul 11, 2025
1ad3c86
thats better
SuitablyMysterious Jul 11, 2025
7a4dc6e
Merge pull request #119 from The-CS-Nerds/gitignore-patch
SuitablyMysterious Jul 11, 2025
efd5310
update docker compose to use logto networks
SuitablyMysterious Jul 11, 2025
8ea830f
final fix for #113
SuitablyMysterious Jul 11, 2025
6bdd693
Merge branch 'dev' into users-patch
SuitablyMysterious Jul 11, 2025
fcb60a2
Merge branch 'users-patch' of https://github.com/The-CS-Nerds/Library…
SuitablyMysterious Jul 11, 2025
a665f33
Fix errors
SuitablyMysterious Jul 11, 2025
7fdac02
Update `db.py` to find Users by a given key
SuitablyMysterious Jul 12, 2025
be4bd00
update the database to store surnames and forenames
SuitablyMysterious Jul 13, 2025
6cf7939
Create basic Vue structure
SuitablyMysterious Jul 13, 2025
17bb1a6
update policy to allow universal view access to books table
SuitablyMysterious Jul 13, 2025
dded32d
sets backend to listen on port 8000
SuitablyMysterious Jul 13, 2025
5fee132
create a very basic book search template
SuitablyMysterious Jul 13, 2025
833197b
Merge pull request #110 from The-CS-Nerds/users-patch
SuitablyMysterious Jul 13, 2025
5e902c5
Merge branch 'logto-integration' into vue-integration
HippoProgrammer Jul 13, 2025
7060be2
Merge pull request #124 from The-CS-Nerds/vue-integration
HippoProgrammer Jul 13, 2025
b28f00e
blah
SuitablyMysterious Jul 14, 2025
681f41c
blahdiblah
SuitablyMysterious Jul 14, 2025
2963c17
THIS WILL HAVE CONFLICTS, DEFINITELY
HippoProgrammer Jul 14, 2025
86e5cb3
Fix Logto, basic cleanup
HippoProgrammer Jul 14, 2025
9cd0e97
Create launch script
HippoProgrammer Jul 14, 2025
74207b7
Merge remote-tracking branch 'origin/logto-integration' into logto-me…
HippoProgrammer Jul 14, 2025
58f5a4d
Merge pull request #128 from The-CS-Nerds/logto-merging
HippoProgrammer Jul 14, 2025
c0a7e06
update `getUserData` to use Casbin authorisation
SuitablyMysterious Jul 14, 2025
b4175e6
Merge pull request #129 from The-CS-Nerds/logto-integration
HippoProgrammer Jul 14, 2025
273f4a3
Fixing local clone
HippoProgrammer Jul 15, 2025
e35cb40
aaaaaaa
HippoProgrammer Jul 15, 2025
46bf6ff
more vue setup
SuitablyMysterious Jul 17, 2025
6bc6b98
update `index.html` to integrate vue
SuitablyMysterious Jul 18, 2025
72d9081
create a `header-row.vue` component - Create Vue structure in `frontend`
SuitablyMysterious Jul 18, 2025
824e363
create `login.vue` where logto needs to go - Create Vue structure in …
SuitablyMysterious Jul 18, 2025
42b1130
Merge pull request #132 from The-CS-Nerds/casbin-patch
SuitablyMysterious Jul 18, 2025
8446c22
update `frontend.dockerfile` to support javascript
SuitablyMysterious Jul 21, 2025
f5f0b3c
add port exposure to backend in `compose.yaml`
SuitablyMysterious Jul 28, 2025
eadc568
add `package.json`
SuitablyMysterious Jul 29, 2025
6bb563f
update `npm` command in `frontend.dockerfile`
SuitablyMysterious Jul 29, 2025
091b69b
redo `frontend` folder structure to satisfy vue
SuitablyMysterious Jul 29, 2025
71b196b
fix the capitalisation of `App.vue` in `main.js`
SuitablyMysterious Jul 29, 2025
ab12f23
update gitignore to exclude Python Portable Image
SuitablyMysterious Aug 1, 2025
9ce1115
fix `POSTGRES_PASSWORD` to use `DB_PASS` env variable
SuitablyMysterious Aug 1, 2025
f5fee50
add `-d` flag to `launch.sh`
SuitablyMysterious Aug 1, 2025
45fded1
allow extra argument for launch.sh
SuitablyMysterious Aug 1, 2025
17a651c
add a --kill argument to launch.sh
SuitablyMysterious Aug 1, 2025
0c12f8f
fix syntax errors in launch.sh
SuitablyMysterious Aug 1, 2025
da4e064
Fix changes copilot suggested in relation to PR #121
SuitablyMysterious Aug 2, 2025
7cb1266
Update src/backend/db.py
SuitablyMysterious Aug 2, 2025
956de5b
Update src/backend/db.py
SuitablyMysterious Aug 2, 2025
0ead47b
Merge pull request #121 from The-CS-Nerds/vue-integration
SuitablyMysterious Aug 2, 2025
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
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.py linguist-language=Python
*.sh linguist-language=Shell
*.sql linguist-language=SQL
*.Dockerfile linguist-language=Dockerfile
*.yaml linguist-language=YAML
*.md linguist-language=Markdown
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
** @the-cs-nerds/library-devs
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ logs/**
config/*.yaml
!config/example*
secrets/
*/__pycache__/**
*/__pycache__/**
Python-3.13.5/**
Python-3.13.5.tgz
Python3.13-Portable-Image/**
1 change: 1 addition & 0 deletions Python3.13-Portable-Image
Submodule Python3.13-Portable-Image added at 56bc8b
59 changes: 34 additions & 25 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# Docker Compose configuration

services:
frontend:
entrypoint: ["docker-entrypoint.sh"] # Frontend webapp

container_name: frontend
#image: library-system/frontend
build:
Expand All @@ -28,14 +27,14 @@ services:
- "443:443" # HTTPS traffic for serving webapp
networks:
- backend
- casdoor
- logto
restart: unless-stopped
depends_on:
backend:
condition: service_started
command: ["python","/src/__main__.py"]
backend: # Backend
entrypoint: ["docker-entrypoint.sh"]

container_name: backend
#image: library-system/backend
build:
Expand All @@ -44,53 +43,63 @@ services:
networks:
- backend
- db
- casdoor
restart: unless-stopped
environment:
DB_HOST: db
DB_PORT: 5432
command: ["python","/src/__main__.py"]
secrets:
- db_pass
depends_on:
db:
condition: service_healthy
ports:
- "8000:8000"
db: # Database
# entrypoint: ['docker-entrypoint.sh']
image: postgres:17.5-alpine3.21 # Using alpine Postgres image
container_name: db
networks:
- db
restart: unless-stopped
volumes:
- pgdata:/var/lib/postgresql/data
- db-init:/docker-entrypoint-initdb.d:ro # Init scripts for postgres
environment:
POSTGRES_USER: library
POSTGRES_PASSWORD_FILE: /run/secrets/db_pass
POSTGRES_USER: library
POSTGRES_PASSWORD: ${DB_PASS}
POSTGRES_DB: library

secrets:
- db_pass
- casbin_login_pass

healthcheck:
test: ["CMD", "pg_isready", "-U", "library"]
interval: 10s
retries: 5
casdoor:
image: casbin/casdoor:v1.960.0

logto:
depends_on:
db:
condition: service_healthy
image: svhd/logto:${TAG-latest}
entrypoint: ["sh", "-c", "npm run cli db seed -- --swe && npm start"]
ports:
- 3001:3001
- 3002:3002
environment:
- TRUST_PROXY_HEADER=1
- DB_URL=postgres://library:$DB_PASS@db:5432/library
- NODE_ENV=test
- PORT=3001
- ADMIN_PORT=3002
- ADMIN_ENDPOINT=http://localhost:3002
networks:
- casdoor
- db
- logto
restart: unless-stopped
depends_on:
backend:
condition: service_started

networks:
backend:
networks: # Frontend and DB MUST NEVER be on the same network.
backend: # For all containers that must communicate with backend. MUST include backend.
driver: bridge
db:
db: # For all containers that must communicate with the database. MUST include db. CANNOT include frontend.
driver: bridge
casdoor:
logto:
driver: bridge

volumes:
Expand All @@ -99,6 +108,6 @@ volumes:

secrets:
casbin_login_pass:
file: ./secrets/casbin_login_pass.txt
environment: CASBIN_LOGIN_PASS
db_pass:
file: ./secrets/db_pass.txt
environment: DB_PASS
53 changes: 0 additions & 53 deletions conf/app.conf

This file was deleted.

6 changes: 4 additions & 2 deletions db-init/0_roles.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

-- Create casbin role
CREATE ROLE casbin NOLOGIN;
CREATE ROLE casbin_login LOGIN PASSWORD 'SUBSTITUTE_PASSWORD';
CREATE ROLE casbin_login LOGIN PASSWORD :casbin_login_pass;
GRANT casbin TO casbin_login;

-- Create server admin, write and read roles
CREATE ROLE server_admin LOGIN PASSWORD 'SUBSTITUTE_PASSWORD';
CREATE ROLE server_write LOGIN PASSWORD 'SUBSTITUTE_PASSWORD';
CREATE ROLE server_read LOGIN PASSWORD 'SUBSTITUTE_PASSWORD';
CREATE ROLE server_read LOGIN PASSWORD 'SUBSTITUTE_PASSWORD';

CREATE ROLE zitadel LOGIN PASSWORD 'zitadel';
12 changes: 10 additions & 2 deletions db-init/1_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. */

CREATE TABLE IF NOT EXISTS books ( -- Needs to be updated in future
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
id UUID PRIMARY KEY,
isbn TEXT UNIQUE NOT NULL,
title TEXT NOT NULL,
author TEXT NOT NULL,
Expand All @@ -25,11 +25,19 @@ CREATE TABLE IF NOT EXISTS books ( -- Needs to be updated in future
);

CREATE TABLE IF NOT EXISTS loans ( -- Needs to be updated in future
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
id UUID PRIMARY KEY,
isbn TEXT NOT NULL REFERENCES books(isbn) ON UPDATE CASCADE,
student_id CHAR(4) NOT NULL REFERENCES users(student_id) ON UPDATE CASCADE,
borrowed_at TIMESTAMPTZ DEFAULT now(),
due_at DATE NOT NULL,
returned_at TIMESTAMPTZ
);

CREATE TABLE IF NOT EXISTS users (
id UUID PRIMARY KEY,
forename TEXT NOT NULL,
surname TEXT NOT NULL,
student_id INTEGER NOT NULL
Copy link

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma after 'student_id INTEGER NOT NULL' which will cause a SQL syntax error.

Suggested change
student_id INTEGER NOT NULL
student_id INTEGER NOT NULL,

Copilot uses AI. Check for mistakes.
email TEXT NOT NULL UNIQUE,
role TEXT NOT NULL,
);
26 changes: 20 additions & 6 deletions dbKeyGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,25 @@

from secrets import token_urlsafe
import os
from argparse import ArgumentParser

os.makedirs("secrets", exist_ok=True)
parser = ArgumentParser()
parser.add_argument("--keys",action='extend',nargs='+')
parser.add_argument("--print",action='store_true')
if parser.parse_args().print:
os.makedirs("secrets", exist_ok=True)
if 'db' in parser.parse_args().keys:
if parser.parse_args().print:
print(token_urlsafe(512))
else:
with open("secrets/db_pass.txt", "w") as f:
f.write(token_urlsafe(512))
os.remove("secrets/db_pass.txt")

with open("secrets/db_pass.txt", "w") as f:
f.write(token_urlsafe(512))

with open("secrets/casbin_login_pass.txt", "w") as f:
f.write(token_urlsafe(512))
if 'auth' in parser.parse_args().keys:
if parser.parse_args().print:
print(token_urlsafe(512))
else:
with open("secrets/casbin_login_pass.txt", "w") as f:
f.write(token_urlsafe(512))
os.remove("secrets/casbin_login_pass.txt")
32 changes: 0 additions & 32 deletions docker-entrypoint.sh

This file was deleted.

12 changes: 12 additions & 0 deletions launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
export DB_PASS=`python3 dbKeyGen.py --keys db --print`
export CASBIN_LOGIN_PASS=`python3 dbKeyGen.py --keys auth --print`
if [ $1 = "--kill" ]; then
docker compose down
docker system prune --force
exit 0
else
docker compose up --build $1
fi
unset DB_PASS
unset CASBIN_LOGIN_PASS
1 change: 1 addition & 0 deletions src/backend/auth/policy.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ p,librarian,books,book,delete,True
p,librarian,loans,loan,add,True
p,librarian,loans,loan,delete,True
p,student,books,book,read,True
p,*,books,book,read,False
p,admin,*,*,*,True
g,000000,0000,admin,admin,root
1 change: 0 additions & 1 deletion src/backend/auth/policySetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
DSN = f"postgresql+psycopg://{"casbin_login"}:{os.environ["CASBIN_LOGIN_PASS"]}@{os.environ["DB_HOST"]}:{os.environ["DB_PORT"]}/{os.environ["DB_NAME"]}"

engine = create_engine(DSN, future=True)
DSN.delete()
adapter = Adapter(engine)

enforcer = Enforcer(str(MODEL_PATH), adapter, auto_save=False)
Expand Down
6 changes: 4 additions & 2 deletions src/backend/backend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ WORKDIR /src
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir --require-hashes --force-reinstall -r requirements.txt

RUN adduser --disabled-password --gecos '' appuser \
&& chown -R appuser /src
RUN adduser --disabled-password --gecos '' appuser
USER appuser

ADD ./* ./

EXPOSE 8000

Loading
Loading