If you have not already completed the dashboard setup portion of the documentation, please head over there first.
In order to use and develop the authenticated features of the application (course creation, the assignment design wizard, user management, etc) you will need to create a MediaWiki OAuth consumer. You can skip this setup process and use the consumer provided in config/application.example.yml
to get started; this consumer cannot be used to make edits or update preferences on Wikipedia, but can be used to log in.
If you haven't already set an email address for your Wikimedia project account, log in to a Wikimedia site with your username and password. Once you're logged in, click on "Preferences" in the upper right-hand corner. In the "User profile" tab under "Preferences" (selected by default), set your email address. You'll need this to confirm your account and get your token and secret key in the next step.
To register an OAuth consumer, your account must be "confirmed". This happens automatically after a certain number of edits, but if your account is new and you're impatient, you can request your account to be manually confirmed here.
You'll now propose an OAuth consumer. Fill out the form with the following values:
- Application name:
<YOUR_NAME>_at_<YOUR_COMPANY>
- Application description:
<YOUR_NAME>'s local machine
- OAuth "callback" URL:
http://localhost:3000/users/auth/mediawiki/callback
- Contact email address:
<YOUR_EMAIL>
(this must match your Wikimedia account email) - Permissions: select
Edit existing pages
andCreate, edit, and move pages
- Public RSA Key: Leave this blank, so that you receive a secret key in the next step.
Clicking on the 'Propose consumer' button should return a token and secret, which you should store in your application.yml
file.
A development consumer, used only by the proposer, will work immediately. For production or shared testing environments, consumers must be approved before anyone but the proposer can authorize the application. You can post a request for approval here (see example).
When you request a new consumer, add the tokens to the production server's application.yml
, commented out, so they are ready for the switchover.
- Ideally, schedule the consumer update for a time when few users will be active.
- Add a site notice informing users that they will be logged out, 30 mintues or more before the consumer is updated.
- Initiate a snapshot of the Linode server and wait for it to finish (just in case).
- Update
application.yml
, commenting out the old tokens and uncommenting the new, and removing the sitenotice. - In a rails console on production, remove all oauth tokens from users:
User.update_all(wiki_token: nil, wiki_secret: nil)
. - Restart both the main server process (
touch tmp/restart.txt
) and the sidekiq processes (cap production deploy:sidekiq:restart
). - Once an edit has been made with the new consumer, find the CID of that consumer via
Special:Tags
on Wikipedia, and add it to the list of CIDs inapplication.yml
. - Restart the server and sidekiq processes again.
Give users admin privileges in the app, e.g. to approve submitted courses, by setting the users.permissions field to "1". For example, if your wiki username is "RageSock",
rails runner "User.find_by(wiki_id: 'RageSock').update(permissions: User::Permissions::ADMIN)"
or via mysql,
mysql -e "update users set permissions = 1 where wiki_id='RageSock'" dashboard