Ruby SDK
Integrate Onboardbase into your Ruby projects using our Ruby SDK
Installation
gem install onboardbase
Setup
Generate .onboardbase.yaml
If you don't have an Onboardbase setup file .onboardbase.yaml, go to your project page on Onboardbase, click on the Env dropdown and click to copy the setup for the project to your clipboard.
Then, create a new file in the root of your project named .onboardbase.yaml and paste the content you copied earlier.
If you have Onboardbase CLI, run the below command and follow the instruction to generate a setup file:
cd path/to/project
onboardbase setup
Your final setup file should look like this:
setup:
project: "test-project"
environment: "development"
Create an API Key
To create a new API Key, go to your account settings page, and click on your organization's tab, you would find the API Key sections.
On the API Key section, click on Create API Key, Enter an identifying name and a secure passcode string - you can't view this anymore, make it a memorable string.
Once an API Key is generated, click on the options dropdown of the key and then click on copy to copy the newly generated key to your clipboard.
Final setup
In your project .onboardbase.yaml setup file, add two new fields api_key
and passcode
. Paste the copied API Key from above as the value for the api_key
field and enter your memorable encryption passcode.
api_key: "****ANCAME3CFKJG******"
passcode: "TEST_PASSCODE"
setup:
project: "test-project"
environment: "development"
Integrate Onboardbase JS SDK
After having API Key and passcode integrated into your setup file.
require "onboardbase"
Use the config method to initialize the gem after it has been loaded, then call the loadSecrets
method to fetch your Onboardbase secrets.
Onboardbase.config do |c|
c.loadSecrets
end
And access to individual secrets from the environment has ENV
.
p ENV["ONBOARDBASE_SECRET"]
Rails Applications
Modify the boot file at app-path/config/boot.rb
, and add the blow content at the end of the file:
require 'onboardbase'
Onboardbase.config do |c|
# For Rails Applications
# function would fail if not in a rails environment
c.loadAsCredentials
end
And anywhere in your project, read Onboardbase secrets with:
puts Rails.application.ONBOARDBASE_SECRET
Inbuilt SDK Feature
Secure fallback cache
The SDK supports caching your secrets to a secure location on the current computer. This cache is useful in case there is an issue in communicating with Onboardbase servers to serve secrets.
Updated 9 months ago