Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7410955
CentralAuthHeaderSessionProvider.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
CentralAuthHeaderSessionProvider.php
View Options
<?php
use
MediaWiki\Request\WebRequest
;
/**
* Session provider for CentralAuth Authorization header for use in REST APIs.
*
* This session provider looks for an Authorization header using the MWCentralAuth
* authentication type, and checks that the token provided in the header
* corresponds to an existing token set up by ApiCentralAuthToken.
* If the header is present but invalid, it returns a
* bogus SessionInfo to prevent other SessionProviders from establishing a session.
*
* @see \MediaWiki\Extension\CentralAuth\Api\ApiCentralAuthToken
*/
class
CentralAuthHeaderSessionProvider
extends
CentralAuthTokenSessionProvider
{
/** @inheritDoc */
protected
function
getTokenDataFromRequest
(
WebRequest
$request
)
{
$authHeader
=
$request
->
getHeader
(
'Authorization'
);
if
(
$authHeader
===
null
)
{
return
null
;
}
if
(
!
preg_match
(
'/^CentralAuthToken
\s
+(
\w
+)/is'
,
$authHeader
,
$match
)
)
{
return
null
;
}
$oneTimeToken
=
$match
[
1
];
if
(
$oneTimeToken
===
null
)
{
return
null
;
}
return
$this
->
tokenManager
->
detokenizeAndDelete
(
$oneTimeToken
,
'api-token'
);
}
/**
* This session provider is based on a header, so it's safe against CSRF attacks.
* @return true
*/
public
function
safeAgainstCsrf
()
{
return
true
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 23:19 (1 d, 22 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
98/b3/edcab8d0515cb6f1700b44717824
Default Alt Text
CentralAuthHeaderSessionProvider.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment