Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97989367
HeraldWebhookKeyController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jan 8, 08:22
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Jan 10, 08:22 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23448400
Attached To
rPH Phabricator
HeraldWebhookKeyController.php
View Options
<?php
final
class
HeraldWebhookKeyController
extends
HeraldWebhookController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$this
->
getViewer
();
$hook
=
id
(
new
HeraldWebhookQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$request
->
getURIData
(
'id'
)))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$hook
)
{
return
new
Aphront404Response
();
}
$action
=
$request
->
getURIData
(
'action'
);
if
(
$action
===
'cycle'
)
{
if
(!
$request
->
isFormPost
())
{
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'Regenerate HMAC Key'
))
->
appendParagraph
(
pht
(
'Regenerate the HMAC key used to sign requests made by this '
.
'webhook?'
))
->
appendParagraph
(
pht
(
'Requests which are currently authenticated with the old key '
.
'may fail.'
))
->
addCancelButton
(
$hook
->
getURI
())
->
addSubmitButton
(
pht
(
'Regnerate Key'
));
}
else
{
$hook
->
regenerateHMACKey
()->
save
();
}
}
$form
=
id
(
new
AphrontFormView
())
->
setViewer
(
$viewer
)
->
appendControl
(
id
(
new
AphrontFormTextControl
())
->
setLabel
(
pht
(
'HMAC Key'
))
->
setValue
(
$hook
->
getHMACKey
()));
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'Webhook HMAC Key'
))
->
appendForm
(
$form
)
->
addCancelButton
(
$hook
->
getURI
(),
pht
(
'Done'
));
}
}
Event Timeline
Log In to Comment