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
ae27e120
Commit
ae27e120
authored
11 years ago
by
Michael Hamann
Committed by
Christopher Smith
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use a new, truly random secret for cookie encryption
parent
9c6747f2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/auth.php
+9
-5
9 additions, 5 deletions
inc/auth.php
with
9 additions
and
5 deletions
inc/auth.php
+
9
−
5
View file @
ae27e120
...
...
@@ -219,7 +219,7 @@ function auth_login($user, $pass, $sticky = false, $silent = false) {
if
(
$auth
->
checkPass
(
$user
,
$pass
))
{
// make logininfo globally available
$_SERVER
[
'REMOTE_USER'
]
=
$user
;
$secret
=
auth_cookiesalt
(
!
$sticky
);
//bind non-sticky to session
$secret
=
auth_cookiesalt
(
!
$sticky
,
true
);
//bind non-sticky to session
auth_setCookie
(
$user
,
PMA_blowfish_encrypt
(
$pass
,
$secret
),
$sticky
);
return
true
;
}
else
{
...
...
@@ -250,7 +250,7 @@ function auth_login($user, $pass, $sticky = false, $silent = false) {
return
true
;
}
// no we don't trust it yet - recheck pass but silent
$secret
=
auth_cookiesalt
(
!
$sticky
);
//bind non-sticky to session
$secret
=
auth_cookiesalt
(
!
$sticky
,
true
);
//bind non-sticky to session
$pass
=
PMA_blowfish_decrypt
(
$pass
,
$secret
);
return
auth_login
(
$user
,
$pass
,
$sticky
,
true
);
}
...
...
@@ -333,14 +333,18 @@ function auth_browseruid() {
*
* @author Andreas Gohr <andi@splitbrain.org>
* @param bool $addsession if true, the sessionid is added to the salt
* @param bool $secure if security is more important than keeping the old value
* @return string
*/
function
auth_cookiesalt
(
$addsession
=
false
)
{
function
auth_cookiesalt
(
$addsession
=
false
,
$secure
=
false
)
{
global
$conf
;
$file
=
$conf
[
'metadir'
]
.
'/_htcookiesalt'
;
if
(
$secure
||
!
file_exists
(
$file
))
{
$file
=
$conf
[
'metadir'
]
.
'/_htcookiesalt2'
;
}
$salt
=
io_readFile
(
$file
);
if
(
empty
(
$salt
))
{
$salt
=
uniqid
(
rand
(),
true
);
$salt
=
bin2hex
(
auth_randombytes
(
64
)
);
io_saveFile
(
$file
,
$salt
);
}
if
(
$addsession
)
{
...
...
@@ -988,7 +992,7 @@ function updateprofile() {
// update cookie and session with the changed data
if
(
$changes
[
'pass'
])
{
list
(
/*user*/
,
$sticky
,
/*pass*/
)
=
auth_getCookie
();
$pass
=
PMA_blowfish_encrypt
(
$changes
[
'pass'
],
auth_cookiesalt
(
!
$sticky
));
$pass
=
PMA_blowfish_encrypt
(
$changes
[
'pass'
],
auth_cookiesalt
(
!
$sticky
,
true
));
auth_setCookie
(
$_SERVER
[
'REMOTE_USER'
],
$pass
,
(
bool
)
$sticky
);
}
return
true
;
...
...
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