annotate .travis.yml @ 5457:f629e9a0c376

auth: secure password reset implementation This is a better implementation of password reset function, which doesn't involve sending a new password to the user's email address in clear text, and at the same time is stateless. The old implementation generated a new password and sent it in clear text to whatever email assigned to the user currently, so that any user, possibly unauthenticated, could request a reset for any username or email. Apart from potential insecurity, this made it possible for anyone to disrupt users' workflow by repeatedly resetting their passwords. The idea behind this implementation is to generate an authentication token which is dependent on the user state at the time before the password change takes place, so the token is one-time and can't be reused, and also to bind the token to the browser session. The token is calculated as SHA1 hash of the following: * user's identifier (number, not a name) * timestamp * hashed user's password * session identifier * per-application secret We use numeric user's identifier, as it's fixed and doesn't change, so renaming users doesn't affect the mechanism. Timestamp is added to make it possible to limit the token's validness (currently hard coded to 24h), and we don't want users to be able to fake that field easily. Hashed user's password is needed to prevent using the token again once the password has been changed. Session identifier is an additional security measure to ensure someone else stealing the token can't use it. Finally, per-application secret is just another way to make it harder for an attacker to guess all values in an attempt to generate a valid token. When the token is generated, an anonymous user is directed to a confirmation page where the timestamp and the usernames are already preloaded, so the user needs to specify the token. User can either click the link in the email if it's really them reading it, or to type the token manually. Using the right token in the same session as it was requested directs the user to a password change form, where the user is supposed to specify a new password (twice, of course). Upon completing the form (which is POSTed) the password change happens and a notification mail is sent. The test is updated to test the basic functionality with a bad and a good token, but it doesn't (yet) cover all code paths. The original work from Andrew has been thorougly reviewed and heavily modified by Søren Løvborg.
author Andrew Shadura <andrew@shadura.me>
date Sun, 17 May 2015 02:07:18 +0200
parents a9a1560dad79
children e285bb7abb28
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2561
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 language: python
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 python:
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 - "2.6"
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 - "2.7"
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 env:
4206
703d3208424c Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4180
diff changeset
7 - TEST_DB=sqlite:////tmp/kallithea_test.sqlite
703d3208424c Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4180
diff changeset
8 - TEST_DB=mysql://root@127.0.0.1/kallithea_test
703d3208424c Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4180
diff changeset
9 - TEST_DB=postgresql://postgres@127.0.0.1/kallithea_test
2561
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10
2834
925c77b9d3f1 travis configu updates
Marcin Kuzminski <marcin@python-works.com>
parents: 2743
diff changeset
11 services:
925c77b9d3f1 travis configu updates
Marcin Kuzminski <marcin@python-works.com>
parents: 2743
diff changeset
12 - mysql
925c77b9d3f1 travis configu updates
Marcin Kuzminski <marcin@python-works.com>
parents: 2743
diff changeset
13 - postgresql
925c77b9d3f1 travis configu updates
Marcin Kuzminski <marcin@python-works.com>
parents: 2743
diff changeset
14
2561
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 # command to install dependencies
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 before_script:
4206
703d3208424c Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4180
diff changeset
17 - mysql -e 'create database kallithea_test;'
703d3208424c Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4180
diff changeset
18 - psql -c 'create database kallithea_test;' -U postgres
2742
63d3d20cad95 Take that travis !
Marcin Kuzminski <marcin@python-works.com>
parents: 2638
diff changeset
19 - git --version
63d3d20cad95 Take that travis !
Marcin Kuzminski <marcin@python-works.com>
parents: 2638
diff changeset
20
63d3d20cad95 Take that travis !
Marcin Kuzminski <marcin@python-works.com>
parents: 2638
diff changeset
21 before_install:
2743
64ee7cf4a76d remove GIT before installing this ppa to fix upgrade issues
Marcin Kuzminski <marcin@python-works.com>
parents: 2742
diff changeset
22 - sudo apt-get remove git
2742
63d3d20cad95 Take that travis !
Marcin Kuzminski <marcin@python-works.com>
parents: 2638
diff changeset
23 - sudo add-apt-repository ppa:pdoes/ppa -y
63d3d20cad95 Take that travis !
Marcin Kuzminski <marcin@python-works.com>
parents: 2638
diff changeset
24 - sudo apt-get update -y
63d3d20cad95 Take that travis !
Marcin Kuzminski <marcin@python-works.com>
parents: 2638
diff changeset
25 - sudo apt-get install git -y
2561
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 install:
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 - pip install mysql-python psycopg2 mock unittest2
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 - pip install . --use-mirrors
2742
63d3d20cad95 Take that travis !
Marcin Kuzminski <marcin@python-works.com>
parents: 2638
diff changeset
30
2561
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 # command to run tests
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 script: nosetests
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 notifications:
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 email:
4213
13c0ab8eb343 Update address for Travis
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4206
diff changeset
36 - ci@kallithea-scm.org
4180
08af8038e1cc Change IRC channel and Twitter account; remove google group
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3975
diff changeset
37 irc: "irc.freenode.org#kallithea"
2561
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 branches:
6ccf86ebfd4e tox+travis with multiple dbs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 only:
3975
69377d1d7604 Use master branch on master bookmark to test with travis
Marcin Kuzminski <marcin@python-works.com>
parents: 2834
diff changeset
41 - master