Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5982286
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
Sat, Oct 3, 22:17 (1 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
27/45/30560bc7625b0378f9e852d652bd
Default Alt Text
Workflow.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment