Skip to content

Commit

Permalink
fixup! 📝(project) add a ralph lrs tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
wilbrdt committed Dec 19, 2023
1 parent e48d6fc commit 8b4fea7
Show file tree
Hide file tree
Showing 14 changed files with 203 additions and 134 deletions.
4 changes: 2 additions & 2 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ RALPH_BACKENDS__DATA__ES__TEST_FORWARDING_INDEX=test-index-foo-2
# ES lrs backend

# Same options as for the ES data backend, however they are prefixed with
# RALPH_BACKENDS__LRS__ES__ instead. Example:
# RALPH_BACKENDS__LRS__ES__HOSTS=http://elasticsearch:9200
# RALPH_BACKENDS__LRS__ES__ instead.
RALPH_BACKENDS__LRS__ES__HOSTS=http://elasticsearch:9200

# MONGO data backend

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ If the database status is satisfying, you are now ready to send xAPI statements
to the LRS:

```bash
gunzip data/statements.json.gz | \
gunzip -c data/statements.json.gz | \
head -n 100 | \
jq -s . | \
curl -Lk \
--user ralph:secret \
-X POST \
-H "Content-Type: application/json" \
http://localhost:8100/xAPI/statements/ -d @-
-d @- \
http://localhost:8100/xAPI/statements/
```

The command above fetches one hundred (100) example xAPI statements from our
Expand Down
43 changes: 0 additions & 43 deletions docker-compose-test.yml

This file was deleted.

8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ services:
- "${RALPH_RUNSERVER_BACKEND:-es}"
volumes:
- .:/app
networks:
- ralph


# -- backends
elasticsearch:
Expand Down Expand Up @@ -82,3 +85,8 @@ services:
test: curl -s http://127.0.0.1:35357 || exit 1
interval: 1s
retries: 60

networks:
ralph:
external: true

4 changes: 2 additions & 2 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ By default, all authenticated users have full read and write access to the serve

### Filtering results by authority (multitenancy)

In Ralph LRS, all incoming statements are assigned an `authority` (or ownership) derived from the user that makes the call. You may restrict read access to users "own" statements (thus enabling multitenancy) by setting the following environment variable:
In Ralph LRS, all incoming statements are assigned an `authority` (or ownership) derived from the user that makes the request. You may restrict read access to users "own" statements (thus enabling multitenancy) by setting the following environment variable:

```bash
RALPH_LRS_RESTRICT_BY_AUTHORITY = True # Default: False
```

**WARNING**: Two accounts with different credentials may share the same `authority` meaning they can access the same statements. It is the administrators responsability to ensure that `authority` is properly assigned.
**WARNING**: Two accounts with different credentials may share the same `authority`, meaning they can access the same statements. It is the administrator's responsibility to ensure that `authority` is properly assigned.

NB: If not using "scopes", or for users with limited "scopes", using this option will make the use of option `?mine=True` implicit when fetching statement.

Expand Down
10 changes: 5 additions & 5 deletions docs/tutorials/development_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You should know that we would be glad to help you contribute to Ralph! Here's ou


!!! info
In this tutorial, and even more generally in others tutorials, we tend to use Elasticsearch backend. Note that you can do the same with [another LRS backend](../backends) implemented in Ralph.
In this tutorial, and even more generally in others tutorials, we tend to use Elasticsearch backend. Note that you can do the same with [another LRS backend](../backends/index.md) implemented in Ralph.

To start playing with `ralph`, you should first `bootstrap` using:

Expand Down Expand Up @@ -279,22 +279,22 @@ curl -sLk \
-o jsonpath='{.spec.rules[0].host}')/whoami"
```

And why not send test statements:
Let's also send some test statements:

```bash
gunzip data/statements.json.gz | \
gunzip -c data/statements.json.gz | \
head -n 100 | \
jq -s . | \
curl -sLk \
--user foo:bar \
-X POST \
-H "Content-Type: application/json" \
-d @- \
"https://$(\
kubectl -n development-ralph \
get \
ingress/ralph-app-current \
-o jsonpath='{.spec.rules[0].host}')/xAPI/statements/" \
-d @-
-o jsonpath='{.spec.rules[0].host}')/xAPI/statements/"
```

!!! tip "Install `jq`"
Expand Down
30 changes: 15 additions & 15 deletions docs/tutorials/lrs/authentication/basic.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# HTTP Basic Authentication

The default method for securing Ralph API server is with HTTP basic authentication. For this, we need to create a user in Ralph LRS.
The default method for securing the Ralph API server is HTTP Basic Authentication.
For this, we need to create a user in Ralph LRS.

## Creating user credentials

Expand All @@ -10,31 +11,30 @@ To create a new user credentials, Ralph CLI provides a dedicated command:

```bash
ralph auth \
--write-to-disk \
--username janedoe \
--password supersecret \
--scope janedoe_scope \
--agent-ifi-mbox mailto:[email protected] \
# or --agent-ifi-mbox-sha1sum ebd31e95054c018b10727ccffd2ef2ec3a016ee9 \
# or --agent-ifi-openid "http://jane.openid.example.org/" \
# or --agent-ifi-account exampleAccountname http://www.exampleHomePage.com \
-w
--scope statements/write \
--scope statements/read \
--agent-ifi-mbox mailto:[email protected]
```

=== "Docker Compose"

```bash
docker compose run --rm lrs \
bin/ralph auth \
ralph auth \
--write-to-disk \
--username janedoe \
--password supersecret \
--scope janedoe_scope \
--agent-ifi-mbox mailto:[email protected] \
# or --agent-ifi-mbox-sha1sum ebd31e95054c018b10727ccffd2ef2ec3a016ee9 \
# or --agent-ifi-openid "http://jane.openid.example.org/" \
# or --agent-ifi-account exampleAccountname http://www.exampleHomePage.com \
-w
--scope statements/write \
--scope statements/read \
--agent-ifi-mbox mailto:[email protected]
```

!!! tip
You can either display the helper with `ralph auth --help` or check the CLI tutorial [here](../../cli.md)

This command updates your credentials file with the new `janedoe` user.
Here is the file that has been created by the `ralph auth` command:

Expand Down Expand Up @@ -104,7 +104,7 @@ and running the Ralph LRS with:
docker compose up -d lrs
```

we can try to make a request to the `whoami` endpoint again, but this time sending our username and password through Basic Auth:
we can request the `whoami` endpoint again, but this time sending our username and password through Basic Auth:

=== "curl"

Expand Down
Loading

0 comments on commit 8b4fea7

Please sign in to comment.