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

Merging main into mw-1.39 #569

Merged
merged 9 commits into from
Jan 25, 2024
47 changes: 19 additions & 28 deletions build/QuickStatements/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Quickstatements docker image
# QuickStatements docker image

Quickstatements as seen at [https://github.com/magnusmanske/quickstatements](https://github.com/magnusmanske/quickstatements)
QuickStatements as seen at [https://github.com/magnusmanske/quickstatements](https://github.com/magnusmanske/quickstatements)

### Environment variables

Variable | Default | Description
-------------------------------------|--------------------------|------------
`WIKIBASE_SCHEME_AND_HOST` | NONE | Host and port of Wikibase instance as seen by Quick Statements
`WB_PUBLIC_SCHEME_HOST_AND_PORT` | NONE | Host and port of Wikibase as seen by the user's browser
`QS_PUBLIC_SCHEME_HOST_AND_PORT` | NONE | Host and port of Quick Statements as seen by the user's browser
`QS_PUBLIC_SCHEME_HOST_AND_PORT` | NONE | Host and port of QuickStatements as seen by the user's browser
`OAUTH_CONSUMER_KEY` | NONE | OAuth consumer key (obtained from Wikibase)
`OAUTH_CONSUMER_SECRET` | NONE | OAuth consumer secret (obtained from wikibase)
`PHP_TIMEZONE` | UTC | setting of php.ini date.timezone
@@ -23,44 +22,36 @@ Variable | Default | Description

Directory | Description
--------------------------------------------|-------------------------------------------------------------------------------
`/var/www/html/quickstatements` | Base quickstatements directory
`/var/www/html/quickstatements/public_html` | The Apache Root folder
`/var/www/html/quickstatements` | Base QuickStatements directory
`/var/www/html/quickstatements/public_html` | The Apache root folder
`/var/www/html/magnustools` | Base magnustools directory

File | Description
------------------------- | ------------------------------------------------------------------------------
`/templates/config.json` | Template for Quickstatements' config.json (substituted to `/var/www/html/quickstatements/public_html/config.json` at runtime)
`/templates/oauth.ini` | Template for Quickstatements' oauth.ini (substituted to `/var/www/html/quickstatements/oauth.ini` at runtime)
`/templates/config.json` | Template for QuickStatements' config.json (substituted to `/var/www/html/quickstatements/public_html/config.json` at runtime)
`/templates/oauth.ini` | Template for QuickStatements' oauth.ini (substituted to `/var/www/html/quickstatements/oauth.ini` at runtime)
`/templates/php.ini` | php config (default provided sets date.timezone to prevent php complaining substituted to `/usr/local/etc/php/conf.d/php.ini` at runtime)


### Set up quickstatements
In order for quickstatements to communicate with wikibase it needs to know where your instance is and how it can find it.
This must be done by setting the ENV variable `WIKIBASE_SCHEME_AND_HOST`. n.b. This should reflect how this container when running
sees the wikibase container. For example the example docker container alias like `wikibase.svc`.
### Set up QuickStatements
In order to authorize QuickStatements against Wikibase via OAuth, this container must be available on an address on the host machine that is also visible within the Docker network. Set `QS_PUBLIC_SCHEME_HOST_AND_PORT` to this address.

The user's browser will also be redirected to the Wikibase instance and finally back to quickstatements. The address
the user sees for the Wikibase may be different from how the running container sees it. For example: it may be running
on localhost on a specific port. e.g. http://localhost:8181. This should be passed to the quickstatements container as
`WB_PUBLIC_SCHEME_HOST_AND_PORT`.
Likewise, Wikibase needs to be able to access QuickStatements for the OAuth callback on a host-recognizable address, set using `WB_PUBLIC_SCHEME_HOST_AND_PORT`.

One must also know how this container will be visible to the user as well so it can ask the wikibase to redirect the
user back here. This should be passed as `QS_PUBLIC_SCHEME_HOST_AND_PORT`.
Note that Docker Engine doesn't provide such addresses, so you will likely need to set up a reverse proxy (such as nginx or haproxy) alongside either public DNS entries or a local DNS server using entries that route to these container. See the Wikibase Suite example configuration for more guidance on how to set that up.

You can pass the consumer and secret token you got from the wikibase to this container as the environment variables
`OAUTH_CONSUMER_KEY` and `OAUTH_CONSUMER_SECRET`. If you don't, there are [extra-install scripts](../WikibaseBundle/extra-install/QuickStatements.sh) supplied in the Wikibase bundle that can automatically handle this.
You can pass the consumer and secret token you got from your Wikibase instance to this container using the environment variables
`OAUTH_CONSUMER_KEY` and `OAUTH_CONSUMER_SECRET`. Alternatively you can let the [extra-install scripts](../WikibaseBundle/extra-install/QuickStatements.sh) supplied in the Wikibase bundle handle this for you.

You can now test that it works by navigating to `QS_PUBLIC_SCHEME_HOST_AND_PORT` and logging in.
Test whether it works by navigating to `QS_PUBLIC_SCHEME_HOST_AND_PORT` and logging in.

You should be redirected to the wiki where you can authorize this Quickstatements to act on your behalf.
You should be redirected to the wiki, where you can authorize this QuickStatements to act on your behalf.

Finally you should be redirected back to Quickstatements and you should appear logged in.
Finally you should be redirected back to QuickStatements, and you should see yourself logged in.

Use Quickstatements as normal with the Run button. Currently "Run in background" is not supported by this image.
Use QuickStatements as you normally would, using the Run button. The "Run in background" option is not supported by this image.

#### Troubleshooting
If you see an error such as mw-oauth exception when trying to log in check that you have passed the right consumer token
and secret token to quickstatements.
If you see an error such as `mw-oauth exception` when trying to log in, check that you have passed the correct consumer token and secret token to QuickStatements.

If you have changed the value of $wgSecretKey $wgOAuthSecretKey since you made the consumer you'll need to make another new consumer or
reissue the secret token for the old one.
If you have changed the value of $wgSecretKey $wgOAuthSecretKey since you made the consumer, you'll need to make another new consumer or reissue the secret token for the old one.
2 changes: 1 addition & 1 deletion build/QuickStatements/config.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"project":"${MW_SITE_NAME}" ,
"ini_file":"/quickstatements/data/oauth.ini" ,
"publicMwOAuthUrl":"${WB_PUBLIC_SCHEME_HOST_AND_PORT}/w/index.php?title=Special:OAuth" ,
"mwOAuthUrl":"${WIKIBASE_SCHEME_AND_HOST}/w/index.php?title=Special:OAuth" ,
"mwOAuthUrl":"${WB_PUBLIC_SCHEME_HOST_AND_PORT}/w/index.php?title=Special:OAuth" ,
"mwOAuthIW":"mw"
} ,
"server" : "${WB_PUBLIC_SCHEME_HOST_AND_PORT}" ,
2 changes: 1 addition & 1 deletion build/QuickStatements/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# Test if required environment variables have been set
REQUIRED_VARIABLES=(QS_PUBLIC_SCHEME_HOST_AND_PORT WB_PUBLIC_SCHEME_HOST_AND_PORT WIKIBASE_SCHEME_AND_HOST WB_PROPERTY_NAMESPACE WB_PROPERTY_PREFIX WB_ITEM_NAMESPACE WB_ITEM_PREFIX)
REQUIRED_VARIABLES=(QS_PUBLIC_SCHEME_HOST_AND_PORT WB_PUBLIC_SCHEME_HOST_AND_PORT WB_PROPERTY_NAMESPACE WB_PROPERTY_PREFIX WB_ITEM_NAMESPACE WB_ITEM_PREFIX)
for i in "${REQUIRED_VARIABLES[@]}"; do
if ! [[ -v "$i" ]]; then
echo "$i is required but isn't set. You should pass it to docker. See: https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file";
3 changes: 2 additions & 1 deletion example/docker-compose.extra.yml
Original file line number Diff line number Diff line change
@@ -122,14 +122,15 @@ services:
environment:
- QUICKSTATEMENTS_HOST
- QS_PUBLIC_SCHEME_HOST_AND_PORT
- WIKIBASE_SCHEME_AND_HOST=http://wikibase-docker.svc
- WB_PUBLIC_SCHEME_HOST_AND_PORT=http://${WIKIBASE_HOST}:${WIKIBASE_PORT}
- WB_PROPERTY_NAMESPACE=122
- "WB_PROPERTY_PREFIX=Property:"
- WB_ITEM_NAMESPACE=120
- "WB_ITEM_PREFIX=Item:"
- OAUTH_CONSUMER_KEY
- OAUTH_CONSUMER_SECRET
# This can be removed on release of WMDE15 to example
- WIKIBASE_SCHEME_AND_HOST=http://${WIKIBASE_HOST}

volumes:
LocalSettings:
1 change: 0 additions & 1 deletion test/suites/quickstatements/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -64,7 +64,6 @@ services:
environment:
- QS_PUBLIC_SCHEME_HOST_AND_PORT=http://quickstatements.svc:80
- WB_PUBLIC_SCHEME_HOST_AND_PORT=http://wikibase.svc:80
- WIKIBASE_SCHEME_AND_HOST=http://wikibase.svc
- WB_PROPERTY_NAMESPACE=122
- "WB_PROPERTY_PREFIX=Property:"
- WB_ITEM_NAMESPACE=120