summaryrefslogtreecommitdiff
path: root/lib/VNDB/Util/Auth.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2014-08-29 09:43:00 +0200
committerYorhel <git@yorhel.nl>2014-08-29 09:45:15 +0200
commitc27d4e6b509a655d81e36469bb881afc287596e8 (patch)
treec7a42b5226edaab2e3356592130a6db7caa13a9e /lib/VNDB/Util/Auth.pm
parent9475bf8ccf1b422402ab70b6cb2276dc3c61e5c6 (diff)
Strengthen formcode for non-logged-in visitors + CSRF protect login form
formcode is strengthened by including the IP (-prefix) into the hash, ensuring that the code can't be obtained by someone on a different network. I also removed the login form of every page. Felt kinda pointless.
Diffstat (limited to 'lib/VNDB/Util/Auth.pm')
-rw-r--r--lib/VNDB/Util/Auth.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/VNDB/Util/Auth.pm b/lib/VNDB/Util/Auth.pm
index c7e8b973..a1fa9b4d 100644
--- a/lib/VNDB/Util/Auth.pm
+++ b/lib/VNDB/Util/Auth.pm
@@ -165,7 +165,7 @@ sub authGetCode {
my $self = shift;
my $id = shift;
my $time = (shift || time)/3600; # accuracy of an hour
- my $uid = pack('N', $self->{_auth} ? $self->{_auth}{id} : 0);
+ my $uid = encode_utf8($self->{_auth} ? $self->{_auth}{id} : $self->normIP());
return lc substr sha1_hex($self->{form_salt} . $uid . encode_utf8($id||'') . pack('N', int $time)), 0, 16;
}