mwstake / mediawiki-component-oauth-client
2.0.0
2024-07-17 14:20 UTC
Requires
- ext-sodium: *
- composer/installers: ~1.0|~2
- firebase/php-jwt: ^6.10.0
- league/oauth2-client: 2.6.*
- mwstake/mediawiki-componentloader: ~1
- phpseclib/phpseclib: ~3.0
Requires (Dev)
- jakub-onderka/php-console-highlighter: 0.4.0
- jakub-onderka/php-parallel-lint: 1.0.0
- mediawiki/mediawiki-codesniffer: 29.0.0
- mediawiki/minus-x: 1.0.0
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-11-17 15:01:08 UTC
README
Library for user authentication over OAuth2 protocol.
Installation
composer require mwstake/mediawiki-component-oauth-client
Usage
Connection params
$GLOBALS['wgOAuthClientConfig'] = [ 'base_uri' => '', 'client_id' => '##CLIENT_ID##', 'client_secret' => '##CLIENT_SECRET##', // if needed adapt endpoints, if not, omit to use the defaults 'endpoints' => [ 'authorize' => '/oauth2/authorize', 'token' => '/oauth2/token', 'user' => '/oauth2/user', ], // if needed adapt scopes, if not, omit to use the defaults 'default_scopes' => [], 'redirect_uri' => ##REDIRECT_URI##, ];
Login page
Your implementation needs to provide a login page that will be used as the redirect target for the OAuth2 authorization code flow.
Specify the name of the SpecialPage in $GLOBALS['wgOAuthLoginPage'] = 'MyPage
;`
Resource owner
If you want to have a custom resource owner, implement a class that implements League\OAuth2\Client\Provider\ResourceOwnerInterface
and set it in $GLOBALS['wgOAuthClientResourceOwner'] = MyResourceOwner::class;
.
Otherwise, the default League\OAuth2\Client\Provider\GenericResourceOwner
will be used.