Project

bjond-api

0.0
No commit activity in last 3 years
No release in over 3 years
Rails engine that provides communication between Bjönd Server Core and a client app.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.0.1, ~> 2.0

Runtime

>= 3.0.3, ~> 3.0
~> 0.9.2
>= 4.2.4
 Project Readme

Bjönd API¶ ↑

A rubygem wrapper for the Bjönd API.

This gem also contains an engine with endpoints that are made to interface with Bjond server-core.

Installation¶ ↑

gem install 'bjond-api'

For specific version info visit the gem page.

Creating a Bjond Integration App¶ ↑

To create a Bjond App using the Ruby on Rails framework, perform the following actions within your Rails application.

(1) Add the following line to your Gemfile -

gem 'bjond-api'

(2) Install it with -

bundle install

(3) Migrate your Database

To install necessary migrations, add this to your Rails’ application.rb file -

rake bjond_api_engine:install:migrations

(4) At this point, you can run the migrations as usual using -

rake db:migrate

(5) Generate Configuration Files

To get you started, generate a config file by running the following command:

rails g initializer

This will automatically do two things:

  • (5a) Copy a baseline bower.json file in to the root of your app. If you already have a bower.json file, you can skip this file when prompted. Instead, you can copy the dependencies over manually. At the time of this writing, the most import client side library is angular.js. Once the bower.json file is in your environment, run -

    bower install
    

In application.js, include scripts using -

//= require bjond-api

Also, remove references to turbolinks.

From your angular app, include our module as a dependency -

angular.module('your-app',['bjond-api']);

From application.css, require the core css:

*= require 'bjond_registrations'
  • (5b) The generator will also create a root config create a config file that will initialize important variables for the Bjond-App gem. This will be copied into your app at: config/initializers/bjond-api-initializer.rb

(6) The angular / css can be loaded by using the following code in the application.html.erb:

<div class="bjond-application" ng-app="bjond-app">
  <%= yield %>
</div>

(7) Set-up Encryption Key

For security, the encryption keys stored from Bjond Server are themselves encrypted. Define the following environment variable: APP_ENCRYPTION_KEY. If you have multiple apps in your environment, you can modify the name of this constant using BjondApi::BjondAppConfig.instance.encryption_key_name.

To create an API key, from the Rails console (Rails c), type -

[ Array.new(32) { rand(256) }.pack('C*') ].pack('m').chop

Add this to your .bashrc / .zshrc like follows:

BJOND_APP_ENCRYPTION_KEY="12345678/nux3uEVX2tHBRGc5gN4gQXIbkFEmy6d3chas="

Again, BJOND_APP_ENCRYPTION_KEY can be changed. It just needs to match the value set in your config file.

Other environment variables that will need to be set include:

BJOND_ADAPTER_SUBJECT

and

BJOND_ADAPTER_AUDIENCE

(8) Set URL Options. In ‘development.rb`, set your local development options:

config.action_controller.default_url_options = {
  :host => "localhost:3002",
  :root_url => "http://localhost:3002"
}

Routes¶ ↑

This gem contains several prepared routes that will aid registration, and communication with Bjond Server core.

To set your app’s default route to the registration page, add this line to your routes.rb file -

root 'bjond_registrations#index'

For more information on the default routes, check-out the gem’s route page

API Methods¶ ↑

  • register_app

  • fire_event

Environment Variables¶ ↑

  • BJOND_ADAPTER_AUDIENCE

  • BJOND_ADAPTER_SUBJECT

Essential Schema¶ ↑

Most likely, your app schema will have additional configuration tables that are specific to the business logic of the adapter.