Commit Graph

24 Commits

Author SHA1 Message Date
evazion
65adcd09c2 users: track logins, signups, and other user events.
Add tracking of certain important user actions. These events include:

* Logins
* Logouts
* Failed login attempts
* Account creations
* Account deletions
* Password reset requests
* Password changes
* Email address changes

This is similar to the mod actions log, except for account activity
related to a single user.

The information tracked includes the user, the event type (login,
logout, etc), the timestamp, the user's IP address, IP geolocation
information, the user's browser user agent, and the user's session ID
from their session cookie. This information is visible to mods only.

This is done with three models. The UserEvent model tracks the event
type (login, logout, password change, etc) and the user. The UserEvent
is tied to a UserSession, which contains the user's IP address and
browser metadata. Finally, the IpGeolocation model contains the
geolocation information for IPs, including the city, country, ISP, and
whether the IP is a proxy.

This tracking will be used for a few purposes:

* Letting users view their account history, to detect things like logins
  from unrecognized IPs, failed logins attempts, password changes, etc.
* Rate limiting failed login attempts.
* Detecting sockpuppet accounts using their login history.
* Detecting unauthorized account sharing.
2021-01-08 22:34:37 -06:00
evazion
b2cf765d6d users: refactor login and authentication logic.
* Make authentication methods into User instance methods instead of
  class methods.
* Fix API key authentication to use a secure string comparison. Fixes a
  hypothetical (unlikely to be exploitable) timing attack.
* Move login logic from SessionCreator to SessionLoader.
2020-03-25 18:48:43 -05:00
evazion
9e455695a1 sessions: remove legacy user_name / password_hash cookies.
Remove support for logging in with the deprecated user_name /
password_hash cookies. Followup to 320ff01e0.
2020-03-25 18:48:43 -05:00
evazion
309821bf73 rubocop: fix various style issues. 2019-12-22 21:23:37 -06:00
evazion
7f08300f56 login: refactor login form to use simple form.
Also change form to pass params as e.g. `session[name]` instead of just
`name`.
2019-12-14 15:05:54 -06:00
evazion
320ff01e07 login: remove 'remember' checkbox; make session cookies permanent.
Remove the "Remember" checkbox from the login page. Make session cookies
permanent instead. Phase out legacy `user_name` and `password_hash` cookies.

Previously a user's session cookies would be cleared whenever they
closed their browser window, which would log them out of the site. To
work around this, when the "Remember" box was checked on the login page
(which it was by default), the user's name and password hash (!) would
be stored in separate permanent cookies, which would be used to
automatically log the user back in when their session cookies were
cleared. We can avoid all of this just by making the session cookies
themselves permanent.
2019-11-17 17:50:23 -06:00
evazion
cc4e39b88b sessions: raise exception on failed login attempts.
* Allow both xml and json authentication in sessions controller.

* Raise an exception if a login attempt fails so that a) we return a
  proper error for json/xml requests and b) failed login attempts get
  reported to NewRelic (for monitoring abuse).
2019-10-07 22:35:37 -05:00
r888888888
62a1aeabce expose user's api key as api_token field on sessions 2019-10-07 13:54:52 -07:00
evazion
8d706f4fd7 session controller: remove dead session[:previous_uri] cookie.
session[:previous_uri] is never set so it's always nil.
2019-08-08 14:00:46 -05:00
evazion
3b7ab86750 Fix "You are now logged in.." flash message.
The flash message when logging in contained an extra period.
2019-08-05 11:02:40 -05:00
r888888888
f138eeef1d fixes #2619: Delete password_hash cookie on sign out 2016-07-11 16:38:00 -07:00
r888888888
5b3a4b768c fixes #2557 2015-12-17 14:29:17 -08:00
r888888888
80c1c13ce3 fixes #1851 2013-07-26 17:37:44 -07:00
Toks
51a7e36509 fix tests 2013-06-30 11:37:15 -04:00
Kevin Xiwei Zheng
0f768d144a Restrict post-login redirection targets to local URLs 2013-06-26 12:15:08 -04:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
e7da9b2a37 sign out no longer requires http delete, can open up in new window 2013-02-23 11:01:33 -05:00
albert
f07bf9b2cc deleted posts are now hidden 2011-10-22 13:25:22 -04:00
albert
d324f4a071 refactored login process, added remember option for login 2011-10-15 16:36:07 -04:00
albert
124403a921 implemented last-forum-read-at 2011-08-23 17:11:21 -04:00
albert
f8b1bd3142 work on comments 2010-10-20 19:24:53 -04:00
albert
9f29ffc8c3 work on post views 2010-03-12 12:32:31 -05:00
albert
15c134b270 work on controllers/views started 2010-03-11 19:42:04 -05:00
albert
ac98d7db37 stubbed in blank controllers/helpers/functional tests 2010-03-10 18:21:43 -05:00