Skip to content

Commit 68b4ab2

Browse files
committed
Wrap exception with OmniAuth::AuthenticityError
This allows the exception to be handled by the appropriate OmniAuth error handler. The original exception will still be available from the wrapping exceptions's `#cause`, for error reporting and diagnostics.
1 parent dcdf698 commit 68b4ab2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/omniauth/rails_csrf_protection/token_verifier.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ def call(env)
4141

4242
def _call(env)
4343
@request = ActionDispatch::Request.new(env.dup)
44-
4544
verify_authenticity_token
45+
rescue ActionController::ActionControllerError => ex
46+
logger.warn "Attack prevented by #{self.class}"
47+
# wrapped exception:
48+
# * rescued and handled by OmniAuth::Strategy#request_call
49+
# * contains #cause with original exception
50+
raise OmniAuth::AuthenticityError, "[#{ex.class}] #{ex}"
4651
end
4752

4853
private

0 commit comments

Comments
 (0)