Commit Graph

56 Commits

Author SHA1 Message Date
Earlopain
fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00
Earlopain
56e849695b
[Cleanup] Remove readonly only
Since its introduction 3 years ago, it got used once I believe
I can't even say if this properly works anymore.

If something like that is actually desired in the future, it should just be a whitelist instead
2024-02-23 16:48:56 +01:00
Earlopain
d16b7b0b40
[Prod] Limit the amount of data sent to NewRelic 2023-10-11 19:45:11 +02:00
Earlopain
728a8caa60
[Prod] Rework NewRelic logging
* Use config to log request params
* Stop logging the session. There's nothing useful there
* Stop logging a users level
2023-10-10 16:23:43 +02:00
Earlopain
7adac7b250
[Gems] Bump rubocop/regenerate todo
987 files inspected, 6509 offenses detected, 6224 offenses autocorrectable
2023-08-01 19:32:24 +02:00
Earlopain
384766b311
[Users] Delete session on invalid user_id
Not a problem for prod but can happen for dev because of database resets
Fixes #515
2023-05-08 18:09:09 +02:00
Earlopain
03e06fedea
[Misc] Also set CurrentUser when InvalidAuthenticityToken
This makes it possible to unconditionally render the default layout in cases
of errors. This makes it possible to access CurrentUser in the blank layout
2022-10-16 19:43:33 +02:00
Kira
fa6c9044cb [Auth] Prevent infinite sessions.
Prevents sessions from persisting beyond password changes.
2021-12-18 03:36:19 -08:00
Earlopain
061176e095
[Setup] Ignore limits when seeding
This makes the environment config understand booleans. If something
ends with "?" it tries to interpret it as a boolean. A bunch of
existing configs where changed to reflect this change.
2021-11-14 22:16:36 +01:00
Earlopain
bd93c61e77
[ReadOnly] Add basic read-only mode 2021-07-18 17:50:57 +02:00
Kira
e685fb87c2 [Tests] Update tests and fix deprecations 2021-02-25 12:08:09 -08:00
Kira
6fddcc7d58 [Cookies] Hopefully fix Firefox defaulting to SameSite=none 2020-07-02 17:23:16 -07:00
Kira
78b4c83ee8 [e9] Fix safe mode 2020-04-16 18:35:46 -07:00
Kira
3cb1e91adf Better remember support 2020-04-12 19:08:33 -07:00
Kira
94003be259 Make banned login message more clear for suspensions 2020-04-04 14:03:06 -07:00
Kira
090a470706 Prevent login when banned 2020-03-21 20:45:59 -07:00
Kira
3e43fc6fb8 Revise error reporting to users for expected cases 2020-03-04 19:40:46 -08:00
Kira
e71888a01a Add session remember support 2019-10-31 06:41:21 -07:00
Kira
5767b51412 Fix broken authentication 2019-08-31 16:16:28 -07:00
evazion
80bfdbd84a sessions: fix session started_at tracking. 2019-08-28 21:19:22 -07:00
evazion
7aad661619 app controller: move session[:started_at] init to SessionLoader. 2019-08-28 21:09:53 -07:00
evazion
ae5d039745 app controller: move safe mode from app controller to SessionLoader. 2019-08-28 21:09:37 -07:00
evazion
4dd6e86b0c 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-28 21:00:54 -07:00
evazion
3949c184f7 tests: fix authentication in controller tests.
Fix controller tests to login for real instead of faking it.
2019-08-28 20:52:21 -07:00
evazion
573be8791b newrelic: log more request context. 2019-08-10 05:21:13 -07:00
Kira
f4f030f726 Password migration/upgrade
NOTE: All existing passwords in development no longer work after
this change! Change your users password using the rails console.

Automatically convert and ugrade old passwords to using bcrypt
Removed the seemingly pointless transformation and hashing on top
of the actual password with a static salt.
Disabled logging in using password hashes, because that's just not
secure in any way, and negates cracking passwords at all.
Disabled sending the password hash to the client as a cookie, even
if it was signed.
Disabled legacy API logins.
2019-02-21 21:10:20 -08: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