Project

cloaked

0.0
No release in over 3 years
Low commit activity in last 3 years
Cloaked helps obfuscate ActiveRecord ids by generating public keys.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.17
~> 10.0
~> 3.0

Runtime

 Project Readme

Cloaked

Build Status Code Climate

Cloaked provides a simple mechanism to help obfuscate ActiveRecord ids and/or other database attributes by generating public keys that can be used and made publicly visible.

Installation

Add this line to your application's Gemfile:

gem 'cloaked'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cloaked

Usage

Cloaked needs to be included in your model:

class Post < ApplicationRecord
  include Cloaked
end

After including it in the model, you can specify the list of public keys for which you want to generate public keys:

class Post < ApplicationRecord
  include Cloaked

  with_cloaked_keys :public_id
end

By default, cloak will generate a random URL-safe base64 of 8 bytes. You can specify a different method for generating the public keys:

class Post < ApplicationRecord
  include Cloaked

  with_cloaked_keys :public_id, method: :hex 
end

Will generate a random hexadecimal string with 16 characters.

class Post < ApplicationRecord
  include Cloaked

  with_cloaked_keys :public_id, method: :uuid 
end

Will generate a v4 random UUID (Universally Unique IDentifier).

You can specify a custom length:

class Post < ApplicationRecord
  include Cloaked

  with_cloaked_keys :public_id, size: 16
end

Only applies to :base64 and hex. Note that in the latter case, the length of the hexadecimal string will be twice the size amount.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lightthefuserun/cloaked. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Cloaked project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

TODO

  • Load Cloaked automatically with railtie.