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 support for Moodle/LTI and email/password-based authentication #362

Open
wants to merge 163 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
2a51fc9
lti: use a form to properly send the token
agrn Jun 12, 2020
185fec8
CSRF
agrn Jun 24, 2020
68da792
learnocaml_server: add a mechanism to redirect to another page
agrn Jul 6, 2020
0ad4060
/launch: let the server fill the form in launch.html itself
agrn Jul 6, 2020
b4a144a
learnocaml_index_main: read the token in the cookies if it is set
agrn Jul 6, 2020
759c60d
server: generate an HMAC to validate a first login with LTI
agrn Jul 7, 2020
6b9fef3
launch.html: does not request credentials if a user is already authen…
agrn Jul 7, 2020
f7c25ea
launch: add a way to create a new user during an LTI launch
agrn Jul 8, 2020
dabe34f
app: change the login dialog
agrn Jun 8, 2020
140eb95
token_index: add oauth index module
agrn Jul 14, 2020
c504f6c
token_index: add oauth validation code
agrn Jul 15, 2020
fd5058d
app: add an interface to link a moodle account to a learn-ocaml account
agrn Jun 10, 2020
86b5c52
learnocaml_data: add configs options to enable/disable LTI and passwords
agrn Jul 17, 2020
82f6dc5
token_index: add UserIndex module
agrn Jul 20, 2020
a49e606
API: add endpoints to register with a nick/password pair
agrn Jul 20, 2020
4683f42
Add forms to register and login with a nick/password pair
agrn Jul 20, 2020
a7b9720
index.html: add a "nickname" field in the register form
agrn Jul 22, 2020
43d8b68
learnocaml_index_main: properly logout when connected with LTI
agrn Jul 22, 2020
552946d
lti: setup new forms to login with a login/password pair
agrn Jul 22, 2020
e8c06ce
server: implement direct LTI login, email/password login
agrn Jul 24, 2020
275ef9c
server: add an endpoint to check if a given token can be used for login
agrn Jul 24, 2020
fbc8666
learnocaml_index_main: don't show the token if it can't be used to login
agrn Jul 24, 2020
6acc3b6
learnocaml_main: generate and print the OAuth token
agrn Jul 27, 2020
3fb8acd
token_index: various cleanups related to Cryptokit
agrn Jul 27, 2020
0d61ddd
Reinstate the token register form when `use_passwd' is disabled
agrn Jul 28, 2020
3654a26
learnocaml_client: add a command to authenticate with a password
agrn Jul 28, 2020
8758049
fix: Add missing deps
erikmd Jul 28, 2020
628c55d
feat: Add learnocaml_sendmail.mli
erikmd Jul 28, 2020
8607024
learnocaml_index_main: don't crash if `can_show_token' is not stored
agrn Jul 28, 2020
c30efab
lwt_utils: add a `is_directory' function
agrn Jul 28, 2020
64397d4
token_index: move index files into a subdirectory (`data')
agrn Jul 28, 2020
1ce9aed
token_index: add a `verify_email' column in the user index
agrn Jul 28, 2020
5c8218a
token_index: add a new index to store password resets and email changes
agrn Jul 28, 2020
72a1408
feature: send an email to validate the address when registering
agrn Jul 29, 2020
54a14da
feat: send an email when clicking on the "forgot your password?" link
agrn Jul 29, 2020
914c649
feature: add a form to reset a password
agrn Jul 29, 2020
4f65b5f
server: add an enpoint to initiate a password change from a token
agrn Jul 29, 2020
4ea449e
server: add an endpoint to initiate an email address change
agrn Jul 30, 2020
341f3b6
learnocaml_index_main: add buttons and forms to change email and pass…
agrn Jul 30, 2020
a6de979
fix: Add gmp (alpine dependency) for cryptokit
erikmd Jul 30, 2020
27bd23d
feature: add a form to upgrade a token to an account
agrn Jul 30, 2020
34a2e3c
server: advertise the `use_passwd' and `use_moodle' options when star…
agrn Jul 30, 2020
ccb6e64
Add a clean dialog box to indicate that an address has been confirmed
agrn Jul 30, 2020
cee8896
feature: validate consent checkboxes
agrn Jul 31, 2020
e34f784
Add a text to clarify the secret on both register forms
agrn Jul 31, 2020
5b09899
server: remove references to "http://localhost:8080"
agrn Jul 31, 2020
731b361
po: update french translations
agrn Jul 31, 2020
630d7ed
doc: first draft for the password and LTI modes
agrn Jul 31, 2020
a219669
learnocaml_index_main: allow user to cancel the change email dialog
agrn Jul 31, 2020
d622ef6
feat: Add support for sendmail
erikmd Jul 31, 2020
48485ab
feat: Add docker-compose.dev.yml file to test the sendmail feature
erikmd Jul 31, 2020
2847c36
Add token's indexation
Aleridia Jun 4, 2020
23fc260
Token idexation completed
Aleridia Jun 5, 2020
447642a
Change interface's name
Aleridia Jun 5, 2020
7061166
Change token.json's location
Aleridia Jun 5, 2020
79fb950
Minor changes
Aleridia Jun 5, 2020
f375e0a
Update PR
Aleridia Jun 8, 2020
a98351b
chore: Ignore learn-ocaml-client.install
erikmd Jun 9, 2020
331072b
Change files due to PR in ocaml-sf
Aleridia Jun 10, 2020
3d750ec
refactor: Token_index
erikmd Jun 16, 2020
0e2a77a
token_index: rewrite to use Ezjsonm instead of Yojson
agrn Jul 10, 2020
fee06ee
token_index: rewrite using modules
agrn Jul 10, 2020
7b899f1
token_index: add moodle index module
agrn Jul 14, 2020
896b609
Set ALWAYS_ADD_MISSING_HEADERS := yes
erikmd Aug 26, 2020
1131d59
docs: Add hyperlink to docker-compose.yml template
erikmd Aug 26, 2020
adc9729
refactor: Rename file to docker-compose.yml
erikmd Aug 26, 2020
474223f
feat: Add Moodle containers in dev docker-compose.yml
erikmd Aug 26, 2020
86bb1b0
feat: Add nickname in emails openings & Refactor Learnocaml_sendmail
erikmd Aug 26, 2020
e3d4a25
feat: Switch to HTML5 emails (Content-Type: multipart/alternative)
erikmd Aug 26, 2020
df97f04
refactor: s/Format/Printf/ & Improve log
erikmd Aug 26, 2020
c902598
feat: Display the (new) email address on {password, email}-change
erikmd Aug 26, 2020
eb1f669
fix: Make strings uniform: s/email/e-mail/
erikmd Aug 26, 2020
5d531a5
docs: Rename some labels
erikmd Aug 26, 2020
f4d0a9d
feat: Make the upgrade-button more visible
erikmd Aug 26, 2020
0296f6c
fix: Make email validation check more strict and uniform
erikmd Aug 27, 2020
8103091
refactor: Uniformize message prefix in log
erikmd Aug 29, 2020
fbf2d95
refactor: Split BaseUserIndex.upgrade in two functions
erikmd Aug 29, 2020
b3a5e45
fix(low-level module BaseUserIndex): Document/Check email invariants
erikmd Aug 29, 2020
67d8785
refactor(token_index.ml): s/name/email/ for readability
erikmd Aug 29, 2020
1ab9a05
fix(Api.Upgrade): check (at high-level) if E-mail already used
erikmd Aug 29, 2020
c52678e
fix: check email length
erikmd Aug 31, 2020
9fba3fc
fix: Avoid error if "/sync" does not exist
erikmd Sep 1, 2020
8f30481
fix: Avoid "TOKEN NOT FOUND" error
erikmd Sep 1, 2020
83ee3b7
fix: Make messages uniform for email-based login and password reset
erikmd Sep 1, 2020
abe19d3
refactor(index.html): Move "login-returning" before "login-new"
erikmd Sep 1, 2020
d2659bb
refactor(_main.ml): Change two strings
erikmd Sep 1, 2020
eea254f
fix: Add check_email_ml test
erikmd Sep 1, 2020
966f168
api: don't return the token of a newly created account
agrn Sep 1, 2020
ecdc59f
learnocaml_common: hide the dialog box first, then call the callback
agrn Sep 1, 2020
efeb108
index_main: the token cookie has priority over the local storage
agrn Sep 2, 2020
c6cddda
index.html: Uniformize type="email", type="password" & "Nickname" inputs
erikmd Sep 3, 2020
82e9d68
index_main: make reset_password use check_email_js before calling server
erikmd Sep 3, 2020
5f615dd
fix(MoodleIndex): Add a colon to avoid any potentiel clash
erikmd Sep 3, 2020
0052474
lti-main: Refactor /launch page
erikmd Sep 3, 2020
55b2ea1
docs: s/OAuth token/LTI shared secret/
erikmd Sep 3, 2020
3a6cdab
token_index: reset password operations older than 4 hours are invalid
agrn Sep 3, 2020
b58b0f5
server: revoke reset password operations older than 1 month
agrn Sep 3, 2020
4c36a99
server_config.json: allow bool values to be specified with strings
agrn Sep 3, 2020
2f3aea3
config: add an `enableMoodle' value to `learnocaml_config'
agrn Sep 3, 2020
b5b9fad
index: change the message when trying to login with an upgraded token
agrn Sep 3, 2020
7224bd5
translations/fr.po: update translations
agrn Sep 3, 2020
1166e31
feat: Add simple password strength evaluation
erikmd Sep 8, 2020
46505b0
fix(token_index.ml): Simplify & Fix the expiration check
erikmd Sep 8, 2020
562ae5e
[learnocaml_sendmail.ml] Mention that the reset-password link expires
erikmd Sep 8, 2020
831001a
fix: Check password strength at server side as well
erikmd Sep 8, 2020
b1422b7
fix: Update translations/fr.po
erikmd Sep 8, 2020
0492d7a
fix: fr.po & spacing issue
erikmd Sep 8, 2020
d942587
fix: translation bug; s/Upgrade account/Setup a password/
erikmd Sep 8, 2020
fd520f1
refactor: s/token/account/
erikmd Sep 8, 2020
94d15b0
docs: further document the semantics of user.json
erikmd Sep 8, 2020
3aeb65b
feat(token_index.ml): Add some simple, future-proof file-format versi…
erikmd Sep 8, 2020
921d100
feat: Make the need for email confirmation (and error) more explicit
erikmd Sep 8, 2020
98267b4
refactor: Improve validation message
erikmd Sep 8, 2020
08137be
fix: run the user-already-exists check after the secret passphrase check
erikmd Sep 10, 2020
87622c8
refactor: Always display the "Show token" button
erikmd Sep 12, 2020
d6c5cc7
feat: fully implement the "Show login" dialog
erikmd Sep 12, 2020
d785f20
refactor(learnocaml_api.ml): Simplify response_codec/Get_emails
erikmd Sep 12, 2020
a1ed4d7
feat: make it possible to reuse a legacy-token account from lti.html
erikmd Sep 12, 2020
4ee7eca
fix: one translation
erikmd Sep 12, 2020
69ac357
feat: Add text advertising Moodle login if it is enabled
erikmd Sep 13, 2020
48fb42b
feat: Resend confirmation email on passwd_reset if unconfirmed email
erikmd Sep 13, 2020
6f33943
feat(index-main): Make login-connect-button check email syntax first
erikmd Sep 13, 2020
d09037e
refactor(learnocaml_common.mli): Expose box_button & close_button
erikmd Sep 13, 2020
8f235f4
feat(learnocaml_validate_main.ml): Redirect when closing confim dialog
erikmd Sep 13, 2020
37a3e66
refactor(learnocaml_validate_main.ml): Define and Use cb_alert
erikmd Sep 13, 2020
2a02b6a
feat(index-main): Do Manip.focus, relying on cb_alert
erikmd Sep 13, 2020
a04c74d
feat(index-main): Reload the page when registered
erikmd Sep 13, 2020
83024c7
fix(index.html): Set autocomplete="off" for the checkbox
erikmd Sep 13, 2020
08929e7
feat: Allow the user to abort a pending e-mail change
erikmd Sep 13, 2020
41309e8
fix: learnocaml_index_main.ml
erikmd Sep 13, 2020
44bfe9e
fix: Learnocaml_local_storage.(can_show_token)
erikmd Sep 13, 2020
00bf2b6
fix(index-main): upgrade-button
erikmd Sep 13, 2020
e06b380
fix(TokenIndex): Ensure add_token doesn't introduce duplicates
erikmd Sep 13, 2020
70235d1
fix(Launch_direct): don't create duplicate user items
erikmd Sep 13, 2020
edbb510
refactor(token_index.ml): Replace failwith with printf-then-failwith
erikmd Sep 13, 2020
e362d85
fix: missing dependencies in learn-ocaml-client.opam
erikmd Sep 13, 2020
534103c
fix: Print "LTI shared secret" only at "serve" phase (not "build")
erikmd Sep 14, 2020
cf4241c
refactor: Rename one CLI option (s/--root/--root-url/)
erikmd Sep 15, 2020
ca0bd13
feat: Add LEARNOCAML_ROOT_URL env var
erikmd Sep 15, 2020
d75a57a
fix(learnocaml_server): function get_base_url was broken
erikmd Sep 15, 2020
53b3fd3
fix: strings escaping
erikmd Sep 15, 2020
9d6d357
fix: Api.Create_teacher_token should call Token_index.UserIndex.add
erikmd Sep 17, 2020
93c14dd
refactor(token_index.ml): Improve logging
erikmd Sep 17, 2020
ddf6e26
fix: init_teacher_token
erikmd Sep 17, 2020
aa9a51b
refactor: Don't say "legacy" if use_passwd = false
erikmd Sep 17, 2020
825c1fc
fix: Api.Can_login
erikmd Sep 17, 2020
55b63d0
refactor(index-main): Improve 1 error message & fr.po
erikmd Sep 17, 2020
59b49e0
fix: docker-compose networks
erikmd Sep 19, 2020
dfe64ae
fix(static): path of /icons/tryocaml_loading_*.gif
erikmd Sep 21, 2020
2df35d3
fix(token_index): mutex issue
erikmd Sep 22, 2020
f429321
Merge branch 'master' into oauth-moodle
Fixiss May 5, 2021
ab2f47d
fix: bug introduced by the merge
Fixiss May 5, 2021
65bbf46
fix: correct Docker and txt_token_secret
Fixiss May 5, 2021
9ec9f9f
fix: Remove unneeded apk packages from learn-ocaml-client image
erikmd May 5, 2021
8f8bf7f
docs: Document the long time required by the first run of moodle
erikmd May 7, 2021
28cd64b
fix: Moodle/LTI authentication was broken, not using the full URL
erikmd May 10, 2021
60bf264
feat: add password confirmation lti + index
Fixiss May 26, 2021
55908ab
feat: add password confirmation moodle->define password
Fixiss May 31, 2021
0da0be2
fix: secret label
Fixiss Jun 1, 2021
1ecf98c
feat: add confirmation password on moodle account and add module for …
Fixiss Jun 9, 2021
18da153
chore: Add deploy-oauth-moodle.yml to auto-build-and-push preprod images
erikmd Jun 8, 2021
ac11ad5
chore: Add push_emacs_client, a conditional deploy job
erikmd Jun 9, 2021
84ce517
Merge remote-tracking branch 'upstream/master' into oauth-moodle-dev
erikmd Jun 9, 2021
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
73 changes: 73 additions & 0 deletions .github/workflows/deploy-oauth-moodle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Note: remove this file (squash-removing the underlying commit) before merging
name: Push oauth-moodle to DockerHub
on:
push:
branches:
- oauth-moodle
- oauth-moodle-dev
jobs:
push_server:
name: Push learn-ocaml image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Get branch name
run: branch="${{ github.ref }}"; echo "::set-output name=branch::${branch#refs/heads/}"
id: branch
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
always_pull: true
add_git_labels: true
labels: "org.opencontainers.image.version=${{ steps.branch.outputs.branch }}"
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# repository: ocamlsf/learn-ocaml
repository: pfitaxel/learn-ocaml
tags: ${{ steps.branch.outputs.branch }}
push_client:
name: Push learn-ocaml-client image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Get branch name
run: branch="${{ github.ref }}"; echo "::set-output name=branch::${branch#refs/heads/}"
id: branch
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
always_pull: true
add_git_labels: true
labels: "org.opencontainers.image.version=${{ steps.branch.outputs.branch }}"
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# repository: ocamlsf/learn-ocaml-client
repository: pfitaxel/learn-ocaml-client
target: client
tags: ${{ steps.branch.outputs.branch }}
push_emacs_client:
name: Push emacs-learn-ocaml-client image to Docker Hub
needs: push_client
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Get branch name
run: branch="${{ github.ref }}"; echo "::set-output name=branch::${branch#refs/heads/}"
id: branch
- name: Push to Docker Hub
# https://github.com/docker/build-push-action/tree/releases/v1#readme
uses: docker/build-push-action@v1
with:
path: ci/docker-emacs-learn-ocaml-client
build_args: "base=pfitaxel/learn-ocaml-client,version=${{ steps.branch.outputs.branch }}"
always_pull: true
add_git_labels: true
labels: "org.opencontainers.image.version=${{ steps.branch.outputs.branch }}"
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# repository: ocamlsf/learn-ocaml
repository: pfitaxel/emacs-learn-ocaml-client
tags: ${{ steps.branch.outputs.branch }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ src/ppx-metaquot/ast_lifter.ml

learnocaml-server.byte
learn-ocaml.install
learn-ocaml-client.install

src/grader/embedded_cmis.ml
src/grader/embedded_grading_cmis.ml
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ LABEL org.opencontainers.image.vendor="The OCaml Software Foundation"
FROM alpine:3.13 as program

RUN apk update \
&& apk add ncurses-libs libev dumb-init git openssl \
&& apk add ncurses-libs libev gmp dumb-init msmtp git openssl \
&& addgroup learn-ocaml \
&& adduser learn-ocaml -DG learn-ocaml

Expand Down
2 changes: 2 additions & 0 deletions ci/docker-emacs-learn-ocaml-client/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.emacs
105 changes: 105 additions & 0 deletions ci/docker-emacs-learn-ocaml-client/.emacs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
;;; .emacs --- Emacs conf file -*- coding: utf-8 -*-

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Config de package.el, MELPA et use-package

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Config de Tuareg, Merlin et Company

(use-package tuareg
:ensure t
:defer t
:init
(setq tuareg-opam-insinuate t))

;; Merlin would require OPAM
; (use-package merlin
; :ensure t
; :hook
; ((tuareg-mode caml-mode) . merlin-mode)
; :config
; (setq merlin-command 'opam))
;
; (use-package merlin-eldoc
; :ensure t
; :hook
; ((tuareg-mode caml-mode) . merlin-eldoc-setup)
; :bind (:map merlin-mode-map
; ("C-c <C-left>" . merlin-eldoc-jump-to-prev-occurrence)
; ("C-c <C-right>" . merlin-eldoc-jump-to-next-occurrence)))
;
; (use-package company
; :ensure t
; :hook
; ((tuareg-mode caml-mode) . company-mode)
; :config
; (bind-key "<backtab>" 'company-complete))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Config de Magit

; (use-package magit
; :ensure t
; :defer t
; :config
; (setq magit-diff-refine-hunk 'all)
; :bind (("C-x g" . magit-status)
; ("C-x M-g" . magit-dispatch-popup)))
;
; (use-package magit-gitflow
; :ensure t
; :after magit
; :config (add-hook 'magit-mode-hook 'turn-on-magit-gitflow))
;
; ;; Protect against accident pushes to upstream
; (defadvice magit-push-current-to-upstream
; (around my-protect-accidental-magit-push-current-to-upstream)
; "Protect against accidental push to upstream.
;
; Causes `magit-git-push' to ask the user for confirmation first."
; (let ((my-magit-ask-before-push t))
; ad-do-it))
;
; (defadvice magit-git-push (around my-protect-accidental-magit-git-push)
; "Maybe ask the user for confirmation before pushing.
;
; Advice to `magit-push-current-to-upstream' triggers this query."
; (if (bound-and-true-p my-magit-ask-before-push)
; ;; Arglist is (BRANCH TARGET ARGS)
; (if (yes-or-no-p (format "Push %s branch upstream to %s? "
; (ad-get-arg 0) (ad-get-arg 1)))
; ad-do-it
; (error "Push to upstream aborted by user"))
; ad-do-it))
;
; (ad-activate 'magit-push-current-to-upstream)
; (ad-activate 'magit-git-push)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Config générale

(setq column-number-mode t
line-number-mode t
require-final-newline t)

;; Marquage des parenthèses
(load-library "paren")
(show-paren-mode 1)

;; Raccourcis C-c/C-x/C-v/C-z standards
;; au lieu de M-w/C-w/C-y/C-_ par défaut dans GNU Emacs
(cua-mode 1)
29 changes: 29 additions & 0 deletions ci/docker-emacs-learn-ocaml-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG base=ocamlsf/learn-ocaml-client
ARG version=master
FROM ${base}:${version}

WORKDIR /home/learn-ocaml

USER root

RUN apk add --no-cache \
curl \
emacs-nox \
&& mkdir -p -v bin \
&& chown -v learn-ocaml:learn-ocaml bin

ENV PATH /home/learn-ocaml/bin:${PATH}

ENV LANG C.UTF-8
# ENV LC_ALL C.UTF-8
# ENV LANGUAGE en_US:en

COPY --chown=learn-ocaml:learn-ocaml .emacs .emacs

USER learn-ocaml

# Do some automatic Emacs installation/byte-compilation:
RUN emacs --version && emacs --batch -l ${HOME}/.emacs

ENTRYPOINT []
CMD ["/bin/sh"]
103 changes: 103 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Note: this file is dev-specific.
# To deploy learn-ocaml, see e.g.:
# https://github.com/pfitaxel/docker-learn-ocaml/blob/master/docker-compose.yml

# Note: regarding the very first run (sudo docker-compose up --build),
# the setup of the moodle container ("Running Moodle install script")
# may take a long time (up to 18').
# Do NOT stop the docker-compose app too early, otherwise the database
# would be in a broken state, leading to a systematic error at further
# runs ("learn-ocaml_moodle_1 exited with code 1").

version: '3.7'

services:
learnocaml:
container_name: backend
# image: ocamlsf/learn-ocaml:0.13
build: .
ports:
- '8080:8080'
environment:
# (ocaml variable) root URL:
LEARNOCAML_BASE_URL: "http://localhost:8080"
# (ocaml variable) <container_name>.<network_name>:
FROM_DOMAIN: "backend.localdomain"
# (alpine msmtp variable) hostname of the SMTP server:
SMTPSERVER: "maildev"
# SMTPSERVER: "postfix"
# (ocaml + alpine msmtp variable) Reply-To = Return-Path:
EMAIL: "[email protected]"
depends_on:
- maildev
# - postfix
volumes:
- ./demo-repository:/repository:ro
- ./sync:/sync
networks:
- learnocaml-net
restart: unless-stopped

# Only useful for dev
maildev:
image: maildev/maildev
ports:
- "1080:80"
networks:
- learnocaml-net

# For a prod configuration, see also:
# https://github.com/pfitaxel/docker-learn-ocaml/blob/master/docker-compose.yml

# BEGIN https://github.com/bitnami/bitnami-docker-moodle/blob/ffa8007ebb0ebc501eeeba62804d10b0efef3673/docker-compose.yml

mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=bn_moodle
- MARIADB_DATABASE=bitnami_moodle
# - BITNAMI_DEBUG=true
volumes:
- 'mariadb_data:/bitnami/mariadb'
networks:
- moodle-net
moodle:
image: 'docker.io/bitnami/moodle:3-debian-10'
ports:
- '9090:8080'
# - '80:8080'
# - '443:8443'
environment:
- MOODLE_DATABASE_HOST=mariadb
- MOODLE_DATABASE_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
# - BITNAMI_DEBUG=true
volumes:
- 'moodle_data:/bitnami/moodle'
- 'moodledata_data:/bitnami/moodledata'
networks:
- moodle-net
depends_on:
- mariadb

volumes:
mariadb_data:
driver: local
moodle_data:
driver: local
moodledata_data:
driver: local

# END https://github.com/bitnami/bitnami-docker-moodle/blob/ffa8007ebb0ebc501eeeba62804d10b0efef3673/docker-compose.yml
# @ https://github.com/bitnami/bitnami-docker-moodle#readme
# @ https://github.com/bitnami/bitnami-docker-moodle#configuration

networks:
learnocaml-net:
driver: bridge
name: localdomain
moodle-net:
driver: bridge
26 changes: 26 additions & 0 deletions docs/howto-deploy-a-learn-ocaml-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,29 @@ make && make opaminstall
```
learn-ocaml serve --port 8080
```

## Enabling passwords

By default, authentication is performed with a token instead of a more
traditionnal email/password pair, but this can now be enabled by
setting the `use_passwd` option to `true` (by default, it is set to
`false`).

## Integration with Moodle and other teaching tools

If you enabled passwords, you can also enable LTI, enabling to login
in Learn-OCaml from Moodle and other teaching tools.

> *Warning*
>
> Passwords must be enabled to use the LTI integration.

The option `use_moodle` must be set to `true` in the config file (by
default, it is set to `false`). When running `learn-ocaml build`,
Learn-OCaml generate a private key for LTI authentication if there is
none yet, and print it to the standard output.

This key can be then inserted as the secret in the LTI-compatible
application (eg. Moodle). You can set any value you want as the
consumer key, but take care to not reuse the value between multiple
applications.
3 changes: 3 additions & 0 deletions learn-ocaml-client.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ depends: [
"asak"
"cohttp" {>= "1.0.0" & < "2.0.0"}
"cohttp-lwt-unix" {>= "1.0.0" & < "2.0.0"}
"cryptokit"
"ssl" {= "0.5.5"}
"digestif" {>= "0.7.1"}
"dune" {= "2.0.1"}
"ezjsonm"
"lwt" {>= "4.0.0"}
"lwt_ssl"
"ocaml" {= "4.05.0"}
"ocamlnet" {> "4.1"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm isn't ocamlnet a legacy library ? I am not sure it's much maintained anymore.
As far as I can see, it is only used for sending emails, did you consider alternatives ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! It had been added just because the mirage counterpart of this library needed ocaml > 4.08, and we only had 4.05 support at this time. Thanks for reminding this need for an upgrade.

"ocamlfind" {build}
"ocp-indent-nlfork"
"ocp-ocamlres" {>= "0.4"}
Expand All @@ -37,6 +39,7 @@ depends: [
"ppx_tools"
"ppx_sexp_conv" {= "v0.9.0"}
"ppx_fields_conv" {= "v0.9.0"}
"safepass"
]
build: [
["dune" "build" "@install" "-p" name "-j" jobs]
Expand Down
Loading