Skip to content
  • Jon Leighton's avatar
    470c1898
    Improve logging when Origin header doesn't match · 470c1898
    Jon Leighton authored
    I came up against this while dealing with a misconfigured server. The
    browser was setting the Origin header to "https://example.com", but the
    Rails app returned "http://example.com" from request.base_url (because
    it was failing to detect that HTTPS was used).
    
    This caused verify_authenticity_token to fail, but the message in the
    log was "Can't verify CSRF token", which is confusing because the
    failure had nothing to do with the CSRF token sent in the request. This
    made it very hard to identify the issue, so hopefully this will make it
    more obvious for the next person.
    470c1898
    Improve logging when Origin header doesn't match
    Jon Leighton authored
    I came up against this while dealing with a misconfigured server. The
    browser was setting the Origin header to "https://example.com", but the
    Rails app returned "http://example.com" from request.base_url (because
    it was failing to detect that HTTPS was used).
    
    This caused verify_authenticity_token to fail, but the message in the
    log was "Can't verify CSRF token", which is confusing because the
    failure had nothing to do with the CSRF token sent in the request. This
    made it very hard to identify the issue, so hopefully this will make it
    more obvious for the next person.
Loading