Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
35c2739
First commit on developing AuthMD, a CodiMD fork.
lamprosfasoulas Jan 22, 2025
5dfd3b9
Update README.md
lamprosfasoulas Jan 22, 2025
fd6f3d6
Update push-image.yml
lamprosfasoulas Jan 22, 2025
2ca4538
Update build.yml
lamprosfasoulas Jan 22, 2025
c73288d
minor changes
lamprosfasoulas Jan 22, 2025
50230bb
Added logo to the window title bar
lamprosfasoulas Jan 23, 2025
9445791
Modified workflow for nexus
lamprosfasoulas Jan 23, 2025
3ab03e4
Update push-image.yml
lamprosfasoulas Jan 23, 2025
deff0e8
Update push-image.yml
lamprosfasoulas Jan 23, 2025
5890bf6
Update push-image.yml
lamprosfasoulas Jan 23, 2025
43429fd
edited title bar icons
lamprosfasoulas Jan 24, 2025
e2e5398
testing actions with api
lamprosfasoulas Jan 25, 2025
2e0d9d7
edit me before pushing
lamprosfasoulas Mar 12, 2025
5261906
almost ready for testing
lamprosfasoulas Mar 13, 2025
71b2117
first test
lamprosfasoulas Mar 19, 2025
4ccaee6
Merge pull request #1 from lamprosfasoulas/develop
lamprosfasoulas Mar 19, 2025
ea4cff5
minor edit to dockerfile
lamprosfasoulas Mar 19, 2025
924dff1
Merge pull request #2 from lamprosfasoulas/develop
lamprosfasoulas Mar 19, 2025
3fec064
Update Dockerfile
lamprosfasoulas Mar 19, 2025
e1b38e6
Update Dockerfile
lamprosfasoulas Mar 19, 2025
444d840
Update Dockerfile -- hopes and prayers
lamprosfasoulas Mar 19, 2025
c9c9ea4
Update Dockerfile -- root
lamprosfasoulas Mar 19, 2025
69b0ebe
Update Dockerfile
lamprosfasoulas Mar 19, 2025
d5a1be1
Update Dockerfile
lamprosfasoulas Mar 19, 2025
1e87379
Update Dockerfile
lamprosfasoulas Mar 19, 2025
ba80b40
Update Dockerfile
lamprosfasoulas Mar 19, 2025
8136543
Update Dockerfile -- test new image
lamprosfasoulas Mar 19, 2025
fb969e0
Update Docker file test test
lamprosfasoulas Mar 19, 2025
34820fb
Update Dockerfile -- typo
lamprosfasoulas Mar 19, 2025
4b4424d
Update Dockerfile
lamprosfasoulas Mar 19, 2025
2d6caab
Update Dockerfile
lamprosfasoulas Mar 19, 2025
5700bb0
Update Dockerfile
lamprosfasoulas Mar 19, 2025
b65985a
Update Dockerfile
lamprosfasoulas Mar 19, 2025
504e6c3
Update Dockerfile -- final?
lamprosfasoulas Mar 19, 2025
3da2219
using bash script for deleting
lamprosfasoulas Mar 19, 2025
cd83be6
Merge pull request #3 from lamprosfasoulas/develop
lamprosfasoulas Mar 19, 2025
d0cb587
moved user to pass env
lamprosfasoulas Mar 19, 2025
2354b5b
Merge remote-tracking branch 'upstream/develop' into develop
lamprosfasoulas Mar 19, 2025
1356b32
Merge pull request #4 from lamprosfasoulas/dev2
lamprosfasoulas Mar 19, 2025
b673d28
probably the final version
lamprosfasoulas Mar 19, 2025
bf2f7a5
Merge pull request #5 from lamprosfasoulas/develop
lamprosfasoulas Mar 19, 2025
f02ba95
version 1.1.0 -- added date for script
lamprosfasoulas Mar 19, 2025
7f42aa5
Merge pull request #6 from lamprosfasoulas/develop
lamprosfasoulas Mar 20, 2025
6b1b6ab
checkusers.sh error fix
lamprosfasoulas Apr 2, 2025
e3f26d2
fixed export pdf problems and container user
lamprosfasoulas Apr 6, 2025
237967c
Update Dockerfile -- port
lamprosfasoulas Apr 6, 2025
907fdcd
Update Dockerfile
lamprosfasoulas Apr 6, 2025
91a8622
fixed pandoc export docx with filesystem images
lamprosfasoulas Apr 6, 2025
9e117c0
Modified checkusers.sh to move expired users' data to trash
lamprosfasoulas Apr 9, 2025
4eae825
new workflow
lamprosfasoulas Apr 29, 2025
521aaff
mermaid update
lamprosfasoulas May 6, 2025
a93efc9
Update push-k8s-image.yml
lamprosfasoulas May 6, 2025
b2d6ea7
fix error where during user deletion script tries to creat filename w…
lamprosfasoulas Feb 6, 2026
d1143e7
Merge pull request #7 from lamprosfasoulas/cron/checkusers
lamprosfasoulas Feb 9, 2026
e4e0da3
update dockerfile
lamprosfasoulas Feb 9, 2026
b904416
Merge branch 'master' into develop
lamprosfasoulas Feb 9, 2026
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
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: 'Test and Build'

on:
push:
pull_request:
workflow_dispatch:

jobs:
Expand Down
84 changes: 14 additions & 70 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,15 @@ on:
default: 'hackmdio/buildpack:16.20.2-35fe7e39'

env:
REGISTRY_IMAGE: hackmdio/hackmd
REGISTRY_IMAGE: demo-images/codimd

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
-
name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
run: echo "PLATFORM_PAIR=linux-amd64" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v4
Expand All @@ -51,73 +43,25 @@ jobs:
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
username: ${{ secrets.NEXUS_USERNAME }}
password: ${{ secrets.NEXUS_PASSWORD }}
registry: ${{ secrets.NEXUS_REGISTRY }}
-
name: Build and push by digest
name: Build and push
id: build
uses: docker/build-push-action@v5
with:
context: .
file: ./deployments/Dockerfile
platforms: ${{ matrix.platform }}
platforms: linux/amd64
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
tags: |
${{ secrets.NEXUS_REGISTRY }}/${{ env.REGISTRY_IMAGE }}:latest
${{ secrets.NEXUS_REGISTRY }}/${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

build-args: |
RUNTIME=${{ github.event.inputs.runtime || 'hackmdio/runtime:16.20.2-35fe7e39' }}
BUILDPACK=${{ github.event.inputs.buildpack || 'hackmdio/buildpack:16.20.2-35fe7e39' }}
-
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
-
name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
-
name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=match,pattern=\d.\d.\d
type=sha,prefix=
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
push: true
58 changes: 58 additions & 0 deletions .github/workflows/push-k8s-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build and Push k8s Image

on:
workflow_dispatch:
inputs:
runtime:
description: 'Runtime image'
required: true
default: 'hackmdio/runtime:16.20.2-35fe7e39'
buildpack:
description: 'Buildpack image'
required: true
default: 'hackmdio/buildpack:16.20.2-35fe7e39'
release:
types: [published]

env:
REGISTRY_IMAGE: demo-images/codimd
jobs:
build-and-push:
if: startsWith(github.event.release.tag_name, 'k8s-v')
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v3
with:
ref: k8s

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker registry
uses: docker/login-action@v3
with:
username: ${{ secrets.NEXUS_USERNAME }}
password: ${{ secrets.NEXUS_PASSWORD }}
registry: ${{ secrets.NEXUS_REGISTRY }}

- name: Determine tag
id: tag
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "IMAGETAG=k8s-${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "IMAGETAG=k8s-latest" >> $GITHUB_OUTPUT
fi

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: deployments/Dockerfile
push: true
tags: ${{ secrets.NEXUS_REGISTRY }}/${{ env.REGISTRY_IMAGE }}:${{ steps.tag.outputs.IMAGETAG }}
build-args: |
RUNTIME=${{ github.event.inputs.runtime || 'hackmdio/runtime:16.20.2-35fe7e39' }}
BUILDPACK=${{ github.event.inputs.buildpack || 'hackmdio/buildpack:16.20.2-35fe7e39' }}
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

name: Hello world test action

on:
workflow_dispatch:

jobs:
say-hello:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Hello world
run: echo "Hello world"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
CodiMD
===

### This is a fork of the original CodiMD project. The original project can be found [here](https://github.com/hackmdio/codimd).

[![build status][build-image]][build-url]

[![version][github-version-badge]][github-release-page]
[![Gitter][gitter-image]][gitter-url]
[![Matrix][matrix-image]][matrix-url]
Expand Down
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CodiMD",
"description": "Realtime collaborative markdown notes on all platforms",
"name": "AuthMD",
"description": "Fork of CodiMD",
"keywords": [
"Collaborative",
"Markdown",
Expand Down
105 changes: 105 additions & 0 deletions bin/checkusers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash
# The script uses Cronjob to run once a day to check for expired users
# It is vital to have RUN env > /etc/environment in Dockerfile so that
# cronjob can have access to env variables from docker
. /home/hackmd/cron.env
UPLOADS_DIR="/home/hackmd/app/public/uploads"
TRASH_DIR="/home/hackmd/trash"

isActive() {
if ! ldapres=$(ldapsearch -x -H $CMD_LDAP_URL -D "$CMD_LDAP_BINDDN" -w $CMD_LDAP_BINDCREDENTIALS -b $CMD_LDAP_SEARCHBASE $query 2>/dev/null); then
echo "Ldap is DOWN. Exiting..."
exit 1
fi
if echo "$ldapres" | grep -q -e "^uid:"; then
return 0
else
return 1
fi
}

deleteUser(){
# Deleting users from postgres database
local profileid="$1"
psql $CMD_DB_URL <<-SQL
DELETE FROM "Users" WHERE profileid = '${profileid}';
SQL
}

deleteNotes(){
# Deleting all user's notes from postgres database and moving them to
# trash can
shortids=$(psql $CMD_DB_URL -At<<-SQL
SELECT shortid FROM "Notes" where "ownerId" = '${id}';
SQL
)
while IFS=' ' read shortid; do
title=$(psql $CMD_DB_URL -At<<-SQL
SELECT title FROM "Notes" where shortid = '${shortid}';
SQL
)
safe_title=$(echo "$title" | tr -cd '[:alnum:]._-')
filename="${USER_TRASH_DIR}/${safe_title}.md"

content=$(psql $CMD_DB_URL -At<<-SQL
SELECT content FROM "Notes" WHERE shortid = '${shortid}';
SQL
)

echo "$content" > "$filename"
done<<<"$shortids"

psql $CMD_DB_URL <<-SQL
DELETE FROM "Notes" where "ownerId" = '${id}';
SQL
}

deleteFiles(){
# Deleting all user's uploads from location /home/hackmd/app/public/uploads
# The files are saved as upload_{user.id}_{random letters}.{jpg,png,...}
find $UPLOADS_DIR -type f -name "upload_${id}_*" -exec mv {} "$USER_TRASH_DIR" \; 2>&1
}

actuallyDeleteFiles(){
# Deleting all user's uploads from location /home/hackmd/app/public/uploads
# The files are saved as upload_{user.id}_{random letters}.{jpg,png,...}

echo "Removing old trash files"
find $TRASH_DIR -mindepth 1 -maxdepth 1 -type d -mtime +90 -exec rm -rf {} \; 2>&1
}

# Write down the date-time
date
# Removing old trash files
actuallyDeleteFiles
allusers=$(psql $CMD_DB_URL -t -c 'SELECT profileid FROM "Users";')
if [ -z "$allusers" ]; then
echo "Ha Ha nothing to delete"
exit
fi
while IFS=' ' read -r username; do
# Extracting the username (removing LDAP- prefix)
uid=$(echo $username | cut -d '-' -f2)
# Creating the ldap search query
query=$(echo $CMD_LDAP_SEARCHFILTER | sed "s#{{username}}#${uid}#")
id=$(psql $CMD_DB_URL -t -A <<-SQL
SELECT id FROM "Users" WHERE profileid = '${username}';
SQL
)
# Check if the user exists in the ldap as active user
if isActive; then
echo "The account $uid is active"
else
echo "The account $uid must be destroyed"
# This will be the user specific trash can
USER_TRASH_DIR=${TRASH_DIR}/${uid}
echo "Moving to Trash ${USER_TRASH_DIR}..."
mkdir -p $USER_TRASH_DIR
# These functions move uploads and notes to trash can
# and delete them permanently after 90 days
deleteUser $username
deleteNotes
deleteFiles

fi
done <<< "$allusers"
Loading