Skip to content

Roda and Rails routing behavior is different for explicit formats (.html etc) #365

@angerson

Description

@angerson

This isn't a bug but it's something security-relevant that rodauth-rails could address.

Rails will route /foo.html and /foo.json to the same controller as /foo. However, Roda doesn't consider /foo.html or /foo.json to be part of the /foo routing tree. If rodauth_app.rb sets up authentication with r.on instead of r.path.start_with? then it's possible to bypass require_account.

# If you visit `/foo` then account handling works, 
# but visiting `/foo.html` goes through to the page 
# without checking for an account.
r.on "foo" do
  rodauth.require_account
end

Those who ignore rodauth-rails's authentication example (with r.path.start_with?) because r.on looks cleaner may end up exposing private sections of their application without knowing.

Maybe this routing difference could be bridged in the rodauth-rails integration? If not, the rodauth_app.rb template already recommends start_with?, but it may be good to add a more explicit warning about this unintuitive behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions