Extension:GoogleLogin

From mediawiki.org
This page is a translated version of the page Extension:GoogleLogin and the translation is 59% complete.
Outdated translations are marked like this.
MediaWiki 拡張機能マニュアル
GoogleLogin
リリースの状態: ベータ
実装 利用者識別 , 特別ページ
説明 Googleアカウントでのログインを可能にする
作者 Florian Schmidt (Florianschmidtwelzowトーク)
最新バージョン 0.4.0-git
MediaWiki >= 1.36.0
データベースの変更 はい
Composer mediawiki/googlelogin
テーブル googlelogin_allowed_domains
user_google_user
ライセンス MIT ライセンス
ダウンロード
README
  • $wgGLAPIKey
  • $wgGLAllowedDomainsStrict
  • $wgGLAppId
  • $wgGLAllowedDomainsDB
  • $wgGLAuthoritativeMode
  • $wgGLSecret
  • $wgGLEnableEchoEvents
  • $wgGLAllowedDomains
  • managegooglelogin
  • managegooglelogindomains
互換性の概要については、バージョン周期を参照してください。
Quarterly downloads 75 (Ranked 81st)
translatewiki.net で翻訳を利用できる場合は、GoogleLogin 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

GoogleLogin 拡張機能は、ウィキ利用者が Google アカウントを用いてログインできるようにします。この拡張機能はGoogle APIを使用してGoogleから基本的なプロフィール情報(アカウントID、名前、メールアドレスなど)を要求します。

要件

この拡張機能を使用すらには、以下が必要です。

  • MediaWiki 1.36+
  • MySQL/MariaDB (PostgreSQL、SQLiteは未対応)
  • PHP 7.3+
  • Google Developer アクセス
  • WebアプリケーションのAPI認証情報(クライアントID、クライアントシークレット)
  • composer update --no-devを実行できるようになりました。

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のGoogleLoginという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GoogleLogin
  • Gitでのインストールの場合のみ、PHPの依存関係をインストールするためComposerを実行します。 (合併症の可能性についてはタスク T173141を参照。)
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'GoogleLogin' );
    
  • 更新スクリプトを実行します。このスクリプトは、この拡張機能が必要とするデータベーステーブルを自動的に作成します。
  • 必要なパラメータを設定します
  • Web サーバーのユーザーが ./wiki/extensions/GoogleLogin/cache を書き込み可能であることを確認します。
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

設定

The extension provides two configuration variables to set the Client ID and Client Secret (you get this pair in the Google Developer Console, remove "<" and ">").

$wgGLSecret = '<your-client-secret>';
$wgGLAppId = '<your-client-id>';

追加の設定パラメータ

構成変数 既定値 説明
$wgGLAllowedDomains[gerrit 1] '' GoogleLogin で使用を許可するメールアドレスのドメイン。 [ 'example.com' ];。標準ではすべてのドメインを許可します。 設定されている場合や変更された場合は、"updatePublicSuffixArray.php" メンテナンス スクリプトを実行する必要があります。
$wgGLAllowedDomainsDB[gerrit 2] false true に設定すると、GoogleLogin はデータベースを使用して Google アカウントのプライマリメールアドレスのメールドメインがログインを許可されているかどうかをチェックします。
$wgGLAllowedDomainsStrict[gerrit 1] false Only observed, if $wgGLAllowedDomains is an array. If set to true, the email domain will be checked completely against the allowed domains (instead of only the TLD), e.g.:

test.example.com isn't allowed if $wgGLAllowedDomainsStrict is true and example.com is an allowed domain.
test.example.com is allowed if $wgGLAllowedDomainsStrict is false and example.com is an allowed domain.

$wgGLAPIKey[gerrit 3] '' 公開 API アクセス用のキー。利用者が Google Plus のプロファイルを持っているかどうかを確認するための管理操作にのみ使用されます。
$wgGLAuthoritativeMode[gerrit 4] false Controls the Authoritative mode of GoogleLogin.
$wgGLEnableEchoEvents true

Google Developer Consoleでの設定

To use this extension you need a Google developer account and access to the developer console. This is a very simple step-by-step guide (see also Googles help page on this):

Google 開発者コンソールを開く

  1. 利用規約を読み、同意する
  2. 最初のプロジェクトを作成する
  3. APIとサービスに移動する
  4. + 証明書を作成(CREATE CREDENTIALS)をクリックする
  5. OAuthクライアントIDを選択
  1. Select as Web application as APPLICATION TYPE, as Authorized JavaScript origins type in your domain name (no wildcards and directories allowed!)
  1. Type in your Authorized redirect URI like this example:
  1. If your domain is example.com and you have installed MediaWiki in Root of your domain, the redirect URI is as follows: https://example.com/index.php/Special:GoogleLoginReturn
  1. Click create and copy the Client ID and Client Secret to the configuration variables in LocalSettings.php

特別ページ"特別:GoogleLoginReturn"

The allowed redirect URI in Google developer console must be in the wiki's content language. If your wiki was set to German as the content language, then use Spezial:GoogleLoginReturn. In case you used the wrong language, all authentication requests will fail with the error code redirect uri mismatch.

デバッグ

Normally, you can see the error message on all generic error pages. Sometimes there are Internal Errors, called Exceptions. In this case, please add $wgShowExceptionDetails with value true in LocalSettings.php to see the complete Exception message. For a support request, please provide always the lines of the Exception.

非公開ウィキでの使用

Wikiを非公開にした場合

$wgGroupPermissions['*']['read'] = false;

you have to whitelist the "Special:GoogleLoginReturn" page, so that anonymous users can access the callback URL after being redirected from the authentication provider. You can do this by adding the following line to your LocalSettings.php:

$wgWhitelistRead = [ 'Special:GoogleLoginReturn' ];

The name of the special page must be in the wiki's content language. If your wiki was e.g. set to German as the content language, then use Spezial:Benutzerkonto_anlegen. In case you used the wrong language, all authentication requests will fail and redirect you to "Special:Login".

使用できるドメインを制限する

The user interface to manage the list of allowed domains.

GoogleLoginでは、Wikiへのログインを特定のメールアドレスのドメイン(gmail.com、googlemail.com、その他の独自ドメインなど)に制限することができます。Google Appsで独自ドメイン名を使用している組織には有用です。 The list of domains, which are allowed to login with Google, are managed in an array in the LocalSettings.php (the $wgGLAllowedDomains configuration option). Since version 0.4.0, GoogleLogin also provides a way to manage the list of allowed domains on the wiki itself. The allowed domains are saved in the database when this feature is enabled and can be change (remove/add) through a graphical user interface (a special page) or through the MediaWiki API.

Note: The list of allowed domains cannot be managed in LocalSettings.php anymore, once the administration of the domains in the database is enabled.

To enable the feature to manage the allowed domains in the database, just set the $wgGLAllowedDomainsDB configuration variable to true in your LocalSettings.php. You also want to assign the new managegooglelogindomains user right to one group you're a member of (please keep in mind, that all users with this user right are allowed to change the list of allowed domains, so consider to add this right to an administrator-level group only!). An example configuration could look like:

$wgGLSecret = 'your-secret';
$wgGLAppId = 'your-app-id';
$wgGLAllowedDomainsDB = true;
$wgGroupPermissions['sysop']['managegooglelogindomains'] = true;

You now need to run the update.php script again, so that the necessary database changes are applied to your database. After the update process is completed, you can navigate to the special page Special:GoogleLoginAllowedDomains on your wiki. You'll get a page where you can add new domains, which are allowed to login with their Google account and you can remove them, once they was added.

Configuration parameter "$wgGLAPIKey"

This configuration option still exists, but it's now used for more than just the Special:ManageGoogleLogin special page. It's now used to get the name of a user on Special:RemoveCredentials to make it easier to the user to identify the correct Google account (instead of just showing the Google ID). If the key isn't correct or isn't supplied, GoogleLogin will show the Google ID only. For a good user experience, it's highly suggested to supply this api key now.

認証モード

自動アカウント作成

GoogleLoginはいわゆるauthoritativeモードをサポートしており、これを有効にすると、ログインに使用されたGoogleアカウントがローカルのMediaWikiアカウントと関連付けられていない場合、アカウントを自動的に作成します。このモードは既定では無効になっており、設定オプションで有効にする必要があります。しかし、これを行う前に以下の重要な情報を読んでください。 この機能を利用するためには、Wikiの設定で以下を厳密にサポートする必要があります。

  • GoogleLoginは唯一の一次認証プロバイダである必要があり、例えば以下のように設定します。
$wgAuthManagerConfig = [
    'primaryauth' => [
        GoogleLogin\Auth\GooglePrimaryAuthenticationProvider::class => [
            'class' => GoogleLogin\Auth\GooglePrimaryAuthenticationProvider::class,
            'sort' => 0
        ]
    ],
    'preauth' => [],
    'secondaryauth' => []
];
$wgInvalidUsernameCharacters = ':~';
$wgUserrightsInterwikiDelimiter = '~';
  • アカウントの自動作成を有効にする必要があります。
$wgGroupPermissions['*']['autocreateaccount'] = true;
  • GoogleLoginの認証モードが有効になっている必要があります。
$wgGLAuthoritativeMode = true;

また、この機能を有効にすることで、以下のような影響があります。

  • アカウントの利用者名は、Googleアカウントのメールアドレスです。これは変更できません。
  • ローカルWikiのアカウントが既に連携されている場合は、そのアカウントでログインします。既にGoogleアカウントに連携されたアカウントが存在する場合は作成されません。
  • 新しく作成されたアカウントは、自動的にGoogleアカウントと連携されます。
  • GoogleLoginは、ユーザーがログインできなくなるのを防ぐために、Googleアカウントの接続(または自動的に作成されるリンク)をさらに追加または削除することを許可しません。
  • GoogleLogin はアカウント作成時にパスワードを設定しないため、認証モードを無効にしてパスワード でのログインを再度有効にした場合、利用者はパスワードをリセットする必要があります。

手動アカウント作成 Google Login also supports a variant of the so called authoritative mode, in which, when configured, a user account is still manually created by the respective user but automatically mapped to the Google account, which was used when creating the account, if it is not already associated with a local MediaWiki account. Moreover only permissive Google accounts can register an account manually.

  • Creation of accounts needs to be enabled (also for private wikis):
$wgGroupPermissions['*']['createaccount'] = true;
  • If on a private wiki the following pages need to be accessible by everybody, e.g. for English language wikis:
$wgWhitelistRead = [
    'Special:Login',
    'Special:GoogleLoginReturn',
    'Special:CreateAccount',
    'Special:CreateAccount/return'
];
Note that the special pages need to be added in the wiki language.
  • The primary authentication provider needs to be disabled, i.e. set
$wgAuthManagerAutoConfig['primaryauth'] = [ ];

Enabling manual account creation has the same influence as automatic account creation does (see above), however with the following difference:

  • The user who creates the account is free in its naming, i.e. some sort of user name logic cannot be enforced.
  • If a local wiki account is already connected, an additional new account cannot be created manually, which means that an already existing account takes precedence over creating a new one.

Google API PHP クライアント

この拡張機能は Google API PHP Client (0.2.1 より前のバージョンに同梱) を使用しており、Apache 2.0 License の下で配布されています。このクライアントは、GitHub からダウンロードすることができます。 The Client can be downloaded from GitHub.

Maintenance script "updatePublicSuffixArray.php"

"updatePublicSuffixArray.php" メンテナンス スクリプトは、世界で使用するのに有効なドメイン名のリストをダウンロードします。 これは、GoogleLoginで特定のドメインのログインを制限している場合に、特定のメールドメインのサブドメインを許可するために必要なものです。 This is only needed if $wgGLAllowedDomainsStrict is set to false (which is the default) and every time the setting configuration parameter $wgGLAllowedDomains was changed.

バージョン周期

なお、GoogleLoginは最新版のみサポートしています。現在のリリース(つまり現在のMediaWikiのリリースブランチ)および現在の開発版(別名master)以外のバージョンはもうサポートされていません。 Any versions apart from the current release (which means the current MediaWiki release branch) and the current development version (aka master) are not supported anymore.

脚注

Gerrit コードレビュー

関連項目

  • OpenID Connect - Allows for authentication and authorization, including logging in with Google.