Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
529b0416
Commit
529b0416
authored
12 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Patches
Plain Diff
added mediawiki password method FS#2559
This should make migrating from MediaWiki a bit easier.
parent
bcc1938e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
_test/tests/inc/auth_password.test.php
+5
-0
5 additions, 0 deletions
_test/tests/inc/auth_password.test.php
inc/PassHash.class.php
+26
-8
26 additions, 8 deletions
inc/PassHash.class.php
lib/plugins/config/settings/config.metadata.php
+1
-1
1 addition, 1 deletion
lib/plugins/config/settings/config.metadata.php
with
32 additions
and
9 deletions
_test/tests/inc/auth_password.test.php
+
5
−
0
View file @
529b0416
...
...
@@ -61,6 +61,11 @@ class auth_password_test extends PHPUnit_Framework_TestCase {
$this
->
assertTrue
(
auth_verifyPassword
(
'test12345'
,
'$H$9IQRaTwmfeRo7ud9Fh4E2PdI0S3r.L0'
));
}
function
test_veryPassword_mediawiki
(){
$this
->
assertTrue
(
auth_verifyPassword
(
'password'
,
':B:838c83e1:e4ab7024509eef084cdabd03d8b2972c'
));
}
/**
* pmd5 checking should throw an exception when a hash with a too high
* iteration count is passed
...
...
This diff is collapsed.
Click to expand it.
inc/PassHash.class.php
+
26
−
8
View file @
529b0416
...
...
@@ -4,7 +4,7 @@
*
* This class implements various mechanisms used to hash passwords
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author
Andreas Gohr <andi@splitbrain.org>
* @license LGPL2
*/
class
PassHash
{
...
...
@@ -58,6 +58,9 @@ class PassHash {
}
elseif
(
substr
(
$hash
,
0
,
6
)
==
'{SMD5}'
)
{
$method
=
'lsmd5'
;
$salt
=
substr
(
base64_decode
(
substr
(
$hash
,
6
)),
16
);
}
elseif
(
preg_match
(
'/^:B:(.+?):.{32}$/'
,
$hash
,
$m
))
{
$method
=
'mediawiki'
;
$salt
=
$m
[
1
];
}
elseif
(
$len
==
32
)
{
$method
=
'md5'
;
}
elseif
(
$len
==
40
)
{
...
...
@@ -104,7 +107,7 @@ class PassHash {
* applied.
*
* @param string &$salt The salt, pass null if you want one generated
* @param int $len The length of the salt
* @param int $len
The length of the salt
*/
public
function
init_salt
(
&
$salt
,
$len
=
32
)
{
if
(
is_null
(
$salt
))
$salt
=
$this
->
gen_salt
(
$len
);
...
...
@@ -263,7 +266,7 @@ class PassHash {
*
* This method was used by old MySQL systems
*
* @link http://www.php.net/mysql
* @link
http://www.php.net/mysql
* @author <soren at byu dot edu>
* @param string $clear The clear text to hash
* @return string Hashed password
...
...
@@ -327,9 +330,9 @@ class PassHash {
* an exception.
*
* @link http://www.openwall.com/phpass/
* @param string $clear The clear text to hash
* @param string $salt The salt to use, null for random
* @param string $magic The hash identifier (P or H)
* @param string $clear
The clear text to hash
* @param string $salt
The salt to use, null for random
* @param string $magic
The hash identifier (P or H)
* @param int $compute The iteration count for new passwords
* @throws Exception
* @return string Hashed password
...
...
@@ -430,8 +433,8 @@ class PassHash {
* will break. When no salt is given, the iteration count can be set
* through the $compute variable.
*
* @param string $clear The clear text to hash
* @param string $salt The salt to use, null for random
* @param string $clear
The clear text to hash
* @param string $salt
The salt to use, null for random
* @param int $compute The iteration count (between 4 and 31)
* @throws Exception
* @return string Hashed password
...
...
@@ -450,4 +453,19 @@ class PassHash {
return
crypt
(
$clear
,
$salt
);
}
/**
* Password hashing method 'mediawiki'
*
* Uses salted MD5, this is referred to as Method B in MediaWiki docs. Unsalted md5
* method 'A' is not supported.
*
* @link http://www.mediawiki.org/wiki/Manual_talk:User_table#user_password_column
* @param string $clear The clear text to hash
* @param string $salt The salt to use, null for random
* @return string Hashed password
*/
public
function
hash_mediawiki
(
$clear
,
$salt
=
null
)
{
$this
->
init_salt
(
$salt
,
8
);
return
':B:'
.
$salt
.
':'
.
md5
(
$salt
.
'-'
.
md5
(
$clear
));
}
}
This diff is collapsed.
Click to expand it.
lib/plugins/config/settings/config.metadata.php
+
1
−
1
View file @
529b0416
...
...
@@ -126,7 +126,7 @@ $meta['_authentication'] = array('fieldset');
$meta
[
'useacl'
]
=
array
(
'onoff'
);
$meta
[
'autopasswd'
]
=
array
(
'onoff'
);
$meta
[
'authtype'
]
=
array
(
'authtype'
);
$meta
[
'passcrypt'
]
=
array
(
'multichoice'
,
'_choices'
=>
array
(
'smd5'
,
'md5'
,
'apr1'
,
'sha1'
,
'ssha'
,
'lsmd5'
,
'crypt'
,
'mysql'
,
'my411'
,
'kmd5'
,
'pmd5'
,
'hmd5'
,
'bcrypt'
));
$meta
[
'passcrypt'
]
=
array
(
'multichoice'
,
'_choices'
=>
array
(
'smd5'
,
'md5'
,
'apr1'
,
'sha1'
,
'ssha'
,
'lsmd5'
,
'crypt'
,
'mysql'
,
'my411'
,
'kmd5'
,
'pmd5'
,
'hmd5'
,
'
mediawiki'
,
'
bcrypt'
));
$meta
[
'defaultgroup'
]
=
array
(
'string'
);
$meta
[
'superuser'
]
=
array
(
'string'
);
$meta
[
'manager'
]
=
array
(
'string'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment