Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/oauthserver/controller/client/PhabricatorOAuthClientSecretController.php
12242 views
1
<?php
2
3
final class PhabricatorOAuthClientSecretController
4
extends PhabricatorOAuthClientController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$viewer = $request->getUser();
8
9
$client = id(new PhabricatorOAuthServerClientQuery())
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 (!$client) {
19
return new Aphront404Response();
20
}
21
22
$view_uri = $client->getViewURI();
23
$token = id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
24
$viewer,
25
$request,
26
$view_uri);
27
28
if ($request->isFormPost()) {
29
$secret = $client->getSecret();
30
31
$body = id(new PHUIFormLayoutView())
32
->appendChild(
33
id(new AphrontFormTextAreaControl())
34
->setLabel(pht('Plaintext'))
35
->setReadOnly(true)
36
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
37
->setValue($secret));
38
39
return $this->newDialog()
40
->setWidth(AphrontDialogView::WIDTH_FORM)
41
->setTitle(pht('Application Secret'))
42
->appendChild($body)
43
->addCancelButton($view_uri, pht('Done'));
44
}
45
46
47
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
48
49
if ($is_serious) {
50
$body = pht(
51
'The secret associated with this OAuth application will be shown in '.
52
'plain text on your screen.');
53
} else {
54
$body = pht(
55
'The secret associated with this OAuth application will be shown in '.
56
'plain text on your screen. Before continuing, wrap your arms around '.
57
'your monitor to create a human shield, keeping it safe from prying '.
58
'eyes. Protect company secrets!');
59
}
60
61
return $this->newDialog()
62
->setTitle(pht('Really show application secret?'))
63
->appendChild($body)
64
->addSubmitButton(pht('Show Application Secret'))
65
->addCancelButton($view_uri);
66
}
67
68
}
69
70