Commit Graph

472 Commits

Author SHA1 Message Date
evazion
e9b33dbd48 api: remove legacy password_hash login method.
Remove the ability to authenticate to the API with the `login` and
`password_hash` url parameters. This is a legacy authentication method
from Danbooru 1. How to actually generate the password_hash for this
method hasn't been fully documented for many years now. It required
taking the SHA1 hash of your password combined with an undocumented salt
value (i.e., password_hash = sha1("choujin-steiner--#{password}")).

This authentication method was also slow because it required checking
the password on every API call. Checking passwords is deliberately slow
because passwords are hashed with BCrypt. BCrypt takes about ~200ms per
request, so using this method effectively limited you to ~5 requests per
second in a single thread.
2020-03-25 18:48:43 -05: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
cbd713dea8 users: move sockpuppet detection from model to controller. 2020-03-24 18:41:27 -05:00
evazion
b7bd6c8fdd users: require email verification for signups from proxies.
Require users who signup using proxies to verify their email addresses
before they can perform any edits. For verification purposes, the email
must be a nondisposable address from a whitelist of trusted email
providers.
2020-03-24 17:25:35 -05:00
evazion
5faa323729 users: clean up password update logic.
Pull the password reauthentication logic out of the user model and put
it in the password update controller where it belongs.

This fixes an issue where when a new user was created the user model had
an incorrect password error set on it by `encrypt_password_on_update`.
It was trying to verify the old password even though we don't have one
when creating a new user. This error caused the user create action to
redirect back to the signup page because `respond_with` thought that
creating the user failed.
2020-03-24 17:25:35 -05:00
evazion
4a5bec71f6 signup: don't send welcome emails to invalid addresses.
Fix attempting to send welcome emails when user didn't provide a valid
email address.
2020-03-24 00:26:47 -05:00
evazion
e79910431f emails: validate that email addresses are deliverable.
Reject email addresses that known to be undeliverable during signup.
Some users signup with invalid email addresses, which causes the welcome
email (which contains the email confirmation link) to bounce. Too many
bounces hurt our ability to send mail.

We check that an email address is undeliverable by checking if the
domain has a mail server and if the server returns an invalid address
error when attempting to send mail. This isn't foolproof since some
servers don't return an error if the address doesn't exist. If the
checks fail we know the address is bad, but if the checks pass that
doesn't guarantee the address is good. However, this is still good
enough to filter out bad addresses for popular providers like Gmail and
Microsoft that do return nonexistent address errors.

The address existence check requires being able to connect to mail
servers over port 25. This may fail if your network blocks port 25,
which many home ISPs and hosting providers do by default.
2020-03-23 23:45:18 -05:00
evazion
63f7311489 comments: allow new users to comment.
Remove the rule that users less than a week old can't leave comments.
2020-03-21 23:06:47 -05:00
evazion
2445e8b82f favorites: convert user.hide_favorites? to pundit. 2020-03-21 23:06:42 -05:00
evazion
41ab3c9f63 post versions: fix undo action. 2020-03-21 23:06:42 -05:00
evazion
ca27929249 tests: add more posts/show tests. 2020-03-21 23:06:42 -05:00
evazion
3656063a6b tests: fix unit tests.
* Move old post archive tests to post version tests.

* Fix pool tests that assumed that multiple edits by the same user
  weren't merged.

* Fix references to `is_active` and `notes` on artist model.
2020-03-21 21:07:35 -05:00
evazion
94ae10b1a6 tests: fix post and pool version tests helpers.
* Fix the pool version SQS service to always be mocked before every
  test. Before we had to manually set it up before every test dealing
  with pool versions.

* Fix it so that we reconnect to the post/pool version databases before
  every test. Before using $ARCHIVE_DATABASE_URL to set the database url
  failed because environment variables weren't loaded by dotenv yet when
  connections were first established.
2020-03-21 19:28:10 -05:00
evazion
7f742242e4 pundit: convert uploads to pundit. 2020-03-20 18:03:01 -05:00
evazion
d51b0dfe17 pundit: convert moderator/post/posts to pundit. 2020-03-20 18:03:01 -05:00
evazion
a5418abb31 pundit: convert posts to pundit. 2020-03-20 18:03:01 -05:00
evazion
dd39913e55 pundit: convert post replacements to pundit. 2020-03-20 18:03:01 -05:00
evazion
3bb3c0b990 pundit: convert saved searches to pundit. 2020-03-20 18:03:01 -05:00
evazion
415d9591c5 pundit: convert post votes to pundit.
Side effects:

* The data-current-user-is-voter <body> attribute has been removed.
* {{upvote:self}} no longer works. {{upvote:<name>}} should be used instead.
2020-03-20 18:03:01 -05:00
evazion
33d81d0d1b pundit: convert post flags to pundit. 2020-03-20 18:03:01 -05:00
evazion
ffae64f127 pundit: convert post versions to pundit. 2020-03-20 18:03:01 -05:00
evazion
ba0a5dda8a pundit: convert post disapprovals to pundit. 2020-03-20 18:03:01 -05:00
evazion
84c654464d pundit: convert post approvals to pundit. 2020-03-20 18:03:01 -05:00
evazion
ab5432d149 pundit: convert pools to pundit. 2020-03-20 18:03:01 -05:00
evazion
62835ac9fc pundit: convert notes to pundit. 2020-03-20 18:03:01 -05:00
evazion
2c4c29b81a pundit: convert favorite groups to pundit. 2020-03-20 18:03:01 -05:00
evazion
50fa674a3e pundit: convert emails to pundit. 2020-03-20 18:03:01 -05:00
evazion
f1f489c40b pundit: convert favorites to pundit. 2020-03-20 18:03:01 -05:00
evazion
cc2b4abd09 pundit: convert forum post votes to pundit. 2020-03-20 18:03:01 -05:00
evazion
be59e85d25 pundit: convert ip addresses to pundit. 2020-03-20 18:03:01 -05:00
evazion
92aeb8728f pundit: convert ip bans to pundit. 2020-03-20 18:03:01 -05:00
evazion
9242bf522b pundit: convert moderation reports to pundit. 2020-03-20 18:03:01 -05:00
evazion
480f39c34a pundit: convert dmails to pundit. 2020-03-20 18:03:01 -05:00
evazion
3d72e62c77 pundit: convert bans to pundit. 2020-03-20 18:03:00 -05:00
evazion
ff1d71af2e pundit: convert artists to pundit. 2020-03-20 18:03:00 -05:00
evazion
79a365abe0 pundit: convert bulk update requests to pundit. 2020-03-20 18:03:00 -05:00
evazion
4a36b99614 pundit: convert tag aliases / implications to pundit. 2020-03-20 18:03:00 -05:00
evazion
4bb036aff1 pundit: convert tags to pundit. 2020-03-20 18:03:00 -05:00
evazion
4cd0b2cbfe pundit: convert user feedbacks to pundit.
Allow users to delete feedbacks they've given to other users, not just
mods.
2020-03-20 18:03:00 -05:00
evazion
565a6572a7 pundit: convert user name change requests to pundit.
Fix discrepancy between index action and show action. The index
action allowed members to see name changes for undeleted users, but the
show action didn't.
2020-03-20 18:03:00 -05:00
evazion
db63b6d44f pundit: convert forum topics / forum posts to pundit.
Fix it being possible for users to delete or undelete their own forum
posts and topics, even if they were deleted by a mod.
2020-03-20 18:03:00 -05:00
evazion
b3ff08fedf pundit: convert wiki pages to pundit. 2020-03-20 18:03:00 -05:00
evazion
5c6d26ea24 pundit: convert users to pundit. 2020-03-20 18:03:00 -05:00
evazion
a0c4617057 pundit: convert comments to pundit. 2020-03-20 18:03:00 -05:00
evazion
4d49bf053f tests: fix only param test. 2020-03-20 17:53:59 -05:00
evazion
8aac108e6b tests: fix password reset tests. 2020-03-20 17:53:59 -05:00
evazion
2d260f509d tests: remove upload tags test. 2020-03-20 16:33:00 -05:00
evazion
9a3b855cf6 bulk update requests: fix reference to title attribute.
Also remove non-nullable and default options from migration. The column
didn't originally have these options so they shouldn't be added if the
migration is reverted.
2020-03-20 16:08:20 -05:00
evazion
d211264239 emails: add show endpoint. 2020-03-18 03:46:01 -05:00