Giter Club home page Giter Club logo

mediawiki-shibboleth-authentication's Introduction

login.php lazy session login file:

cd /var/www/html/mediawiki-1.23.13
wget https://raw.githubusercontent.com/malavolti/mediawiki-shibboleth-authentication/master/login.php -O login.php

LocalSettings.php configuration example to add

require_once('extensions/ShibAuthPlugin.php');

## Allow for empty paswords
$wgMinimalPasswordLength = 0;

## Last portion of the shibboleth WAYF url for lazy sessions.
## This value is found in your shibboleth.xml file on the setup for your SP
## WAYF url will look something like: /Shibboleth.sso/WAYF/$shib_WAYF
## $shib_WAYF = "Login";

## Are you using an old style WAYF (Shib 1.3) or new style Discover Service (Shib 2.x)?
## Values are WAYF or DS, defaults to WAYF
##$shib_WAYFStyle = "DS";
$shib_WAYFStyle = "CustomLogin";

## Default for compatibility with previous version: false
$shib_Https = true;

## Prompt for user to login
$shib_LoginHint = "Login with SSO";

## Prompt for user to log out
$shib_LogoutHint = "Logout";

## Where is the assertion consumer service located on the website?
## Default: "/Shibboleth.sso"
##$shib_AssertionConsumerServiceURL = "";
$shib_AssertionConsumerServiceURL = $wgScriptPath . "/login.php";

## Map Real Name to what Shibboleth variable(s)?
##$shib_RN = isset($_SERVER['HTTP_COMMON_NAME']) ? $_SERVER['HTTP_COMMON_NAME'] : null;
if (array_key_exists("cn", $_SERVER)) {
   $shib_RN = $_SERVER['cn'];
} else if (array_key_exists("givenName", $_SERVER) && array_key_exists("sn", $_SERVER)) {
   $shib_RN = ucfirst(strtolower($_SERVER['givenName'])) . ' '
            . ucfirst(strtolower($_SERVER['sn']));
}

## Map e-mail to what Shibboleth variable?
##$shib_email = isset($_SERVER['HTTP_EMAIL']) ? $_SERVER['HTTP_EMAIL'] : null;
$shib_email = isset($_SERVER['mail']) ?  $_SERVER['mail'] : null;

## Field containing groups for the user and field containing the prefix to be searched (and stripped) from wiki groups
$shib_groups = isset($_SERVER['isMemberOf']) ? $_SERVER['isMemberOf'] : null;

//This value must match with the FolderID of Wiki on the Grouper instance
$shib_group_prefix = "wiki.fqdn.example.it";

## Should pre-existing groups be deleted?
## If groups are fetched only from Shibboleth it should be true
## if memberships are granted from mediawiki User rights management
## page, it should be false
## PLEASE NOTE: with $shib_group_delete = false, in order to revoke
## a membership it should be deleted both from Shibboleth and 
## User rights management page!
$shib_group_delete = false;

## The ShibUpdateUser hook is executed on login.
## It has two arguments:
## - $existing: True if this is an existing user, false if it is a new user being added
## - &$user: A reference to the user object. 
##           $user->updateUser() is called after the function finishes.
## In the event handler you can change the user object, for instance set the email address or the real name
## The example function shown here should match behavior from previous versions of the extension:

$wgHooks['ShibUpdateUser'][] = 'ShibUpdateTheUser';

function ShibUpdateTheUser($existing, &$user) {
        global $shib_email;
        global $shib_RN;
        if (! $existing) {
                if($shib_email != null)
                        $user->setEmail($shib_email);
                if($shib_RN != null)
                        $user->setRealName($shib_RN);
        }
        return true;
}

## This is required to map to something
## You should beware of possible namespace collisions, it is best to chose
## something that will not violate MW's usual restrictions on characters
## Map Username to what Shibboleth variable?
##$shib_UN = isset($_SERVER['HTTP_UID']) ? $_SERVER['HTTP_UID'] : null;
$shib_UN = isset($_SERVER['eppn']) ? ucfirst(strtolower($_SERVER['eppn'])) : null;

## hide "IP login" and default login link
$wgShowIPinHeader = false;
function NoLoginLinkOnMainPage( &$personal_urls ){
    unset( $personal_urls['login'] );
    unset( $personal_urls['anonlogin'] );
    return true;
}
$wgHooks['PersonalUrls'][]='NoLoginLinkOnMainPage';

## to disable factory user login
function disableUserLoginSpecialPage(&$list) {
        unset($list['Userlogin']);
        return true;
}
$wgHooks['SpecialPage_initList'][]='disableUserLoginSpecialPage';

## Add to permit the management of the User rights
$wgUserrightsInterwikiDelimiter = '#';

## Activate Shibboleth Plugin
SetupShibAuth();

mediawiki.conf Apache2 (>=2.4) site configuration example

<IfModule mod_alias.c>
  Alias /wiki /var/www/html/mediawiki-1.23.13/

  <Directory /var/www/html/mediawiki-1.23.13/>
    Options Indexes MultiViews FollowSymLinks
    Order deny,allow
    Allow from all
  </Directory>

  <Location /wiki>
    AuthType shibboleth
    require shibboleth
  </Location>

  <Location /wiki/login.php>
    AuthType shibboleth
    ShibRequestSetting requireSession true
    require shib-attr entitlement urn:mace:example.it:wiki
  </Location>

</IfModule>

mediawiki-shibboleth-authentication's People

Contributors

biancini avatar daserzw avatar francescm avatar malavolti avatar scolytus avatar tmichel avatar vbalazs avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mediawiki-shibboleth-authentication's Issues

Does not work for MW 1.27 and above

Whenever I try to save a page edit, I see this:

Sorry! We could not process your edit due to a loss of session data.

You might have been logged out. Please verify that you're still logged in and try again. If it still does not work, try logging out and logging back in, and check that your browser allows cookies from this site.

Everything worked before the upgrade to 1.28. Others appear to have this issue as you can see at the very bottom of the discussion section of the project website.

https://www.mediawiki.org/wiki/Extension_talk:Shibboleth_Authentication#ShibAuthPlugin_not_working_on_MW_REL1_27

Automatic user account creation cannot be disabled

Using MW 1.27.3 & ShibAuthPlugin 1.2.7

Attempted to disable the account creation in using the settings (according to [1])
$wgGroupPermissions['*']['createaccount'] = false;

But using the ShibAuthPlugin 1.2.7 though, anyone logging in using this feature automatically gets a local account created.
Note. The account creation can be disabled when using this setting with the LdapAuthentication 2.1.0 [2] and the option
$wgLDAPDisableAutoCreate = array('testLDAPdomain' => true);.

Another attempt was to change ShibAuthPlugin.php, but it didn't help either:

        function autoCreate() {
                return false;
        }

        function updateExternalDB( $user ) {
                return false;
        }

How to stop the ShibAuthPlugin plugin from automatically creating the accounts?
Does exist an option like $wgLDAPDisableAutoCreate?

[1] https://www.mediawiki.org/wiki/Manual:Preventing_access#Restrict_account_creation
[2] https://www.mediawiki.org/wiki/Extension:LDAP_Authentication

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.