|
| 1 | +## Wikimedia |
| 2 | + |
| 3 | +MediaWiki instances running |
| 4 | +[Extension:OAuth](https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:OAuth), |
| 5 | +including all Wikimedia wikis (like Wikipedia), can be used as an |
| 6 | +OAuth authentication source. |
| 7 | + |
| 8 | +### Register an application with Wikimedia |
| 9 | + |
| 10 | +* Review the [OAuth app |
| 11 | + guidelines](https://meta.wikimedia.org/wiki/OAuth_app_guidelines) on |
| 12 | + meta.wikimedia.org. |
| 13 | +* As described on that page, propose a new client registration at |
| 14 | + [Special:OAuthConsumerRegistration/propose](https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose). |
| 15 | + Use the "Propose an OAuth 2.0 client" link. |
| 16 | +* Provide your wiki details: |
| 17 | +** An application name; presumably the name of your wiki. If you |
| 18 | + include "test" in the name or "localhost" in the callback URL |
| 19 | + the authorization will work only on your own account and only |
| 20 | + for 30 days. |
| 21 | +** Set the Consumer version to `1.0` |
| 22 | +** Describe your application; you might want to mention that the |
| 23 | + software is open-source and available at |
| 24 | + https://github.com/fedwiki/wiki-security-passportjs/ |
| 25 | +** You can click "This consumer is for use only by..." if this will |
| 26 | + be a single-user wiki. |
| 27 | +** You will need to specify a callback URL. For local testing this |
| 28 | + will be http://localhost:3000/auth/oauth2/callback but for a wiki |
| 29 | + visible to the external internet you will need to update the host |
| 30 | + portion. This is a callback provided by `wiki-security-passport`. |
| 31 | +** You will need an "Authorization code" grant type, and probably a |
| 32 | + "Refresh token" grant as well; you don't need "Client credentials". |
| 33 | +** You will probably check "User identity verification only", either |
| 34 | + with "access to real name..." if you want to use the |
| 35 | + `oauth2_DisplayNameField` feature or without that otherwise. |
| 36 | + "Request authorization for specific permissions" is only needed if |
| 37 | + you are working on a deeper integration with MediaWiki. |
| 38 | + |
| 39 | +When you click on "Propose registration" you will get a client |
| 40 | +application key and client application secret which you will use |
| 41 | +to create a `config.json`. Note that you can access the details |
| 42 | +of your registration later at |
| 43 | +[Special:OAuthConsumerRegistration/list](https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/list). |
| 44 | + |
| 45 | +### Configure Wiki |
| 46 | + |
| 47 | +The Wiki is configured by adding the `Consumer Key` and `Consumer Secret` to the configuration. As long as we have not selected `Enable Callback Locking` these can be added outside the `wikiDomains` definition, so they apply to the entire farm. The `wikiDomains` definition is required so that the security plugin knows what is required. |
| 48 | + |
| 49 | +This example will work for a test server running on `localhost:3000`: |
| 50 | +```JSON |
| 51 | +{ |
| 52 | + "admin": {"oauth2": "ID VALUE FROM OWNER.JSON FILE OF ADMIN"}, |
| 53 | + "security_type": "passportjs", |
| 54 | + "oauth2_clientID": "CLIENT APPLICATION ID", |
| 55 | + "oauth2_clientSecret": "CLIENT APPLICATION SECRET", |
| 56 | + "oauth2_CallbackURL": "http://localhost:3000/auth/oauth2/callback", |
| 57 | + "oauth2_AuthorizationURL": "https://www.mediawiki.org/w/rest.php/oauth2/authorize", |
| 58 | + "oauth2_TokenURL": "https://www.mediawiki.org/w/rest.php/oauth2/access_token", |
| 59 | + "oauth2_UserInfoURL": "https://www.mediawiki.org/w/rest.php/oauth2/resource/profile", |
| 60 | + "oauth2_UseHeader": true, |
| 61 | + "oauth2_IdField": "profile.sub", |
| 62 | + "oauth2_DisplayNameField": "profile.realname", |
| 63 | + "oauth2_UsernameField": "profile.username", |
| 64 | + "wikiDomains": { |
| 65 | + "localhost": {} |
| 66 | + } |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +Note that Wikimedia wikis (the global user accounts on mediawiki.org) |
| 71 | +don't export "realname". If you are running against a local mediawiki |
| 72 | +instance you will need to update the `https://www.media.org/w/` prefix |
| 73 | +to match your local install. |
0 commit comments