Extension:OAuth
![]() リリースの状態: 安定 |
|
---|---|
実装 | 利用者識別 , 利用者権限 , API |
説明 | 利用者が自分の代わりに MediaWiki 操作 API を使用する別のアプリケーション ("consumer") を安全に認可できるようにする。 |
最新バージョン | 1.1.0 (continuous updates) |
互換性の方針 | MediaWikiとともにリリースされるスナップショット。 master には後方互換性がありません。 |
MediaWiki | >= 1.38.0 |
データベースの変更 | はい |
Composer | mediawiki/oauth |
テーブル | oauth_accepted_consumer oauth_registered_consumer |
ライセンス | GNU 一般公衆利用許諾書 2.0 以降 |
ダウンロード | |
ヘルプ | Help:OAuth |
|
|
|
|
Quarterly downloads | 140 (Ranked 69th) |
Public wikis using | 1,179 (Ranked 211st) |
translatewiki.net で翻訳を利用できる場合は、OAuth 拡張機能の翻訳にご協力ください | |
Vagrant role | oauth |
問題点 | 未解決のタスク · バグを報告 |
The OAuth extension implements an OAuth server in MediaWiki that supports both the OAuth 1.0a and OAuth 2.0 protocol versions.
It allows third party developers to securely develop applications ("consumers"), to which users can give a limited set of permissions ("grants"), so that the application can use the MediaWiki action API on the user's behalf.
要件
- OAuthは一時的なトークンとセッションのためにオブジェクトキャッシュに依存しています。 This should work as long as cache configuration settings are sane. (Older versions required Memcached explicitly.)
- 現在、MySQLとSQLiteのデータベースバックエンドのみをサポートしています。
- If the MediaWiki installation is private (i.e. users need to log in to have read access), Special:OAuth will need to be added to the white list.
インストール
- ダウンロードして、ファイルを
extensions/
フォルダー内のOAuth
という名前のディレクトリ内に配置します。 - Gitでのインストールの場合のみ、PHPの依存関係をインストールするためComposerを実行します。 (合併症の可能性についてはタスク T173141を参照。)
- 以下のコードを
LocalSettings.php
の末尾に追加します:wfLoadExtension( 'OAuth' );
- 更新スクリプトを実行します。このスクリプトは、この拡張機能が必要とするデータベーステーブルを自動的に作成します。
- 必要に応じて一般的なパラメーターを設定します。
- 利用者権限の設定は、
$wgGroupPermissions
の該当するグループ配下に置くと実行されます。 - 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
MediaWiki 1.24以前を稼働させている利用者へ:
上記の手順では、wfLoadExtension()
を使用してこの拡張機能をインストールする新しい方法を記載しています。
この拡張機能をこれらの過去のバージョン (MediaWiki 1.24以前) にインストールする必要がある場合は、wfLoadExtension( 'OAuth' );
の代わりに以下を使用する必要があります:
require_once "$IP/extensions/OAuth/OAuth.php";
Vagrant installation:
- Vagrant を使用している場合は、
vagrant roles enable oauth --provision
でインストールしてください。
利用者権限
権限 | 説明 |
---|---|
mwoauthproposeconsumer | 新しいコンシューマーを提案 |
mwoauthupdateownconsumer | 自身が制御できるOAuthコンシューマーを更新 |
mwoauthmanageconsumer | OAuthコンシューマーを管理 |
mwoauthsuppress | OAuthコンシューマーを秘匿 |
mwoauthviewsuppressed | 秘匿されたOAuthコンシューマーを閲覧 |
mwoauthviewprivate | 非公開OAuthデータを閲覧 |
mwoauthmanagemygrants | OAuth付与を管理 |
To assign a permission to some group, for example to sysops, you add following line to LocalSettings.php
:
$wgGroupPermissions['sysop']['mwoauthproposeconsumer'] = true;
設定
変数名 | 既定値 | 説明 |
---|---|---|
$wgMWOAuthCentralWiki
|
false
|
Wiki ID of OAuth management wiki. On wiki farms, it makes sense to set this to a wiki that acts as a portal site, is dedicated to management, or just handles login/authentication. It can, however, be set to any wiki in the farm. For single-wiki sites or farms where each wiki manages consumers separately, it should be left as false .
|
$wgMWOAuthSharedUserIDs
|
false
|
(廃止予定) Use $wgMWOAuthSharedUserSource instead
Whether shared global user IDs are stored in the oauth tables.
On wiki farms with a central authentication system (with integer user IDs) that share a single OAuth management wiki, this must be set to true.
If wikis have a central authentication system but have their own OAuth management, then this can be either |
$wgMWOAuthSharedUserSource
|
null
|
Central ID provider when sharing OAuth credentials over a wiki farm
Source of shared user IDs, if enabled. If CentralIdLookup is available, this is the $providerId for CentralIdLookup::factory(). Generally null would be what you want, to use the default provider. If that class is not available or the named provider is not found, this is passed to the OAuthGetUserNamesFromCentralIds, OAuthGetLocalUserFromCentralId, OAuthGetCentralIdFromLocalUser, OAuthGetCentralIdFromUserName hooks. This has no effect if $wgMWOAuthSharedUserIDs is set to false. |
$wgMWOAuthRequestExpirationAge
|
2592000 (30 days)
|
Seconds after which an idle request for a new Consumer is marked as "expired" |
$wgMWOAuthSecureTokenTransfer
|
true
|
Require SSL/TLS for returning Consumer and user secrets. This is required by RFC 5849, however if a wiki wants to use OAuth, but doesn't support SSL, this option makes this configuration possible. This should be set to true for most production settings. |
$wgOAuthSecretKey
|
$wgSecretKey
|
A secret configuration string (random 32-bit string generated using "base64_encode(random_bytes(32))") used to hmac the database-stored secret to produce the shared secrets for Consumers. This provides some protection against an attacker reading the values out of the consumer table (the attacker would also need $wgOAuthSecretKey to generate valid secrets), and some protection against potential weaknesses in the secret generation. If this string is compromised, the site should generate a new $wgOAuthSecretKey, which will invalidate Consumer authorizations that use HMAC/shared secret signatures instead of public/private keys. Consumers can regenerate their new shared secret by using the "Reset the secret key to a new value" option under Special:MWOAuthConsumerRegistration/update. If null, the value is set to $wgSecretKey. |
$wgOAuthGroupsToNotify
|
[]
|
The list of user groups which should be notified about new consumer proposals. Setting this will only have an effect when Echo is installed. |
$wgMWOauthDisabledApiModules
|
[]
|
List of API module classes to disable when OAuth is used for the request |
$wgMWOAuthReadOnly
|
false
|
Prevent write activity to the database. When this is set, consumers cannot be added or updated, and new authorizations are prohibited. Authorization headers for existing authorizations will continue to work. Useful for migrating database tables |
$wgMWOAuthSessionCacheType
|
$wgSessionCacheType
|
The storage mechanism for session data. If null, it defaults to $wgSessionCacheType. |
$wgOAuth2EnabledGrantTypes
|
[
"authorization_code",
"refresh_token",
"client_credentials"
]
|
List of OAuth2 grants that client applications can be allowed to use. Actual grants client application will be allowed to use can be any subset of grants listed here. Grants, other than the ones listed here, are considered legacy grants, and are not supported by this extension |
$wgOAuth2PrivateKey
|
""
|
Private key or a path to the private key used to sign OAuth2 JWT being transmitted. See the OAuth 2.0 Server documentation for how to generate the keys. |
$wgOAuth2PublicKey
|
""
|
Public key or a path to the public key used to verify OAuth2 resource requests. |
$wgOAuth2RequireCodeChallengeForPublicClients
|
true
|
Controls whether clients are required to send code challenges with OAuth2 requests. This only applies to non-confidential clients. |
$wgOAuth2GrantExpirationInterval
|
"PT1H"
|
Controls validity period for access tokens. Does not apply to owner-only clients, whose access tokens are always non-expiring. Accepts ISO 8601 durations or can be set to "infinity" or false for non-expiring tokens. |
$wgOAuth2RefreshTokenTTL
|
"PT1M"
|
Controls validity period for refresh tokens. Accepts ISO 8601 durations or can be set to "infinity" or false for non-expiring tokens. |
OAuth 2.0 REST endpoints
The following REST endpoints are provided for OAuth 2.0 interaction
パス | 説明 | 許容されるパラメーター | Allowed method | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
/oauth2/authorize | Used for retrieving authorization code when using authorization_code grant. |
|
GET | ||||||||||||||||||||||||||||||||||||||||||||||||||
/oauth2/access_token | Used for requesting access tokens |
|
POST | ||||||||||||||||||||||||||||||||||||||||||||||||||
/oauth2/resource/{{type}} | Used for retrieving protected resources using the access token issued previously.
Currently, two resource types can be retrieved using this endpoint, by replacing
|
No parameters are allowed, apart from the {{type}} parameter that is included in the path
|
GET/POST | ||||||||||||||||||||||||||||||||||||||||||||||||||
/oauth2/client | Lists OAuth 1.0a or 2.0 clients for the logged-in user. Authentication can be achieved over CentralAuth or by including an access token in the authorization header.
|
|
GET | ||||||||||||||||||||||||||||||||||||||||||||||||||
/oauth2/client/{client_key}/reset_secret | Resets a client secret. For owner-only clients, this endpoint also resets the access token.
|
|
POST | ||||||||||||||||||||||||||||||||||||||||||||||||||
/oauth2/client | Creates an OAuth 2.0 client.
|
|
POST |
実験用RESTエンドポイント
実験的なRESTエンドポイントを有効にするには、$wgRestAPIAdditionalRouteFiles 設定変数をLocalSettings.phpに追加してください。
$wgRestAPIAdditionalRouteFiles[] = "$wgExtensionDirectory/OAuth/experimentalRoutes.json";
関連項目
- Extension:OATHAuth - A similarly named extension which implements a second authentication factor using OATH-based one-time passwords.
- Extension:WSOAuth – A MediaWiki extension that lets your wiki delegate authentication to any OAuth provider using PluggableAuth, including a wiki that is running Extension:OAuth.
- oauthclient-php – A client library for OAuth consumers.
この拡張機能は 1 つ以上のウィキメディアのプロジェクトで使用されています。 これはおそらく、この拡張機能が安定していて高いトラフィックのウェブサイトでも十分に動作することを意味します。 この拡張機能がインストールされている場所を確認するには、ウィキメディアの設定ファイル CommonSettings.php および InitialiseSettings.php 内で、この拡張機能の名前を探してください。 特定のウィキにインストールされている拡張機能の完全な一覧は、そのウィキの Special:Version ページにあります。 |
この拡張機能は以下のパッケージ/ウィキファームに含まれています: This is not an authoritative list. Some wiki farms/hosts may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |