Skip to content

Do not return HTTP 500 when cross-site request forgery token is invalid for in-person proofing API#7950

Merged
mitchellhenke merged 1 commit intomainfrom
mitchellhenke/do-not-500-on-csrf-failure-for-usps-locations
Mar 9, 2023
Merged

Do not return HTTP 500 when cross-site request forgery token is invalid for in-person proofing API#7950
mitchellhenke merged 1 commit intomainfrom
mitchellhenke/do-not-500-on-csrf-failure-for-usps-locations

Conversation

@mitchellhenke
Copy link
Contributor

🛠 Summary of changes

We've seen a handful of these recently, and I think it's an error we want to avoid returning a 500 status on.

…id for in-person proofing API

changelog: Internal, In-Person Proofing, Do not return HTTP 500 when cross-site request forgery token is invalid
@mitchellhenke mitchellhenke requested review from a team and sheldon-b March 8, 2023 20:42
Faraday::TimeoutError => :unprocessable_entity,
Faraday::BadRequestError => :unprocessable_entity,
Faraday::ForbiddenError => :unprocessable_entity,
ActionController::InvalidAuthenticityToken => :unprocessable_entity,
Copy link
Contributor

Choose a reason for hiding this comment

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

could we add a controller-level

protect_from_forgery with: :reset_session

so that it never throws an error in the first place?

https://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#method-i-protect_from_forgery

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure on the best strategy since this is an API and mostly copied what's already here, I'm primarily wanting to not return a 500. I'd defer to the folks on Joy.

Copy link
Contributor

@allthesignals allthesignals left a comment

Choose a reason for hiding this comment

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

This looks good… unprocessable_entity is 4xx level, right?

@zachmargolis
Copy link
Contributor

This looks good… unprocessable_entity is 4xx level, right?

yup! it's a 422

@mitchellhenke mitchellhenke merged commit bde43bc into main Mar 9, 2023
@mitchellhenke mitchellhenke deleted the mitchellhenke/do-not-500-on-csrf-failure-for-usps-locations branch March 9, 2023 16:19
jmdembe pushed a commit that referenced this pull request Mar 9, 2023
…id for in-person proofing API (#7950)

changelog: Internal, In-Person Proofing, Do not return HTTP 500 when cross-site request forgery token is invalid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants