Skip to content

Latest commit

 

History

History
182 lines (122 loc) · 4.31 KB

File metadata and controls

182 lines (122 loc) · 4.31 KB

GovBox Pro

Requirements

Installation steps

Install Ruby and Node.js to versions specified in .tool-versions

Ensure to have postgresql-devel and libyaml-devel installed in your system.

asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
asdf install

Configuration

Create own env file `

cp .env .env.local

Setup an email with which you will sign in in .env.local

SITE_ADMIN_EMAILS=your-g-suite-sign-up-email@gmail.com

Google OAuth2

GOOGLE_CLIENT_ID=some-numbers-and-characters.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-and-other-secret-part

Microsoft Entra ID (AAD)

  • Create AAD APP
    • don't forget to Add a Redirect URI http://localhost:3000/auth/microsoft_graph/callback
  • write Application (client) ID and Certificates & secrets to .env.local, example:
AZURE_APPLICATION_CLIENT_ID=some-numbers-and-characters
AZURE_APPLICATION_CLIENT_SECRET=some-secret
  • in the portal, open the Manifest tab under Manage section and set the following properties:
"accessTokenAcceptedVersion": 2,
"signInAudience": "AzureADandPersonalMicrosoftAccount"

For more details, see the official documentation

Running

Run database

docker-compose up

Install dependencies & setup database for local and test environment

./bin/setup
env RAILS_ENV=test ././bin/setup
yarn

Seed the database

After configuring your admin email and setting up the database, run:

./bin/rails db:seed

Note

Make sure you have set SITE_ADMIN_EMAILS in your .env.local file before running the seed command, as this creates the admin account and other initial data.

Run local development environment

./bin/dev

Run tests

./bin/rails test

Run console

./bin/rails c

API

OpenAPI Documentation

public/openapi.yaml

Setup API credentials for development

  1. Generate RSA keypair:
openssl genrsa -out govbox_dev_api_token.private.pem 2048
openssl rsa -in govbox_dev_api_token.private.pem -pubout -out govbox_dev_api_token.public.pem
  1. Set the public key on your tenant, enable API feature, Generate API token (in Rails console):
# bin/rails console

TENANT_ID = 1 # your tenant id
PEM = 'govbox_dev_api_token.private.pem'

tenant = Tenant.find(TENANT_ID)
tenant.api_token_public_key = File.read(PEM)
tenant.feature_flags << :api
tenant.save!

def api_token_private_key
  OpenSSL::PKey::RSA.new(File.read(PEM))
end

def generate_api_token(tenant)
  JWT.encode({ sub: tenant.id, exp: 5.minutes.from_now.to_i, jti: SecureRandom.uuid }, api_token_private_key, 'RS256')
end

token = generate_api_token(tenant) # max 5 minutes validity
  1. Use the token in API requests:
export GOVBOX_TOKEN=token-from-rails-console
curl -H "Authorization: Bearer $GOVBOX_TOKEN" http://localhost:3000/api/boxes

Other

Async Jobs

Getting sample data

  • Your public IP has to be added to whitelist (ask colleague)
  • In rails console run Govbox::SyncBoxJob.perform_later(Box.last)

Create sample FS connections

Execute this script in rail console.

Create sample UPVS connection

Execute following command in rails console.

Govbox::ApiConnectionWithOboSupport.find_or_create_by!(
  tenant: Tenant.first,
  sub: "SPL_Irvin_83300252_KK_24022023",
  api_token_private_key: File.read(Rails.root + "security/govbox_api_fix.pem")
)