From 2a13d4a48c86df453258e5012c9a726153e88236 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sun, 3 Jun 2012 12:20:40 +0200 Subject: [PATCH] Add community auth v2 provider for mediawiki --- .../sample/php/mediawiki/README.rst | 38 ++++ .../sample/php/mediawiki/auth.php | 201 ++++++++++++++++++ .../sample/php/mediawiki/login.php | 7 + .../sample/php/mediawiki/logout.php | 15 ++ .../sample/php/mediawiki/pgauth_conf.php | 7 + 5 files changed, 268 insertions(+) create mode 100644 tools/communityauth/sample/php/mediawiki/README.rst create mode 100644 tools/communityauth/sample/php/mediawiki/auth.php create mode 100644 tools/communityauth/sample/php/mediawiki/login.php create mode 100644 tools/communityauth/sample/php/mediawiki/logout.php create mode 100644 tools/communityauth/sample/php/mediawiki/pgauth_conf.php diff --git a/tools/communityauth/sample/php/mediawiki/README.rst b/tools/communityauth/sample/php/mediawiki/README.rst new file mode 100644 index 00000000..1a35e996 --- /dev/null +++ b/tools/communityauth/sample/php/mediawiki/README.rst @@ -0,0 +1,38 @@ +Mediawiki login provider +------------------------ + +This provider implements a (fairly ugly) community auth v2 provider +for mediawiki. Since the mediawiki API doesn't support external +authentication (it reqiures there to be a username and password, +which isn't always true, and can only pass those on to external +services), this has to be done by browser interception. Basically, +we intercept the mediawiki login URL and redirect it. Upon receiving +the data back from the authentication system, we inject it into the +mediawiki session and redirect back. It appears to work so far... + +Installation +++++++++++++ +Copy all the PHP files to `/var/lib/mediawiki/pgauth/`, and +edit as necessary to have the correct URLs and keys. + +Server configuration +++++++++++++++++++++ +The webserver needs to be configured to intercept and redirect +the mediawiki URLs. The following configuration is required on +lighttpd:: + + url.rewrite-once = ( + "^/wiki/([^?]*)(?:\?(.*))?" => "/index.php?title=$1&$2", + "^/index.php\?title=Special:UserLogin&returnto=(.*)" => "/pgauth/login.php?r=$1", + "^/index.php\?title=Special:UserLogout&returnto=(.*)" => "/pgauth/logout.php", + ) + +It should be added after the regular mediawiki rewrites (included here +for reference on the first row). + +Configuration ++++++++++++++ +Edit the settings in `pgauth_conf.php` to set steid, key and URLs. The +database connectoin string configured here is for the authentication +provider to connect to the mediawiki database, not to the community auth +database. diff --git a/tools/communityauth/sample/php/mediawiki/auth.php b/tools/communityauth/sample/php/mediawiki/auth.php new file mode 100644 index 00000000..5a17b3a9 --- /dev/null +++ b/tools/communityauth/sample/php/mediawiki/auth.php @@ -0,0 +1,201 @@ + diff --git a/tools/communityauth/sample/php/mediawiki/login.php b/tools/communityauth/sample/php/mediawiki/login.php new file mode 100644 index 00000000..99da885d --- /dev/null +++ b/tools/communityauth/sample/php/mediawiki/login.php @@ -0,0 +1,7 @@ + diff --git a/tools/communityauth/sample/php/mediawiki/logout.php b/tools/communityauth/sample/php/mediawiki/logout.php new file mode 100644 index 00000000..53b66f18 --- /dev/null +++ b/tools/communityauth/sample/php/mediawiki/logout.php @@ -0,0 +1,15 @@ + diff --git a/tools/communityauth/sample/php/mediawiki/pgauth_conf.php b/tools/communityauth/sample/php/mediawiki/pgauth_conf.php new file mode 100644 index 00000000..8618e9ce --- /dev/null +++ b/tools/communityauth/sample/php/mediawiki/pgauth_conf.php @@ -0,0 +1,7 @@ + \ No newline at end of file