Skip to content

Avoid returning user information on password reset mutation#100

Merged
mcelicalderon merged 2 commits intomasterfrom
gqld-98-insecure-password-reset-mutation
Jun 12, 2020
Merged

Avoid returning user information on password reset mutation#100
mcelicalderon merged 2 commits intomasterfrom
gqld-98-insecure-password-reset-mutation

Conversation

@00dav00
Copy link
Copy Markdown
Contributor

@00dav00 00dav00 commented Jun 12, 2020

Resolves #98

  • Choose using Authenticable type on operation basis

Copy link
Copy Markdown
Member

@mcelicalderon mcelicalderon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just minor comments.


if resource.errors.empty?
{ authenticatable: resource }
{ message: I18n.t('devise.passwords.send_instructions') }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the message to our locales file, that was done for all other messages. That way we won't be affected if d ecise changes that message or removes it

logout: { klass: GraphqlDevise::Mutations::Logout, authenticable: true },
sign_up: { klass: GraphqlDevise::Mutations::SignUp, authenticable: true },
update_password: { klass: GraphqlDevise::Mutations::UpdatePassword, authenticable: true },
send_password_reset: { klass: GraphqlDevise::Mutations::SendPasswordReset, authenticable: true },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one needs to be authenticatable: false

sign_up: { klass: GraphqlDevise::Mutations::SignUp, authenticable: true },
update_password: { klass: GraphqlDevise::Mutations::UpdatePassword, authenticable: true },
send_password_reset: { klass: GraphqlDevise::Mutations::SendPasswordReset, authenticable: true },
resend_confirmation: { klass: GraphqlDevise::Mutations::ResendConfirmation, authenticable: true }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should have a message field too

update_password: GraphqlDevise::Mutations::UpdatePassword,
send_password_reset: GraphqlDevise::Mutations::SendPasswordReset,
resend_confirmation: GraphqlDevise::Mutations::ResendConfirmation
login: { klass: GraphqlDevise::Mutations::Login, authenticable: true },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's authenticatable

it 'sends password reset email' do
expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1)

expect(json_response.dig(:data, :userSendPasswordReset)).to include(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't use dig on ruby < 2.3, that is what's breaking the build


it 'honors devise configuration for case insensitive fields' do
expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1)
expect(json_response.dig(:data, :userSendPasswordReset)).to include(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Copy Markdown
Member

@mcelicalderon mcelicalderon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcelicalderon mcelicalderon merged commit 5d2d437 into master Jun 12, 2020
@mcelicalderon mcelicalderon deleted the gqld-98-insecure-password-reset-mutation branch June 12, 2020 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insecure send password reset mutation?

2 participants