Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/auth/controller/PhabricatorAuthSSHKeyRevokeController.php
12256 views
1
<?php
2
3
final class PhabricatorAuthSSHKeyRevokeController
4
extends PhabricatorAuthSSHKeyController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$viewer = $this->getViewer();
8
9
$key = id(new PhabricatorAuthSSHKeyQuery())
10
->setViewer($viewer)
11
->withIDs(array($request->getURIData('id')))
12
->requireCapabilities(
13
array(
14
PhabricatorPolicyCapability::CAN_VIEW,
15
PhabricatorPolicyCapability::CAN_EDIT,
16
))
17
->executeOne();
18
if (!$key) {
19
return new Aphront404Response();
20
}
21
22
$cancel_uri = $key->getURI();
23
24
$token = id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
25
$viewer,
26
$request,
27
$cancel_uri);
28
29
if ($request->isFormPost()) {
30
$xactions = array();
31
32
$xactions[] = id(new PhabricatorAuthSSHKeyTransaction())
33
->setTransactionType(PhabricatorAuthSSHKeyTransaction::TYPE_DEACTIVATE)
34
->setNewValue(true);
35
36
id(new PhabricatorAuthSSHKeyEditor())
37
->setActor($viewer)
38
->setContentSourceFromRequest($request)
39
->setContinueOnNoEffect(true)
40
->setContinueOnMissingFields(true)
41
->applyTransactions($key, $xactions);
42
43
return id(new AphrontRedirectResponse())->setURI($cancel_uri);
44
}
45
46
$name = phutil_tag('strong', array(), $key->getName());
47
48
return $this->newDialog()
49
->setTitle(pht('Revoke SSH Public Key'))
50
->appendParagraph(
51
pht(
52
'The key "%s" will be permanently revoked, and you will no '.
53
'longer be able to use the corresponding private key to '.
54
'authenticate.',
55
$name))
56
->addSubmitButton(pht('Revoke Public Key'))
57
->addCancelButton($cancel_uri);
58
}
59
60
}
61
62