Skip to content

Commit

Permalink
Merge pull request #87 from serlo/big-merge-with-edusharing-integration
Browse files Browse the repository at this point in the history
Merge with `serlo-editor-for-edusharing`
  • Loading branch information
LarsTheGlidingSquirrel authored Oct 15, 2024
2 parents 48fbb8e + 3988b9a commit 91d2ed0
Show file tree
Hide file tree
Showing 31 changed files with 2,660 additions and 289 deletions.
25 changes: 0 additions & 25 deletions .env-template

This file was deleted.

27 changes: 27 additions & 0 deletions .env.local.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Template - Copy content to `.env` file and add missing (secret) values

# Set this to 'local' in local development.
# - sets origin to localhost
# - configures cookie handling
ENVIRONMENT=local

EDITOR_URL=http://localhost:3000/

# Secret to enable media upload
SERLO_EDITOR_TESTING_SECRET=

# Symmetric HS256 key used by ltijs to sign ltik and database entries & to sign the jwt access token
LTIJS_KEY=DONOTUSETHISKEYINPRODUCTION

MYSQL_URI=mysql://root:secret@mariadb:3306/serlo

# https://www.mongodb.com/docs/drivers/go/current/fundamentals/connections/connection-guide/#connection-uri
MONGODB_URI=mongodb://mongo:27017/

# LTI platform: https://saltire.lti.app/platform
ALLOW_SALTIRE=true

# LTI platform: edu-sharing mock
ALLOW_EDUSHARING_MOCK=true

# Keep an empty line at the end
31 changes: 31 additions & 0 deletions .env.uberspace.edtr.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Template - Copy content to `.env` file and add missing (secret) values

EDITOR_URL=https://edtr.uber.space/

# Secret to enable media upload
SERLO_EDITOR_TESTING_SECRET=

# Symmetric HS256 key used by ltijs to sign ltik and database entries & to sign the jwt access token
LTIJS_KEY=

# LTI platform: itslearning
ITSLEARNING_URL=
ITSLEARNING_NAME=
SERLO_EDITOR_CLIENT_ID_ON_ITSLEARNING=
ITSLEARNING_AUTHENTICATION_ENDPOINT=
ITSLEARNING_ACCESS_TOKEN_ENDPOINT=
ITSLEARNING_KEYSET_ENDPOINT=

# LTI platform: edu-sharing (RLP)
EDUSHARING_RLP_URL=
EDUSHARING_RLP_NAME=
SERLO_EDITOR_CLIENT_ID_ON_EDUSHARING_RLP=
EDUSHARING_RLP_AUTHENTICATION_ENDPOINT=
EDUSHARING_RLP_ACCESS_TOKEN_ENDPOINT=
EDUSHARING_RLP_KEYSET_ENDPOINT=

# LTI tool: edu-sharing (RLP)
EDUSHARING_RLP_LOGIN_ENDPOINT=
EDUSHARING_RLP_LAUNCH_ENDPOINT=
EDUSHARING_RLP_CLIENT_ID_ON_SERLO_EDITOR=
EDUSHARING_RLP_DETAILS_ENDPOINT=
12 changes: 12 additions & 0 deletions .env.uberspace.edtrdev.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Template - Copy content to `.env` file and add missing (secret) values

EDITOR_URL=https://edtrdev.uber.space/

# Secret to enable media upload
SERLO_EDITOR_TESTING_SECRET=

# Symmetric HS256 key used by ltijs to sign ltik and database entries & to sign the jwt access token
LTIJS_KEY=DONOTUSETHISKEYINPRODUCTION

# LTI platform: https://saltire.lti.app/platform
ALLOW_SALTIRE=true
34 changes: 34 additions & 0 deletions .env.uberspace.edtrstag.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Template - Copy content to `.env` file and add missing (secret) values

EDITOR_URL=https://edtrstag.uber.space/

# Secret to enable media upload
SERLO_EDITOR_TESTING_SECRET=

# Symmetric HS256 key used by ltijs to sign ltik and database entries & to sign the jwt access token
LTIJS_KEY=DONOTUSETHISKEYINPRODUCTION

# LTI platform: https://saltire.lti.app/platform
ALLOW_SALTIRE=true

# LTI platform: itslearning (staging)
ITSLEARNING_URL=
ITSLEARNING_NAME=
SERLO_EDITOR_CLIENT_ID_ON_ITSLEARNING=
ITSLEARNING_AUTHENTICATION_ENDPOINT=
ITSLEARNING_ACCESS_TOKEN_ENDPOINT=
ITSLEARNING_KEYSET_ENDPOINT=

# LTI platform: edu-sharing (RLP) (staging)
EDUSHARING_RLP_URL=
EDUSHARING_RLP_NAME=
SERLO_EDITOR_CLIENT_ID_ON_EDUSHARING_RLP=
EDUSHARING_RLP_AUTHENTICATION_ENDPOINT=
EDUSHARING_RLP_ACCESS_TOKEN_ENDPOINT=
EDUSHARING_RLP_KEYSET_ENDPOINT=

# LTI tool: edu-sharing (RLP) (staging)
EDUSHARING_RLP_LOGIN_ENDPOINT=
EDUSHARING_RLP_LAUNCH_ENDPOINT=
EDUSHARING_RLP_CLIENT_ID_ON_SERLO_EDITOR=
EDUSHARING_RLP_DETAILS_ENDPOINT=
12 changes: 3 additions & 9 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: cp .env-template .env
- run: docker compose up mysql mongo -d
- run: sleep 30
- run:
yarn mysql -e "CREATE TABLE lti_entity ( id bigint, resource_link_id
varchar(255), custom_claim_id varchar(255), content longtext,
id_token_on_creation text )"
- run: cp .env.local.template .env
- run: yarn dev -d
- run: yarn build
- run: docker compose up express -d
- run: sleep 2
- run: sleep 15
- run: yarn playwright install
- run: HEADLESS=true yarn test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# output folder of e2e tests
output

# .env - Should not be added because it contains private keys used for encryption
# .env - Should not be added because they might contain secrets
.env

# Logs
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
FROM node:20.18.0
WORKDIR /usr/src/app

RUN apt update && apt install neovim nano -y

COPY . .
RUN yarn install --immutable

Expand Down
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
Serlo editor as LTI tool Status: Early prototype
Prototype: Serlo editor as LTI tool

# Local dev setup

Requirements:

- Docker & Docker Compose
- Docker 26.0.0 or later

1. Create file `.env` and copy content from `.env-template`
2. `yarn` to install dependencies
3. `yarn dev` to start docker containers (hot reload)
4. Go to https://saltire.lti.app/platform, sign in, navigate to "Advanced
1. Create a copy of `.env.local.template` as `.env`
2. (optional) Add secret values to `.env`
3. `yarn` to install dependencies
4. `yarn dev` to start docker containers

Now, the editor is running locally. It will automatically restart when files get
modified.

## Launch through Saltire

1. Go to https://saltire.lti.app/platform, sign in, navigate to "Advanced
options" and upload file `saltire-platform_[TYPE].config` of the
[`saltire-configs/`](./saltire-configs) directory. `TYPE=LTIDeepLinking`
shows flow of creating a new Serlo Editor element.
`TYPE=LTIResourceLink_Instructor` shows flow of opening an existing Serlo
Editor element as Instructor (editable). `TYPE=LTIResourceLink_Learner` shows
flow of opening an existing Serlo Editor element as Learner (non-editable).
5. Click "Connect"
2. Click "Connect"

## Launch through edu-sharing mock

The editor should open in a new tab.
1. `yarn dev:edusharing` to start the edu-sharing mock
2. Open `http://localhost:8100`

# Technical details

Expand Down
45 changes: 25 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Shared network 'express-mongo-mysql' makes service 'mongo' & 'mysql' available to service 'express'. You can connect using the service name in MONGODB_CONNECTION_URI like this: mongodb://[SERVICE_NAME]:27017/
# Shared network 'express-mongo-mariadb' makes service 'mongo' & 'mariadb' available to service 'express'. You can connect using the service name in MONGODB_URI like this: mongodb://[SERVICE_NAME]:27017/

services:
express:
Expand All @@ -7,37 +7,42 @@ services:
dockerfile: Dockerfile.dev
env_file: '.env'
depends_on:
- mongo
- mysql
mongo:
condition: service_started
mariadb:
condition: service_healthy
networks:
- express-mongo-mysql
- express-mongo-mariadb
expose:
- 3000
ports:
- 3000:3000
develop:
watch:
# TODO: Sync would be faster but harder to setup.
# - action: sync
# path: ./src
# target: /usr/src/app/src
# ignore:
# - node_modules/
- action: rebuild
path: .
extra_hosts:
- 'host.docker.internal:host-gateway'
mongo:
image: mongo:7.0.11
image: mongo:6
networks:
- express-mongo-mysql
- express-mongo-mariadb
expose:
- 27017
mysql:
image: ghcr.io/serlo/serlo-mysql-database:latest
platform: linux/x86_64
pull_policy: always
ports:
- '3306:3306'
mariadb:
image: mariadb:10 # Match major version on Uberspace
environment:
- MARIADB_DATABASE=serlo
- MARIADB_PASSWORD=secret
- MARIADB_ROOT_PASSWORD=secret
# https://mariadb.com/kb/en/using-healthcheck-sh/
healthcheck:
test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
start_period: 10s
interval: 10s
timeout: 5s
retries: 3
networks:
- express-mongo-mysql
- express-mongo-mariadb
networks:
express-mongo-mysql:
express-mongo-mariadb:
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export default [
},
},

{ ignores: ['dist/**'] },

// Our custom rules
ourCustomConfig,
]
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@
"build:backend": "esbuild ./src/backend/index.ts --bundle --platform=node --outfile=dist/backend/index.cjs",
"build:frontend": "vite build",
"dev": "docker compose up --watch --build",
"dev:edusharing": "dotenvx run --env-file=.env -- tsx --watch src/edusharing-server/start-server.ts",
"format": "npm-run-all --sequential --continue-on-error \"format:*\"",
"format:eslint": "eslint --fix",
"format:prettier": "prettier . --write",
"mysql": "docker compose exec mariadb mysql",
"lint": "npm-run-all --parallel \"lint:*\"",
"lint:eslint": "eslint",
"lint:prettier": "prettier --check .",
"lint:tsc": "tsc --noEmit",
"mysql": "docker compose exec mysql serlo-mysql",
"mysql:rollback": "docker compose exec mysql sh -c \"pv /docker-entrypoint-initdb.d/001-init.sql | serlo-mysql\"",
"push-image": "yarn tsx push-image.ts",
"push-image:dev": "yarn push-image dev",
"push-image:latest": "yarn push-image latest",
"start:dev": "tsx --watch src/backend/index.ts",
"start": "node dist/backend/index.cjs",
"test": "codeceptjs run"
},
"dependencies": {
"@serlo/editor": "0.14.0",
"dotenv": "^16.4.5",
"@serlo/editor": "0.16.0",
"express": "^4.19.2",
"fp-ts": "2.16.9",
"io-ts": "^2.2.21",
"jsonwebtoken": "9.0.2",
"jwt-decode": "4.0.0",
"lodash": "^4.17.21",
"ltijs": "^5.9.5",
"mongodb": "5.1.0",
"mysql2": "^3.11.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tsx": "4.19.1",
"typescript": "^5.6.2",
"url-join": "^5.0.0",
"uuid": "^10.0.0"
},
"devDependencies": {
"@dotenvx/dotenvx": "^1.14.2",
"@eslint/compat": "^1.1.1",
"@eslint/js": "^9.12.0",
"@types/jsonwebtoken": "9.0.6",
"@types/lodash": "^4",
"@types/ltijs": "4.0.11",
"@types/multer": "^1",
"@types/node": "^22.7.4",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
Expand All @@ -58,11 +58,16 @@
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.12",
"globals": "^15.10.0",
"json-web-key": "^0.4.0",
"jwks-rsa": "^3.1.0",
"multer": "^1.4.5-lts.1",
"npm-run-all": "^4.1.5",
"playwright": "^1.47.2",
"prettier": "3.3.3",
"prettier-plugin-packagejson": "^2.5.2",
"ts-node": "^10.9.2",
"tsx": "4.19.1",
"typescript": "^5.6.2",
"typescript-eslint": "^8.8.0",
"vite": "^5.4.3"
},
Expand Down
Loading

0 comments on commit 91d2ed0

Please sign in to comment.