New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reset_session breaks indifferent access
#7478
Comments
|
I'm not sure if this is intended behavior or not, but I'm pretty sure it's insane either way. ;) |
|
I'm pretty sure that |
|
Yeah, I mean, don't get me wrong, I'm |
|
I mean, in 7 years of Rails development I have never used |
|
Agreed. @pixeltrix also pointed out a case where it can be legitimately useful: https://twitter.com/pixeltrix/statuses/240879855930048512 |
|
See section 2.8 in the Ruby on Rails Security Guide: http://guides.rubyonrails.org/security.html. You probably should be using |
|
Confirmed in 3.2.8. def index
session[:foo] = "bar"
str = "Before: class = #{session.class}; foo = #{session["foo"]}<br>"
reset_session
# Re-adding :foo = bar to session
session[:foo] = "bar"
str += "After: class = #{session.class}; foo = #{session["foo"]}" # Attempting to print it using "foo" instead of :foo
render text: str
endproduces: |
|
Of course, upon reloading the page, the session hash is once again a |
|
Yes, but the problem is persistent after reloading the page. If I save I will give you an example. This is what we did, and it breaks stuff on our testing machine. It took us some time to figure out what was going wrong. At least we noticed, before these changed went into production. class UserController < FrontendController
def login
if @user = User.authenticate(params[:email], params[:password])
reset_session # Security!
session[:user_id] = @user.id
redirect_to mordor_path, :notice => "Welcome to mordor"
else
flash[:notice] = "One does not simply walk into mordor"
render :login
end
end
end
class User < Sequel::Model
# All sessions of this user - Yes, I know, it does not scale.
#
# BUG: When reset_session is used, will always return zero sessions.
def sessions
Rails::SessionStore.session_class.all.select do |session|
session.data["user_id"] == self.id
end
end
def force_logout!
sessions.each do |session|
Notification.new(:logout).send_to(session.id) # Notify the mobile devices.
session.destroy
end
end
end |
Hi.
I am running rails 3.2.7. When I run
reset_session, it kills indifferent access.The text was updated successfully, but these errors were encountered: