Reaching Complete Anonymity in Rails

Each user has_valued characters, each Persona belongs to the user. Users can create and destroy new characters whenever they want. Users sign / create a new session with a traditional combination of email and passwords and can work depending on who chooses them (users are allowed to have up to 3 people - Dominoes on the website).

Each Persona works the same as the user will be on any other site (pic profile, creating messages, sending messages, etc.). I want it to be impossible to determine which user each Persona belongs to. My question is: how can this be achieved?

In addition, I do not want any connection between Personas. Therefore, I consider it necessary to ensure that the Persona identifier cannot be determined. If a user creates, say, three Personas in quick succession, they will probably have a Persona serial identifier, so you can make a reasonable assumption that Persas with Persona serial identifier were probably created by the same user.

The friendly_id identifier hides the identifier in the URL, but can they still be identified in some ways?

What other considerations exist? Thanks for any suggestions, I don’t know where to start this anonymity.

EDIT:

This is what I have:

User Model:

class User < ActiveRecord::Base

  has_one  :ghost,    dependent: :destroy
  has_many :personas, dependent: :destroy

  before_create :create_remember_token
  before_save do
    email.downcase!
    callsign.downcase!
  end
  after_save do
    self.create_ghost unless ghost
  end

  validates :name, presence: true,
                   length: { maximum: 50 }
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(?:\.[a-z\d\-]+)*\.[a-z]+\z/i
  validates :email, presence:   true,
                    format:     { with: VALID_EMAIL_REGEX },
                    uniqueness: { case_sensitive: false }
  VALID_CALLSIGN_REGEX = /\A[a-z\d\-.\_]+\z/i
  validates :callsign, presence:   true,
                       length:     { maximum: 20 },
                       format:     { with: VALID_CALLSIGN_REGEX },
                       uniqueness: { case_sensitive: false }
  validates :password, length: { minimum: 6 }

  has_secure_password

  def User.new_remember_token
    SecureRandom.urlsafe_base64
  end

  def User.digest(token)
    Digest::SHA1.hexdigest(token.to_s)
  end

  private

    def create_remember_token
      self.remember_token = User.digest(User.new_remember_token)
    end

end

User Controller:

class UsersController < ApplicationController

  before_action :signed_in_user,     only: [:index, :show, :edit, :update, :destroy]
  before_action :non_signed_in_user, only: [:new, :create]
  before_action :correct_user,       only: [:edit, :update]
  before_action :admin_user,         only: :destroy

  def index
    @users = User.paginate(page: params[:page])
  end

  def show
    @user = User.find(params[:id])
    @page_name = "user_page"
  end

  def new
    @user = User.new
  end

  def create
    @user = User.new(user_params)
    if @user.save
      sign_in @user
      flash[:success] = "Welcome, " + @user.name
      redirect_to @user
    else
      render 'new'
    end
  end # create

  def destroy
    @user = User.find(params[:id])
    if ( current_user != @user )
      @user.destroy
      flash[:success] = "User deleted."
      redirect_to users_url
    else
      redirect_to @user, notice: "Suicide is not permitted, admin chappie. Hard cheese."
    end
  end

  def edit
  end

  def update
    if @user.update_attributes(user_params)
      flash[:success] = "Profile updated"
      redirect_to @user
    else
      render 'edit'
    end
  end # update

  private

    def user_params
      params.require(:user).permit(:name, :email, :callsign, :password, :password_confirmation)
    end

    # Before filters

    def non_signed_in_user
      if signed_in?
        redirect_to root_url, notice: "Nice try pal. You can't create a new user 
                                       if you're already signed in."
      end
    end

    def correct_user
      @user = User.find(params[:id])
      redirect_to(root_url) unless current_user?(@user)
    end

    def admin_user
      redirect_to(root_url) unless current_user.admin?
    end

end

Person Model:

class Persona < ActiveRecord::Base

  belongs_to :user

  before_save :make_downcase_callsign

  validates :name, presence: true,
                   length:   { maximum: 50 }
  VALID_CALLSIGN_REGEX = /\A[a-z\d\-.\_]+\z/i
  validates :callsign, presence:   true,
                       length:     { maximum: 20 },
                       format:     { with: VALID_CALLSIGN_REGEX },
                       uniqueness: { case_sensitive: false }
  validates :user_id, presence: true
  validates :persona_id, presence: true

  private

    def make_downcase_callsign
      return unless callsign
      self.callsign = callsign.downcase
    end

end # Persona

Personas controller:

class PersonasController < ApplicationController

  before_action :signed_in_user
  before_action :correct_persona,   only: [:edit, :update]
  before_action :correct_destroyer, only: :destroy
  before_action :too_many_personas, only: :create

  def index
    @personas = Persona.paginate(page: params[:page])
  end

  def show
    @persona = Persona.find(params[:id])
    @page_name = "domino_" + @persona.persona_id.to_s + "_page"
  end

  def new
    @persona = Persona.new
  end

  def create
    @persona = current_user.personas.build(persona_params)
    set_persona_id
    if @persona.save
      flash[:success] = "This is the moment of your creation, " + @persona.name
      redirect_to @persona
    else
      render 'new'
      end
  end

  def edit
    @persona = Persona.find(params[:id])
  end

  def update
    @persona = Persona.find(params[:id])
    if @persona.update_attributes(persona_params)
      flash[:success] = "Persona profile updated"
      redirect_to @persona
    else
      render 'edit'
    end
  end

  def destroy
    @persona = Persona.find(params[:id])
    @persona.destroy
    flash[:success] = "Persona deleted."
    redirect_to current_user
  end


  private

    def persona_params
      params.require(:persona).permit(:name, :callsign)
    end

    def correct_persona
      @persona = Persona.find(params[:id])
      redirect_to(root_url) unless current_user.id == @persona.user_id
    end

    def correct_destroyer
      @persona = Persona.find(params[:id])
      redirect_to(root_url) unless ( (current_user.id == @persona.user_id) || current_user.admin? )
    end

    def too_many_personas
      if ( current_user.personas.count >= 3 )
        flash[:message] = "Sorry, you're not allowed more than three dominos."
        redirect_to(root_url)
      end
    end

    def set_persona_id
      if ( current_user.personas.count == 0 )
        @persona.persona_id = 1
        return
      end
      if ( current_user.personas.count == 1 )
        if current_user.personas.first.persona_id == 1
          @persona.persona_id = 2
          return
        else
          @persona.persona_id = 1
          return
        end
      end
      if ( current_user.personas.count == 2 )
        if current_user.personas.first.persona_id == 1
          if current_user.personas.second.persona_id == 2
            @persona.persona_id = 3
            return
          else
            @persona.persona_id = 2
            return
          end
        end
        if current_user.personas.first.persona_id == 2
          if current_user.personas.second.persona_id == 1
            @persona.persona_id = 3
            return
          else
            @persona.persona_id = 1
            return
          end
        end
        if current_user.personas.first.persona_id == 3
          if current_user.personas.second.persona_id == 1
            @persona.persona_id = 2
            return
          else
            @persona.persona_id = 1
            return
          end
        end
      end
    end

end # class PersonasController < ApplicationController

, , , . , , , (, ) .

+4
1

, , , .

, , , .

1) URL-.

  • . Persona , , URL-, .

2) .

  • . , - IP- ( , Devise , ), .
  • , , , , , , - .
  • - (, Google Analytics), .

3) , / Persona.

4)

  • , Kinja ( ), . , , 16- , , . , , - , " ?". . - .

5) SSL

  • , , SSL.

, , , "". , . INSANE , , , SARTING-NSA. !

+2

All Articles