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

Add SMTP Email Service for LDAP User Notifications #1

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a1aee2b
chore: basic project scaffold
kedom1337 Sep 8, 2024
57f5c00
docs: added better README.md
kedom1337 Sep 8, 2024
a337cf0
chore: switched to postgresql and added diesel ORM
kedom1337 Sep 12, 2024
457f1b7
feat: added diesel migrations with db schema
kedom1337 Sep 13, 2024
1218e1f
feat: added tracing
kedom1337 Sep 13, 2024
45e2f35
fix: improve applications db schema
kedom1337 Sep 13, 2024
3fb962c
docs: improve wording
kedom1337 Sep 13, 2024
328dcc6
feat: finished diesel db setup, implemented `GET /application`
kedom1337 Sep 14, 2024
d82d7b5
Merge branch 'development' of github:kedom1337/applica into development
kedom1337 Sep 14, 2024
272b995
feat: added more CRUD handlers
kedom1337 Sep 15, 2024
f89dc3b
feat: improve error reporting
kedom1337 Sep 15, 2024
440f137
fix: remove unnecessary edit route
kedom1337 Sep 16, 2024
982d6f0
feat: began with API integration in frontend
kedom1337 Sep 16, 2024
0ba47a1
feat(frontend): added basic data fetching
kedom1337 Sep 19, 2024
5ac7054
feat(backend): improved data serializing
kedom1337 Sep 19, 2024
6ddb733
feat(backend): added courses to GET applications
kedom1337 Sep 21, 2024
cba289e
trying out sea query
kedom1337 Sep 22, 2024
04d2bb6
chore: last commit before giving up on rust (the state of SQL is horr…
kedom1337 Sep 28, 2024
cdfa8fb
feat(backend): moved to hono/drizzelorm stack
kedom1337 Sep 29, 2024
054c058
docs: add better `README.md`
kedom1337 Sep 29, 2024
c33402a
docs: improve dev instructions
kedom1337 Sep 29, 2024
2704a5f
feat(backend): improved API return values
kedom1337 Sep 29, 2024
ff91cbd
feat(frontend): finished basic overview page
kedom1337 Sep 29, 2024
1134533
feat(backend): improve/flatten return values
kedom1337 Oct 4, 2024
e8b6d78
feat(frontend): finished confirmation dialogs/feedback
kedom1337 Oct 4, 2024
1c605fd
feat(backend): use transaction for seed script
kedom1337 Oct 5, 2024
c57679d
feat(backend): improve return of POST /applications
kedom1337 Oct 5, 2024
620e781
feat(frontend): added new application dialog
kedom1337 Oct 5, 2024
e0c1223
feat(backend): improved types of PUT /applications
kedom1337 Oct 6, 2024
f5b1a8a
feat(frontend): finish new/edit application functionality
kedom1337 Oct 6, 2024
5c8e3a1
feat(frontend): added global http error reporting
kedom1337 Oct 6, 2024
853d75b
feat(backend): added /auth/login route logic
kedom1337 Oct 6, 2024
c07f9d7
feat(backend): use http-status-codes library for constants
kedom1337 Oct 6, 2024
3ae66e1
feat(backend): added jwt signing with guard
kedom1337 Oct 8, 2024
91f4342
feat(frontend): added jwt logic
kedom1337 Oct 8, 2024
1eb79dd
feat(backend): remove POST /applications from guard and improve docke…
kedom1337 Oct 9, 2024
cdcbe4d
feat(backend): added cors middleware
kedom1337 Oct 9, 2024
0f1f3c6
feat(frontend): added signout button
kedom1337 Oct 9, 2024
ecf99ad
feat(frontend): fix sass deprecation warning
kedom1337 Oct 9, 2024
0d94dff
feat(frontend): switched from scss to vanilla css
kedom1337 Oct 9, 2024
620d342
feat(backend): add missing env variable
kedom1337 Oct 9, 2024
e7a77a0
feat(backend): add drizzle-kit to normal deps
kedom1337 Oct 9, 2024
e72209c
feat(backend): removed drizzle.config from .dockerignore
kedom1337 Oct 9, 2024
538fe4e
feat(backend): added jwt verify route
kedom1337 Oct 12, 2024
cd126ab
feat(frontend): improved auth logic
kedom1337 Oct 12, 2024
e9a4c17
fix(frontend): properly handle failed auth validate
kedom1337 Oct 13, 2024
bf2d903
feat(backend): added ldap user add
kedom1337 Oct 13, 2024
a025b76
feat: mail support
GoliathLabs Oct 19, 2024
24a9646
Update lockfile
GoliathLabs Oct 19, 2024
9f3549b
fix: use getenv
GoliathLabs Oct 19, 2024
24ceea3
fix: smtp
GoliathLabs Oct 19, 2024
dcddc48
fix: remove redundant username
GoliathLabs Oct 19, 2024
2383302
feat: standard groups
GoliathLabs Oct 19, 2024
c18ad2d
fix: uid
GoliathLabs Oct 19, 2024
c77da58
fix: define groups
GoliathLabs Oct 19, 2024
b3156b5
Revert "fix: define groups"
GoliathLabs Oct 19, 2024
5aba949
Revert "fix: uid"
GoliathLabs Oct 19, 2024
07fe5c2
Revert "feat: standard groups"
GoliathLabs Oct 19, 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
21 changes: 21 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This .env file is supposed to be used during production
# Make sure to REPLACE the placeholders with your real values

# Use internal LDAP server by default
# When you want to use an external LDAP server, change the URL to the external server:
# LDAP_URL=ldap://external-ldap-server:389
LDAP_URL=ldap://ldap:389

# The root distinguished name (DN) for your LDAP directory
LDAP_BASE_DN=dc=applica,dc=com

# Admin password for LDAP server
LDAP_ADMIN_PASSWORD=admin

# The distinguished name (DN) of the group which holds users that
# are "leaders" of one or more fields. Used for mail notifications
# whenever a new application for a field gets added
LDAP_LEADER_DN=cn=fieldleader,ou=group,$LDAP_BASE_DN

# The secret used to sign the JWT payload
JWT_SECRET=verysecret
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# `Applica` 👥

A full-stack platform for managing user applications, designed for university clubs.

## Development

1. Start the required Docker containers with the `dev` profile:

```bash
sudo docker-compose --profile dev up -d
```

2. Run the frontend or backend:

- **Frontend** (`localhost:3000`):

```bash
cd frontend
bun install
bun run dev
```

- **Backend** (`localhost:8080/api`):

```bash
cd backend
bun install
bun run dev
```

## Production

1. Start the production containers with the `prod` profile:

```bash
sudo docker-compose --profile prod up -d
```

2. Make sure to configure your `.env` file with your LDAP URL.

This will launch the frontend, backend, and a PostgreSQL database.
9 changes: 9 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules

Dockerfile*
.dockerignore
.gitignore
README.md
.prettierrc.json
eslint.config.mjs
.env.development
15 changes: 15 additions & 0 deletions backend/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This .env is ONLY supposed to be used during development
# Together with the `dev` docker profile: `docker-compose --profile dev`

DATABASE_URL=postgres://postgres:password@localhost:5432/applica_db
LDAP_URL=ldap://localhost:389
LDAP_BASE_DN=dc=applica,dc=com
LDAP_ADMIN_PASSWORD=admin
LDAP_LEADER_DN=cn=fieldleader,ou=group,$LDAP_BASE_DN
JWT_SECRET=verysecret
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=your-email@example.com
SMTP_PASS=your-email-password
SMTP_FROM_NAME=Applica Admin
SMTP_FROM_EMAIL=your-email@example.com
175 changes: 175 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
7 changes: 7 additions & 0 deletions backend/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"printWidth": 80
}
21 changes: 21 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Base image
FROM oven/bun:1 AS base
WORKDIR /usr/src/app
ENV NODE_ENV=production

# Stage 1
FROM base AS install
# Install dependencies
COPY bun.lockb package.json ./
RUN bun install --frozen-lockfile --production

# Stage 2
FROM base AS release
# Copy artifacts
WORKDIR /app
COPY --from=install /usr/src/app/node_modules node_modules
COPY . .
# Run app with bun
USER bun
EXPOSE 8080/tcp
ENTRYPOINT ["bun", "run", "src/index.ts"]
11 changes: 11 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
To install dependencies:
```sh
bun install
```

To run:
```sh
bun run dev
```

open http://localhost:8080
Binary file added backend/bun.lockb
Binary file not shown.
10 changes: 10 additions & 0 deletions backend/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'drizzle-kit'

export default defineConfig({
dialect: 'postgresql',
schema: './src/db/schema.ts',
out: './src/db/migrations',
dbCredentials: {
url: process.env['DATABASE_URL'] as string,
},
})
16 changes: 16 additions & 0 deletions backend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import globals from 'globals'
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'

export default [
{ files: ['**/*.{js,mjs,cjs,ts}'] },
{
languageOptions: { globals: globals.browser },
rules: {
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
},
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
]
Loading