OAuth2Client

From PKC
Revision as of 00:29, 8 May 2021 by Admin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

OAuth stands for Open Authentication, and OAuth2, is an abbreviation for Open Auth 2.0.

This article tries to explain how to install OAuth2Client for MediaWiki.

Github as the OAuth Server

For the purpose of getting started, Github.com will be used as the OAuth Service provider. The first step is to create an OAuth Application on Github. One should already have an account on Github. The process of how to create an OAuth application for your Github account can be found here[1]:

Please go through the following process:

  1. Login to your Github.com account.
  2. Go to your settings, and navigate to create new OAuth Applications. The link[1] is shown.
  3. You will be prompted with an interface that gives your a new Client ID and ask you to name your application, upload a logo for the application, and you will use the interface to generate a Client Secret.
  4. Capture the Client ID and Secret.
  5. Make sure that you have MW-OAuth2Client package already installed in your MediaWiki's /extensions directory.
  6. Append the following the text to your LocalSettings.php
wfLoadExtension( 'MW-OAuth2Client' );
$wgOAuth2Client['client']['id'] = "alpha_numerical_strings_representing_client_id";
$wgOAuth2Client['client']['secret'] = "alpha_numerical_strings_representing_secret";
$wgOAuth2Client['configuration']['authorize_endpoint'] = 'https://github.com/login/oauth/authorize'; // Authorization URL
$wgOAuth2Client['configuration']['access_token_endpoint'] = 'https://github.com/login/oauth/access_token'; // Token URL
$wgOAuth2Client['configuration']['api_endpoint'] = 'https://api.github.com/user'; // URL to fetch user JSON
$wgOAuth2Client['configuration']['redirect_uri'] = "http://localhost:9352/index.php/Special:OAuth2Client/callback";
$wgOAuth2Client['configuration']['username'] = 'login'; // JSON path to username
$wgOAuth2Client['configuration']['email'] = 'email'; // JSON path to email
$wgOAuth2Client['configuration']['scopes'] = 'openid email profile'; //Permissions
$wgOAuth2Client['configuration']['service_name'] = 'Oauth Registry'; // the name of your service
$wgOAuth2Client['configuration']['service_login_link_text'] = 'OAuth-Github'; // the text of the login link

Caveat

For participants who wants to use OAuth features on Github, just go to http://github.com/xlp0/PKC, and download the code base. It should[footnotes 1] work with your local application, as long as the redirect_uri is set to

http://localhost:9352/index.php/Special:OAuth2Client/callback

as shown above.

Notes

  1. It should work because the client ID and client secret should match all the required settings.

References