Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61822621
PhabricatorRepositoryVCSPassword.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
Thu, May 9, 04:46
Size
1 KB
Mime Type
text/x-php
Expires
Sat, May 11, 04:46 (2 d)
Engine
blob
Format
Raw Data
Handle
17562768
Attached To
rPH Phabricator
PhabricatorRepositoryVCSPassword.php
View Options
<?php
final
class
PhabricatorRepositoryVCSPassword
extends
PhabricatorRepositoryDAO
{
protected
$id
;
protected
$userPHID
;
protected
$passwordHash
;
public
function
setPassword
(
PhutilOpaqueEnvelope
$password
,
PhabricatorUser
$user
)
{
$hash_envelope
=
$this
->
hashPassword
(
$password
,
$user
);
return
$this
->
setPasswordHash
(
$hash_envelope
->
openEnvelope
());
}
public
function
comparePassword
(
PhutilOpaqueEnvelope
$password
,
PhabricatorUser
$user
)
{
return
PhabricatorPasswordHasher
::
comparePassword
(
$this
->
getPasswordHashInput
(
$password
,
$user
),
new
PhutilOpaqueEnvelope
(
$this
->
getPasswordHash
()));
}
private
function
getPasswordHashInput
(
PhutilOpaqueEnvelope
$password
,
PhabricatorUser
$user
)
{
if
(
$user
->
getPHID
()
!=
$this
->
getUserPHID
())
{
throw
new
Exception
(
'User does not match password user PHID!'
);
}
$raw_input
=
PhabricatorHash
::
digestPassword
(
$password
,
$user
->
getPHID
());
return
new
PhutilOpaqueEnvelope
(
$raw_input
);
}
private
function
hashPassword
(
PhutilOpaqueEnvelope
$password
,
PhabricatorUser
$user
)
{
$input_envelope
=
$this
->
getPasswordHashInput
(
$password
,
$user
);
$best_hasher
=
PhabricatorPasswordHasher
::
getBestHasher
();
return
$best_hasher
->
getPasswordHashForStorage
(
$input_envelope
);
}
}
Event Timeline
Log In to Comment