Commit Graph

40 Commits

Author SHA1 Message Date
evazion
153a8339ab Inherit errors from StandardError instead of Exception. 2020-01-11 19:07:28 -06:00
evazion
309821bf73 rubocop: fix various style issues. 2019-12-22 21:23:37 -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
0cf9f845d0 newrelic: fix tracking of api auth failure errors.
Fixes user params not being recorded on SessionLoader::AuthenticationFailed errors.
2019-08-27 21:19:56 -05:00
evazion
371182b102 sessions: fix session started_at tracking. 2019-08-27 14:22:50 -05:00
evazion
a6ed7ca936 app controller: move session[:started_at] init to SessionLoader. 2019-08-24 22:55:36 -05:00
evazion
1a964f7a10 app controller: move safe mode from app controller to SessionLoader. 2019-08-24 22:55:36 -05:00
evazion
2d34e69737 api: disable csrf protection for api requests.
Fixes POST/PUT API requests failing with InvalidAuthenticityToken errors
due to missing CSRF tokens.

CSRF protection is only necessary for cookie-based authentication. For
non-cookie-based authentication we can safely disable it. That is, if
the user is already passing their login + api_key, then we don't need
to additionally verify the request with a CSRF token.

ref: 2e407fa476 (comments)
2019-08-24 22:55:35 -05:00
evazion
7c1552061b tests: fix authentication in controller tests.
Fix controller tests to login for real instead of faking it.
2019-08-24 22:55:35 -05:00
evazion
df433bda9c newrelic: log more request context. 2019-08-08 22:16:39 -05:00
evazion
ae52b487e8 related tags: eliminate favorite_tags cookie (#3955). 2018-10-12 21:18:15 -05:00
evazion
03abbd0683 Fix #2894: Use [[:space:]] instead of \s in regexes. 2018-09-20 19:24:38 -05:00
evazion
e546e52bd7 Replace AnonymousUser with User.new.
* Replace AnonymousUser null object with a readonly, unpersisted User object.

* Default always_resize_images to true (previously it was true for
  anonymous users, but false for new members).

* Default comment_threshold to -1 for anonymous users (previously it was
  0 for anonymous but -1 for new members).
2018-09-09 21:53:08 -05:00
Albert Yi
f2b525a6d2 Implement forum topic voting and tag change pruning (#3580) 2018-04-26 15:31:06 -07:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
evazion
ad74d9e75a Fix #3464: CurrentUser.ip_addr isn't set for anonymous users. 2017-12-27 13:34:20 -06:00
evazion
e34754c65c Possible fix for #3460: Timeout in update_last_ip_addr.
Set the user's statement timeout as soon as possible, before updating
anything in the database.
2017-12-27 12:42:11 -06:00
evazion
fd291c8b42 bans: fix exception when user with expired ban logs in.
`ban.destroy` fails because users have many `bans`, not a single `ban`.
Destroying the expired ban isn't necessary anyway.
2017-05-07 12:13:19 -05:00
r888888888
7c6243bca0 remove unused listbooru check in session loader 2017-03-20 13:52:54 -07:00
r888888888
f41c362bf4 keep better track of per-user ip addrs 2016-08-24 15:58:22 -07:00
r888888888
40957e04fd base listbooru refresh on user login 2016-02-17 17:02:35 -08:00
r888888888
64516b3a37 fixes #2389 2015-06-18 17:03:33 -07:00
r888888888
6772566665 fixes #2166 2014-07-23 15:15:47 -07:00
r888888888
bb402f5a27 fixes #2197 2014-07-17 16:34:54 -07:00
Toks
4a45d1e6bb Potential fix for #2124 2014-06-06 13:43:27 -04:00
r888888888
7e07b874a4 implementation for #1469
This reverts commit 18edc937fd.
2014-03-14 18:39:31 -07:00
Toks
99cb177398 potential fix for bugged frequent tags 2013-06-20 18:01:35 -04:00
r888888888
d4007e8093 potential fix for #1769, add missing jquery ui icons 2013-06-19 12:56:21 -07:00
r888888888
af25507480 fixes #813 2013-06-10 16:33:26 -07:00
r888888888
0535237704 fixes #1512 2013-05-07 18:19:30 -07:00
albert
15986b3afe fixes #1067 2013-03-25 22:51:18 -04:00
albert
4606ec4763 priv users now have 6sec timeout, platinum users have 9sec timeout 2013-03-21 07:46:49 -07:00
albert
7470d189c3 add api authentication 2013-03-20 15:43:17 -07:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
d912ba6172 fixes #764 2013-03-05 17:18:01 -05:00
albert
5ab9887923 only store partial hash in cookies for validation 2013-03-05 16:49:09 -05:00
albert
f52181db94 Major revamp of security. Passwords are first SHA1 hashed and then
that hash is bcrypted.  Bcrypted hashes are stored in a new column on
users.  This separate column is only to allow for rollbacks,
eventually the old SHA1 hash column will be removed.  Sensitive cookie
details are now encrypted to prevent user tampering and more stringent
checks on secret_token and session_secret_key are enforced.
2013-03-04 22:55:41 -05:00
albert
000be2de6d update users last_logged_in_at more frequently, disable tag subscription processing for users who have been inactive for more than one year 2012-06-07 17:31:55 -04:00
albert
a7267cf00b fixed tests 2011-10-16 01:40:42 -04:00
albert
d324f4a071 refactored login process, added remember option for login 2011-10-15 16:36:07 -04:00