Jump to content

Manual: Id. da Central

From mediawiki.org
This page is a translated version of the page Manual:Central ID and the translation is 44% complete.

A Id. da Central identifica os utilizadores entre as wikis. Nas instalações de wiki únicas, é o mesmo que a Id. do utilizador; nas farms de wiki que utilizam algum tipo de início de sessão único, provavelmente está atribuído pela extensão de autenticação. Os administradores do site podem configurá-lo definido $wgCentralIdLookupProvider .

Utilização de um provedor de Id. de Central

Any code that interacts with data that would benefit from being available cross-wiki (e.g. authentication and authorization details, cross-wiki blocks) should, instead of storing local user IDs, store the central ID and use the CentralIdLookup class to convert between local usernames and central IDs.

Such extensions should also allow their data to be stored centrally. Typically this is done by providing a virtual domain, and doing something like this to get a database connection:

Versão MediaWiki:
1.42
$db = \MediaWiki\MediaWikiServices::getInstance()->getConnectionProvider()->getPrimaryDatabase( 'virtual-myextension' );

(in MW 1.40-1.41, use getDBLoadBalancerFactory() rather than getConnectionProvider)

For an example of code making use of central IDs, see SpecialBotPasswords.

Exemplos básicos

Obtaining the default Central ID Lookup provider:

$lookup = \MediaWiki\MediaWikiServices::getInstance()->getCentralIdLookup();

Obtaining the central ID from a local user:

$centralId = $lookup->centralIdFromLocalUser( $user );


Writing a central ID provider

Single sign-on extensions should implement a subclass of CentralIdLookup and register it in $wgCentralIdLookupProviders .

For an example of a single sign-on extension providing central IDs, see CentralAuthIdLookup in Extensão: CentralAuth . Para uma lista de tais extensões , consulte Category:CentralIdLookup providers .