Extension:OpenID Connect/fi

This page is a translated version of the page Extension:OpenID Connect and the translation is 28% complete.
This extension is maintained by a member of the MediaWiki Stakeholders' Group .
This extension requires the PluggableAuth extension to be installed first.
MediaWikin laajennukset-ohje
OpenID Connect
Julkaisustatus: vakaa
Toteutus Käyttäjän identiteetti
Kuvaus Extends the PluggableAuth extension to provide authentication using OpenID Connect
Tekijä(t) Cindy Cicalese (cindy.cicalesekeskustelu)
Viimeisin versio 7.0-dev (2023-02-25)
Yhteensopivuuskäytäntö Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki >= 1.36.0
Tietokantamuutokset Kyllä
Composer mediawiki/openidconnect
Taulukot openid_connect
Lisenssi MIT-lisenssi
  • $wgPluggableAuth_Config
  • $wgOpenIDConnect_UseRealNameAsUserName
  • $wgOpenIDConnect_UseEmailNameAsUserName
  • $wgOpenIDConnect_MigrateUsers
  • $wgOpenIDConnect_ForceLogout
Voit kääntää OpenID Connect-laajennuksen mikäli se on saatavilla translatewiki.netissä
Ongelmat Avoimet tehtävät · Raportoi ongelmasta

The OpenID Connect extension extends the PluggableAuth extension to provide authentication using OpenID Connect.

Special thanks to jumbojett for the OpenID Connect PHP library used by this extension.


This extension requires PluggableAuth to be installed first. It also requires the CURL PHP extension and the OpenID Connect PHP library, which may be installed using composer. If you are updating from version 4.x or below to version 6.x or above, you will need to update to version 5.x first.

Install Dependencies

Add the line "extensions/OpenIDConnect/composer.json" to the "composer.local.json" file in the root directory of your wiki, e.g.

	"extra": {
		"merge-plugin": {
			"include": [

Then run composer update in the root directory of your wiki. This will install any dependencies (i.e. the jumbojett OpenID Connect PHP library).


Most of the configuration for OpenID Connect is handled by a file found at /.well-known/openid-configuration[1] on the provider's domain. This contains most of the settings that are needed to handle authentication.

Flag Default Description
$wgPluggableAuth_Config (see Extension:PluggableAuth#Configuration) [] A mandatory array of arrays specifying the OpenID Connect issuers and their configuration. The data field of the array contains an array that has the following keys:
  • providerURL (mandatory): the URL of the issuer (e.g. https://accounts.google.com/ for Google) that is used to find the "well-known" file mentioned above (e.g. https://accounts.google.com/.well-known/openid-configuration for Google)
  • clientID (mandatory)
  • clientsecret (mandatory)
  • proxy (optional URL)
  • scope (optional): string or array of strings to be passed to the issuer, defaults to [ 'openid', 'profile', 'email' ]
  • preferred_username (optional preferred username field from issuer to use)
  • verifyHost (optional boolean to enable/disable host verification; default: true)
  • verifyPeer (optional boolean to enable/disable SSL peer verification; default: true)
  • authparam (optional associative array of authentication parameters to be passed to the issuer)
  • providerConfig (optional associative array used to alter a provider's endpoints and other attributes)
$wgOpenIDConnect_UseRealNameAsUserName false If a new user is being created in the database and no preferred username was provided by the issuer, a value of true for this flag indicates that the user's real name, if provided by the issuer, should be used as the new user's username.
$wgOpenIDConnect_UseEmailNameAsUserName false If a new user is being created in the database, and no preferred username was provided by the issuer, and either no real name was provided by the issuer or $wgOpenIDConnect_UseRealNameAsUserName was undefined or set to false, a value of true for this flag indicates that the name portion of the user's email address, if provided by the issuer, should be used as the new user's username.
$wgOpenIDConnect_MigrateUsersByUserName false If a user already exists in the database with the same user name as the authenticated user and has null values for subject and issuer, use this user, setting the subject and issuer in the database to those of the authenticated user. This is useful when the wiki previously used a different authentication mechanism.
$wgOpenIDConnect_MigrateUsersByEmail false If a user already exists in the database with the same email address as the authenticated user and has null values for subject and issuer, use this user, setting the subject and issuer in the database to those of the authenticated user. This is useful when the wiki previously used a different authentication mechanism.
$wgOpenIDConnect_ForceLogout false Upon logout, request authentication passing attribute prompt with a value of login (not fully supported by all OpenID Connect servers yet).

When configuring the identity provider, it will ask for a redirect URL or callback URL. Use the full URL to the Special:PluggableAuthLogin page for that value.

A simple example of the $wgPluggableAuth_Config configuration for a single issuer is as follows:

$wgPluggableAuth_Config[] = [
    'plugin' => 'OpenIDConnect',
    'data' => [
        'providerURL' => 'https://id.mycompany_abc.com/connect/',
        'clientID' => '.....',
        'clientsecret' => '.....'

An example of the $wgPluggableAuth_Config configuration for multiple issuers is as follows:

$wgPluggableAuth_Config["My Company's Connect Server"] = [
    'plugin' => 'OpenIDConnect',
    'data' => [
        'providerURL' => 'https://id.mycompany_abc.com/connect/',
        'clientID' => '.....',
        'clientsecret' => '.....'
$wgPluggableAuth_Config["Partner Company's Connect Server"] = [
    'plugin' => 'OpenIDConnect',
    'data' => [
        'providerURL' => 'https://id.partnercompany_def.com/connect/',
        'clientID' => '.....',
        'clientsecret' => '.....'

Example: Google as an Issuer

  1. Using the Google Developer Console create a project.
  2. Click on the project, click on the hamburger menu (three horizontal lines in the top left), and click on APIs & Services -> Credentials on the menu.
  3. Click the Create credentials -> OAuth client ID button and select Web application. Fill in the consent screen information and save.
  4. Provide the redirect URI in Authorized redirect URIs[2]:
  5. Click Create Client ID.
  6. Note the Client ID and Client Secret that are assigned.

The Google issuer is now configured. Add the corresponding configuration to your LocalSettings.php file, filling in the clientID and clientsecret fields with the values assigned above.

$wgPluggableAuth_Config[] = [
    'plugin' => 'OpenIDConnect',
    'data' => [
        'providerURL' => 'https://accounts.google.com',
        'clientID' => '.....',
        'clientsecret' => '.....',

You may also assign other values such as proxy and authparam.

Example: Using it against Azure Active Directory

  1. In the Azure portal, go to 'Active Directory' and then 'App Registrations'
  2. Register a new Application
    1. Provide a Name
    2. Likely specify 'Accounts in this org directory only'
    3. Provide redirect URI:[2]
  3. In the new app, go to 'Certificates and secrets' and create a new Client secret
  4. Using the 'Application (client) ID', Directory (tenant) ID, and Secret from the application, populate your LocalSettings.php:
    $wgPluggableAuth_Config[] = [
        'plugin' => 'OpenIDConnect',
        'data' => [
            'providerURL' => 'https://login.microsoftonline.com/[tenantID]/v2.0/',
            'clientID' => '[Application (Client) ID]',
            'clientsecret' => '[Secret from Certs and Secrets]'
    $wgOpenIDConnect_UseRealNameAsUserName = true;

Tärkeät huomiot
  • Using the Client secret will result in the expiration of the key
  • The .well-known/openid-configuration location was derived from the 'OpenID Connect metadata document' endpoint in the app Endpoints.

Example: Using it against Keycloak


  • Your Keycloak realm name is acme
  • Your Keycloak URL and Port is https://keycloak.local:8080
  • Your Keycloak Client ID is set to mediawiki
  • Your auto-generated client secret is 12345
$wgPluggableAuth_Config[] = [
    'plugin' => 'OpenIDConnect',
    'data' => [
        'providerURL' => 'https://keycloak.local:8080/realms/acme',
        'clientID' => 'mediawiki',
        'clientsecret' => '12345'


  • If you're running into trouble, like "The provider {$param} could not be fetched. Make sure your provider has a well known configuration available.", your URI is wrong. You can test the correctness by calling https://keycloak.local:8080/realms/acme/.well-known/openid-configuration in your browser. If you get back a long JSON, the path is correct.
    • Another way to verify the 'providerURL' is to check it against the ‘Redirect URI’ at Keycloak>Identity Providers>keycloak-oidc, i.e.: https://keycloak.local:8080/realms/acme/broker/keycloak-oidc/endpoint. For 'providerURL' you need the portion up to one level below realms.
  • Make sure the redirect uri provided by this OIDC plugin is set valid for your keycloak-server under acme -> Clients -> mediawiki -> Settings -> valid redirect uris . For testing purposes you can add a wildcard "*".

Example: Using it with Okta

  Note: As of the date this example was written, a bug exists in the OpenID Connect PHP library which causes stricter OIDC providers like Okta to reject certain requests. This should be resolved in the future when the library is updated to incorporate the change. The solution is to add a single line of code to $MEDIAWIKI_ROOT/extensions/OpenIDConnect/vendor/jumbojett/openid-connect-php/src/OpenIDConnectClient.php as follows: right below: unset($token_params['client_secret']); simply add: unset($token_params['client_id']); # see https://github.com/jumbojett/OpenID-Connect-PHP/pull/208/commits/dd44c1ca7e45d35dcd8f32ea503b545149bc6562 (this was fixed in version 0.9.8)

To authenticate your users against Okta, you must first create a new OIDC app in your Okta org and assign it to the relevant users/groups, etc.

Okta OIDC app settings

Allowed grant types: (all)
Login redirect URIs: the full URL to Special:PluggableAuthLogin, e.g. https://www.example.com/wiki/index.php/Special:PluggableAuthLogin
Login flow: "Redirect to app to initiate login (OIDC compliant)"
Initiate login URI: the full URL to Special:UserLogin, e.g. https://www.example.com/wiki/index.php/Special:UserLogin

Laajennuksen asetukset

You must specify the openid, profile, and email scopes to communicate with Okta. If you omit the appropriate scopes, Okta will gladly authenticate your users but will not return any useful claims.

$wgPluggableAuth_Config[] = [
    'plugin' => 'OpenIDConnect',
    'data' => [
        'providerURL' => 'https://your-okta-org.okta.com',
        'clientID' => '(paste the client ID Okta assigned your new app here)',
        'clientsecret' => '(paste the client secret Okta assigned your new app here)'

Auto-creating users

If you want to take advantage of MediaWiki's user auto-creation (e.g. $wgGroupPermissions['*']['autocreateaccount'] = true;), be aware that Okta's preferred_username claims take the format of an email address.

If you do not want your users to have an @ character in their usernames (this is forbidden by MediaWiki by default), you will need to specify an alternative claim to use via the 'preferred_username' key in your $wgPluggableAuth_Config.

Allowing @ in usernames may break your wiki's Interwiki compatibility (if you rely on that). To allow the use of the @ character, just set $wgInvalidUsernameCharacters = ' '; and $wgUserrightsInterwikiDelimiter = '#'; in LocalSettings.php.

Example: Using it with Gitlab

Gitlab configuration:

  • Login to Gitlab Admin Area
  • Go to Applications -> New Application
    • Name: MediaWiki
    • Redirect URI: <wiki server>/wiki/Special:PluggableAuthLogin
    • Trusted: yes
    • Confidential: yes
    • Scopes: openid, profile, email
  • Submit
  • Copy Application ID and Secret to LocalSettings.php

MediaWiki Configuration

In "LocalSettings.php"

// Extension PluggableAuth
wfLoadExtension( 'PluggableAuth' );
$wgPluggableAuth_EnableLocalLogin = true; // set to false to deactivate local logins if required

// Extension OpenIDConnect
wfLoadExtension( 'OpenIDConnect' );
$wgPluggableAuth_Config['Login with your Gitlab Account'] = [
   'plugin' => 'OpenIDConnect',
   'data' => [
       'providerURL' => '...',  // '''Add your gitlab server here (main page)'''
       'clientID' => '...',     // '''Insert Gitlab Application ID here!'''
       'clientsecret' => '...', // '''Insert Gitlab Secret here!'''
       // Alternative 'nickname'
       // Alternative 'name'
       'preferred_username' => 'nickname'

You can find more information to Gitlab's docs at OpenID Connect Provider.

Example: Using it against Amazon Cognito


  • Your Amazon Cognito user pool ID is us-west-2_XdLg34nAA
  • Your AWS region is us-west-2
  • Your Client ID is set to mediawiki
  • Your auto-generated client secret is 12345
$wgPluggableAuth_Config[] = [
    'plugin' => 'OpenIDConnect',
    'data' => [
        'providerURL' => 'https://cognito-idp.us-west-2.amazonaws.com/us-west-2_XdLg34nAA',
        'clientID' => 'mediawiki',
        'clientsecret' => '12345'

For detailed instructions about how to configure Amazon Cognito for this use case, please refer to https://medium.com/@robert.broeckelmann/openid-connect-authorization-code-flow-with-aws-cognito-246997abd11a

Example: Using it against NextCloud


  • Running Nextcloud version 24, or Nextcloud All-In-One v3.0.0
  • Nextcloud has the App "OIDC Identity Provider v0.2.6" installed. https://github.com/H2CK/oidc
  • Your nextcloud runs from domain my.nextcloud.com
  • The public url : https://my.nextcloud.com/.well-known/openid-configuration is redirected to <your internal nextcloud server>/index.php/apps/oidc/openid-configuration by e.g. nginx or another reverse proxy.
  • Via nextcloud admin account, under Settings > Security > "Open ID Connect clients" you add a client with the following details
    • Name: wiki
    • Redirection URI: SomeWrongURI
    • Signing Algorithm: RS256
    • Type: confidential When you click "add" it will provide the Client Identifier string and the Secret string. Enter these values into the Localsettings.php for myGeneratedID and myGeneratedSecret shown below.

MediaWiki's LocalSettings.php addition:

wfLoadExtension( 'PluggableAuth' );
$wgGroupPermissions['*']['autocreateaccount'] = true;
$wgPluggableAuth_EnableAutoLogin = true; // Now the user doesn't have the 'login'/'logout' button.

wfLoadExtension( 'OpenIDConnect' );
$wgPluggableAuth_Config[] = [
    'plugin' => 'OpenIDConnect',
    'data' => [
        'providerURL' => 'https://my.nextcloud.com',
        'clientID' => 'myGeneratedID',
        'clientsecret' => 'myGeneratedSecret'

Now navigate to the Wikipedia page, it will redirect to your nextcloud server. The nextcloud server will state that the landing page is incorrect, and to contact the administrator for this client. Copy the URL of this page, and copy the argument part for "redirect_uri". Use an online site to decode the http URL.


URL: https://my.nextcloud.com/apps/oidc/authorize?response_type=code&redirect_uri=https%3A%2F%2Fmy.wiki.com%2Findex.php%2FSpeciaal%3APluggableAuthLogin&client_id=xvLZjUpAvxn

Decoded redirect URI: https://my.wiki.com/index.php/Speciaal:PluggableAuthLogin

Use the found string in Nextcloud OpenID settings for client "wiki", and update the Redirection URI by replacing the previously entered "SomeWrongURI" with the found string.

Release Notes

Version 6.2
  • Update jumbojett/openid-connect-php library version to 0.9.10
  • Replace deprecated User::idFromName
Version 6.1
  • Make sure populate group hook only runs for OpenID Connect plugin instances
Version 6.0
  • Updated to be compatible with PluggableAuth version 6.0
Version 5.4
  • Updated jumbojett/openid-connect-php to version 0.9.1
  • Fixed bug while trying to authenticate with Okta where extra parameters are sent in the request making the request fail
Version 5.3
  • Fixed bug with migrated initial lowercase usernames (T249630)
Version 5.2
  • Added optional configuration options for disabling the verification of hostnames and certificates, for use in development environments with self-issued certificates
Version 5.1
  • Added generation of full redirect URL so OpenID Connect PHP library doesn't have to guess, which occasionally it didn't have enough information to do accurately
Version 5.0
  • Moved subject and issuer columns from user table to openid_connect table (requires database update)
  • Added support for Postgres
Version 4.1
  • Added namespace for library class
Version 4.0
  • Added optional error message to authenticate()
  • Bumped version number to synchronize with PluggableAuth and SimpleSAMLphp extensions
Version 2.3
  • Fixed whitelist implementation
  • Changes migration flags to allow migration by email address in addition to migration by user name
Version 2.2
  • Fixes related to PluggableAuth MediaWIki 1.27 upgrade
  • Array coding conventions
Version 2.1
  • Update to MediaWiki 1.27 session management
  • Added default values for configuration variables to extension.json
Version 2.0
  • Updated extension registration
  • Changed configuration variables to use "wg" prefix
  • Added composer.json to get OpenID Connect library using composer
Version 1.2
  • Added ability to specify auth params and added support for table prefixes
Version 1.1
  • Added support for Google
Version 1.0
  • Initial version

Tunnetut ongelmat

  • Wikis that use URLs of the form https://example.org/w/index.php?title=Page_title (i.e. having the page title provided as a query parameter) will not be redirected correctly to complete the authentication flow. Instead, URLs must be of the form https://example.org/w/index.php/Page_title, which can be accomplished by using short URLs or by setting $wgArticlePath appropriately.
  • This extension may not work correctly with $wgMainCacheType = CACHE_ACCEL;. In this case you also need to set $wgSessionCacheType = CACHE_DB; (see task T147161).
  • This extension does not work on non-standard ports unless you manually update the underlying Openid connect client, see: jumbojett/OpenID-Connect-PHP issue 58 on GitHub. This issue also applies when connecting to other webserver than IIS.
  • When running the createAndPromote.php maintenance script, both the PluggableAuth and OpenID Connect extensions need to be disabled by commenting out their wfLoadExtension() calls.


  1. openid.net: OpenID Provider Configuration Request
  2. 2.0 2.1 Note that the link for the authorized redirect URI must be localized, e.g if you set your wiki's instance language to 'de' ($wgLanguageCode = 'de';) you need to specify "https://[URLofWiki]/wiki/Spezial:PluggableAuthLogin".

See also