Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2753068
Workflow.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
Workflow.php
View Options
<?php
namespace
MediaWiki\Extension\OAuth\Control
;
use
MediaWiki\Config\ServiceOptions
;
use
MediaWiki\Extension\OAuth\Backend\Consumer
;
/** Service class for OAuth workflow-related business logic. */
class
Workflow
{
/** @internal For use by ServiceWiring */
public
const
CONSTRUCTOR_OPTIONS
=
[
'OAuthAutoApprove'
,
];
public
const
AUTOAPPROVE_RULE_GRANTS
=
'grants'
;
private
ServiceOptions
$options
;
/**
* @param ServiceOptions $options
*/
public
function
__construct
(
ServiceOptions
$options
)
{
$options
->
assertRequiredOptions
(
self
::
CONSTRUCTOR_OPTIONS
);
$this
->
options
=
$options
;
}
/**
* True if this is a low-risk consumer that does not require manual approval from an
* OAuth admin, and can go straight to the 'approved' stage after creation.
* @param Consumer $consumer
* @return bool
*/
public
function
consumerCanBeAutoApproved
(
Consumer
$consumer
):
bool
{
foreach
(
$this
->
options
->
get
(
'OAuthAutoApprove'
)
as
$condition
)
{
// check 'grants' rule
if
(
array_key_exists
(
self
::
AUTOAPPROVE_RULE_GRANTS
,
$condition
)
)
{
$allowedGrants
=
$condition
[
self
::
AUTOAPPROVE_RULE_GRANTS
];
if
(
array_diff
(
$consumer
->
getGrants
(),
$allowedGrants
)
!==
[]
)
{
continue
;
}
unset
(
$condition
[
self
::
AUTOAPPROVE_RULE_GRANTS
]
);
}
// check for unsupported rules
if
(
$condition
)
{
continue
;
}
return
true
;
}
// none of the conditions matched
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Jul 3, 20:45 (1 d, 9 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
95/cb/3f2c332b8be68f0da0b039e05f70
Default Alt Text
Workflow.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment