Ruby on Rails private link sharing: Google Docs Style

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 05:35:11

I would have a separate controller that uses a hash value to reference the event.

Something simple like the created_at + user_id hashed to create a unique reference.

You could also simply skip the check on a certain action but I would much prefer the first solution .

I agree with David Lyod's answer (separating this concern in a different controller).

But for creating the hash I strongly recommend you salting the hash with some secret phrase.

require "digest"
Digest::SHA512.hexdigest("#{created_at}#{user_id}.mysupersonicsecretSALT")

Doing this it is not possible, without the knowlegde of the secret phrase, to calculate the hashes and test them against your system until it hits an existing one. If you're handling sensitive data you should not be lazy.

Cheers,

Lukas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!