Ruby on rails 基于Desive current_user helper编辑用户是否安全?

Ruby on rails 基于Desive current_user helper编辑用户是否安全?,ruby-on-rails,devise,Ruby On Rails,Devise,我正在使用Desive、Omniauth twitter和Omniauth facebook进行rails应用程序身份验证,我必须制作自己的控制器来编辑用户参数,而不需要facebook和twitter等提供商的用户密码。 我使用designe helper current_user来显示和编辑当前_用户参数,而不是通过用户id将用户路由到他的配置文件 我的问题是。。这样做安全吗? 我是初学者。。因此,当事情做得如此简单时,我担心安全漏洞。这是我的密码 profile_controller.rb

我正在使用Desive、Omniauth twitter和Omniauth facebook进行rails应用程序身份验证,我必须制作自己的控制器来编辑用户参数,而不需要facebook和twitter等提供商的用户密码。 我使用designe helper current_user来显示和编辑当前_用户参数,而不是通过用户id将用户路由到他的配置文件 我的问题是。。这样做安全吗? 我是初学者。。因此,当事情做得如此简单时,我担心安全漏洞。这是我的密码

profile_controller.rb

class ProfileController < ApplicationController
   before_action :authenticate_user!
   def show
       @user = current_user
   end

   def edit
       @profile = current_user
   end
   def update 
       @profile = current_user
       if @profile.update(profile_params)
           redirect_to profile_path(@profile)
       else
           render 'edit'
       end
   end
   private
   def profile_params
      params.require(:user).permit(:username,:first_name,:last_name,:gender)
   end
end
edit.html.erb

<%= form_for @profile, url: {action: "edit"} do |f| %>

    <%= f.text_field :username, autofocus: true %>

    <%= f.text_field :first_name, autofocus: true %>

    <%= f.text_field :last_name, autofocus: true %>

    <%= f.text_field :gender, autofocus: true %>

    <%= f.submit "Sign up" %>

<% end %>

如果您正在使用Desive,您可以使用他们现有的视图,而不是试图自己实现它们。但是,我认为你目前的方法没有任何安全威胁,只是这是浪费时间

查看设计文档并检查配置视图部分

<%= form_for @profile, url: {action: "edit"} do |f| %>

    <%= f.text_field :username, autofocus: true %>

    <%= f.text_field :first_name, autofocus: true %>

    <%= f.text_field :last_name, autofocus: true %>

    <%= f.text_field :gender, autofocus: true %>

    <%= f.submit "Sign up" %>

<% end %>