This gem is intended to generate and verify Prefix Api Key for ruby.
https://github.com/seamapi/prefixed-api-key?tab=readme-ov-file https://hexdocs.pm/prefixed_api_key/readme.html
Add your Gemfile:
gem 'prefix_api_key'Execute in bash:
bundle installor install directly in bash:
gem install prefix_api_keyConfigure 4 environment variables in your project
SALT_SHORT
SALT_LONG
PASSWORD_SHORT
PASSWORD_LONGConfigure initialize for the gem to use the 4 environment variables
PrefixApiKey.configure do |config|
config.salt_short = ENV['SALT_SHORT']
config.salt_long = ENV['SALT_LONG']
config.password_short = ENV['PASSWORD_SHORT']
config.password_long = ENV['PASSWORD_LONG']
endGenerating an Prefix Api Key
require 'prefix_api_key'
result = PrefixApiKey::Generate.call(prefix: 'my-company')
{
:short_token=>"bXktY29",
:long_token=>"MTIzNGFzZGYxMjM0NTZteS1jb21wYW55",
:long_token_hash=>"100debb3a4d86c39df892b4ebd00f86b64e16870c224f07e8393b9993b02944e",
:token=>"my-company_bXktY29_MTIzNGFzZGYxMjM0NTZteS1jb21wYW55",
:prefix=>"my-company"
}Validating a token
require 'prefix_api_key'
result = PrefixApiKey::Generate.call(prefix: 'my-company')
token = result[:token]
hash = result[:long_token_hash]
PrefixApiKey::Check.call(token: token, hash: hash)
# => trueDownload the project, run bundle install to install dependencies.
Now just make the changes you want.
Bug reports and pull requests are welcome on GitHub at https://github.com/frankyston/prefix_api_key. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the PrefixApiKey project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.