Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F429561
PhabricatorOAuthServerClient.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
PhabricatorOAuthServerClient.php
View Options
<?php
final
class
PhabricatorOAuthServerClient
extends
PhabricatorOAuthServerDAO
implements
PhabricatorPolicyInterface
,
PhabricatorDestructibleInterface
{
protected
$secret
;
protected
$name
;
protected
$redirectURI
;
protected
$creatorPHID
;
protected
$viewPolicy
;
protected
$editPolicy
;
public
function
getEditURI
()
{
return
'/oauthserver/client/edit/'
.
$this
->
getPHID
().
'/'
;
}
public
function
getViewURI
()
{
return
'/oauthserver/client/view/'
.
$this
->
getPHID
().
'/'
;
}
public
function
getDeleteURI
()
{
return
'/oauthserver/client/delete/'
.
$this
->
getPHID
().
'/'
;
}
public
static
function
initializeNewClient
(
PhabricatorUser
$actor
)
{
return
id
(
new
PhabricatorOAuthServerClient
())
->
setCreatorPHID
(
$actor
->
getPHID
())
->
setSecret
(
Filesystem
::
readRandomCharacters
(
32
))
->
setViewPolicy
(
PhabricatorPolicies
::
POLICY_USER
)
->
setEditPolicy
(
$actor
->
getPHID
());
}
protected
function
getConfiguration
()
{
return
array
(
self
::
CONFIG_AUX_PHID
=>
true
,
self
::
CONFIG_COLUMN_SCHEMA
=>
array
(
'name'
=>
'text255'
,
'secret'
=>
'text32'
,
'redirectURI'
=>
'text255'
,
),
self
::
CONFIG_KEY_SCHEMA
=>
array
(
'key_phid'
=>
null
,
'phid'
=>
array
(
'columns'
=>
array
(
'phid'
),
'unique'
=>
true
,
),
'creatorPHID'
=>
array
(
'columns'
=>
array
(
'creatorPHID'
),
),
),
)
+
parent
::
getConfiguration
();
}
public
function
generatePHID
()
{
return
PhabricatorPHID
::
generateNewPHID
(
PhabricatorOAuthServerClientPHIDType
::
TYPECONST
);
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public
function
getCapabilities
()
{
return
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
);
}
public
function
getPolicy
(
$capability
)
{
switch
(
$capability
)
{
case
PhabricatorPolicyCapability
::
CAN_VIEW
:
return
$this
->
getViewPolicy
();
case
PhabricatorPolicyCapability
::
CAN_EDIT
:
return
$this
->
getEditPolicy
();
}
}
public
function
hasAutomaticCapability
(
$capability
,
PhabricatorUser
$viewer
)
{
return
false
;
}
public
function
describeAutomaticCapability
(
$capability
)
{
return
null
;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public
function
destroyObjectPermanently
(
PhabricatorDestructionEngine
$engine
)
{
$this
->
openTransaction
();
$this
->
delete
();
$authorizations
=
id
(
new
PhabricatorOAuthClientAuthorization
())
->
loadAllWhere
(
'clientPHID = %s'
,
$this
->
getPHID
());
foreach
(
$authorizations
as
$authorization
)
{
$authorization
->
delete
();
}
$tokens
=
id
(
new
PhabricatorOAuthServerAccessToken
())
->
loadAllWhere
(
'clientPHID = %s'
,
$this
->
getPHID
());
foreach
(
$tokens
as
$token
)
{
$token
->
delete
();
}
$codes
=
id
(
new
PhabricatorOAuthServerAuthorizationCode
())
->
loadAllWhere
(
'clientPHID = %s'
,
$this
->
getPHID
());
foreach
(
$codes
as
$code
)
{
$code
->
delete
();
}
$this
->
saveTransaction
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 3, 8:44 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
59758
Default Alt Text
PhabricatorOAuthServerClient.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment