Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92672703
PhabricatorAuthSSHRevoker.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
Fri, Nov 22, 15:37
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 24, 15:37 (2 d)
Engine
blob
Format
Raw Data
Handle
22483603
Attached To
rPH Phabricator
PhabricatorAuthSSHRevoker.php
View Options
<?php
final
class
PhabricatorAuthSSHRevoker
extends
PhabricatorAuthRevoker
{
const
REVOKERKEY
=
'ssh'
;
public
function
getRevokerName
()
{
return
pht
(
'SSH Keys'
);
}
public
function
getRevokerDescription
()
{
return
pht
(
"Revokes all SSH public keys.
\n\n
"
.
"SSH public keys are revoked, not just removed. Users will need to "
.
"generate and upload new, unique keys before they can access "
.
"repositories or other services over SSH."
);
}
public
function
revokeAllCredentials
()
{
$query
=
new
PhabricatorAuthSSHKeyQuery
();
return
$this
->
revokeWithQuery
(
$query
);
}
public
function
revokeCredentialsFrom
(
$object
)
{
$query
=
id
(
new
PhabricatorAuthSSHKeyQuery
())
->
withObjectPHIDs
(
array
(
$object
->
getPHID
()));
return
$this
->
revokeWithQuery
(
$query
);
}
private
function
revokeWithQuery
(
PhabricatorAuthSSHKeyQuery
$query
)
{
$viewer
=
$this
->
getViewer
();
// We're only going to revoke keys which have not already been revoked.
$ssh_keys
=
$query
->
setViewer
(
$viewer
)
->
withIsActive
(
true
)
->
execute
();
$content_source
=
PhabricatorContentSource
::
newForSource
(
PhabricatorDaemonContentSource
::
SOURCECONST
);
$auth_phid
=
id
(
new
PhabricatorAuthApplication
())->
getPHID
();
foreach
(
$ssh_keys
as
$ssh_key
)
{
$xactions
=
array
();
$xactions
[]
=
$ssh_key
->
getApplicationTransactionTemplate
()
->
setTransactionType
(
PhabricatorAuthSSHKeyTransaction
::
TYPE_DEACTIVATE
)
->
setNewValue
(
1
);
$editor
=
$ssh_key
->
getApplicationTransactionEditor
()
->
setActor
(
$viewer
)
->
setActingAsPHID
(
$auth_phid
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
)
->
setContentSource
(
$content_source
)
->
setIsAdministrativeEdit
(
true
)
->
applyTransactions
(
$ssh_key
,
$xactions
);
}
return
count
(
$ssh_keys
);
}
}
Event Timeline
Log In to Comment