# A real LTI 1.3 platform, on this machine (M10.6)

Our own tests can only prove that Metis agrees with itself. This brings up
Moodle — an independent LMS that implements the platform side of LTI 1.3 — and
drives a genuine launch into the service, so what the tool accepts is judged by
software nobody here wrote.

Nothing in here is committed except the scripts: Moodle is 75 MB of PHP and its
data is a database.

## Bring it up

```sh
# 1. Moodle itself (pinned by the sha256 recorded in the receipt)
curl -o moodle-405.tgz https://packaging.moodle.org/stable405/moodle-latest-405.tgz
tar xzf moodle-405.tgz && mkdir -p moodledata && chmod -R 777 moodledata

# 2. a database beside the dev one
psql -h 127.0.0.1 -U oshun -d oshun_dev -c 'CREATE DATABASE moodle_lti'

# 3. install it without a browser
docker run --rm --network host -v "$PWD/moodle:/var/www/html" \
  -v "$PWD/moodledata:/var/www/moodledata" moodlehq/moodle-php-apache:8.2-bookworm \
  php /var/www/html/admin/cli/install.php --non-interactive --agree-license --lang=en \
  --wwwroot=http://127.0.0.1 --dataroot=/var/www/moodledata --dbtype=pgsql \
  --dbhost=127.0.0.1 --dbname=moodle_lti --dbuser=oshun --dbpass=oshun_dev \
  --fullname="LTI Conformance" --shortname=lti --adminuser=admin \
  --adminpass='Metis-LTI-2026!' --adminemail=admin@example.edu

# 4. serve it
docker run -d --name moodle-lti --network host -v "$PWD/moodle:/var/www/html" \
  -v "$PWD/moodledata:/var/www/moodledata" moodlehq/moodle-php-apache:8.2-bookworm
```

Then `register_tool.php`, `make_course.php` and `update_tool.php` (copy each
into the Moodle tree and `docker exec moodle-lti php /var/www/html/<script>`)
register Metis as an LTI 1.3 tool, build a course with an LTI activity, and
point the registration at the platform-facing endpoints. Each uses Moodle's own
API, so Moodle is the one doing the registering.

## Run a launch

Start the service with a signing key and register Moodle with it
(`POST /api/lti/platforms`), then:

```sh
python3 drive_launch.py
```

It signs a learner into Moodle, has Moodle build the launch, and follows the
handshake the way a browser would: the platform's form POST to
`/api/lti/login/initiate`, our 303 to Moodle's authorization endpoint, Moodle's
signed `id_token` posted to `/api/lti/launch/callback`, and what the tool made
of it. Receipts land in
`evidence/v1-workbenches/metis-conformance/moodle-lti-1p3/`.

## Two things this arrangement makes true

**The platform is on loopback, so its JWKS is plain http.** `HttpsJwksFetcher`
refuses http everywhere else and allows it only for a loopback literal — the
exception OAuth makes for native apps (RFC 8252 §7.3). There is no path between
here and `127.0.0.1` for anyone to sit on; anywhere else there is.

**A platform never sends a `platform_id`.** It sends `iss` and `client_id`,
which are what it knows about itself. That is why the login endpoint resolves a
registration by issuer and client, and why `platform_id` is ours and optional.
Both were found by running this, not by reading the specification.
