Categorygithub.com/goldexrobot/core.integration.backend

# README

Goldex Robot: Integration

Goldex Robot is a vending machine that evaluates gold/silver valuables, sells coins and has an internal items storage.

Integration with Goldex consists of two major parts: backend integration and UI integration.

This document covers backend integration.


TL;DR

Goldex vending machine serves UI and communicates with the core Goldex backend.

This core backend exposes an API to control the machine from a business side.

Check out Swagger.

Goldex environment


API

Goldex core backend exposes an API to provide some extended information like machines available for some specific project, photos available, evaluation history etc.

Moreover the API allows business backend to control a vending machine (switch operational mode).

Calls to the API must be supplied with a basic HTTP auth header. Contact Goldex support to get the credentials.

See Swagger.


Callbacks (deprecated)

Goldex backend sends optional HTTP requests to notify the business backend about new events or to request some information from the machine in a real time.

See POST /callbacks in Swagger.

The HTTP requests are: callbacks and named proxy endpoints (see below).

Requests are always of method POST and carry application/json; charset=utf-8 with the headers:

HeaderMeaningExample
X-CBOT-PROJECT-IDOrigin project ID"1"
X-CBOT-BOT-IDOrigin bot ID (uint64)"42"

All the Goldex requests are signed (see below) and should be validated at the business side.

Business backend has to respond with the successful HTTP status (200, 201, or 202) to signalize about callback consumption. Until then, Goldex may continue to resend requests.

Named proxy endpoints

Proxy endpoints are optional named callbacks (name-to-endpoint bindings) and are available at the UI side.

The purpose of endpoints is to give the UI a secure way to call business backend. For instance, to get an access token.

See POST /proxy in Swagger.

In this case Goldex backend acts as a secure proxy between the machine and business backend.

For instance, let's assume business backend have defined an endpoint auth pointing to https://example.com/bot/auth.

UI now calls proxy method auth using UI API. Goldex signs the request and sends POST https://example.com/bot/auth:

{
  "project_id": 1,
  "bot_id": 42,
  "payload": {
    // optional k/v from the machine side
  }
}

Then Goldex backend waits for a response from the business backend (status 200, application/json) and returns the response back to the UI.


Signing

Goldex signs callbacks with a JWT. Token is signed with a per-project secret and is transferred in Authorization HTTP header (bearer).

Business backend should validate those callbacks. Developer is fully responsible for the security.

Authorization: Bearer <jwt.goes.here>

JWT claims

Here are default fields of JWT used during signing:

FieldPurposeFormatExample
audRecipient namestring(3-32): alphanumeric, -, _project-1
issIssuer namestring(3-32): alphanumeric, -, _goldex
jtiUnique request IDstring(6-36): alphanumeric, - (UUID compatible)16d918112b0844628754299eb1810963
subSubject (request or notification)string(32): alphanumericrequest
exp, nbf, iatExpiration, not before and issuance timeAccording to RFC 7519-

Additional JWT fields:

FieldPurposeFormatExample
bhaRequest body hash algorithmstring(16): SHA-256, SHA-384, SHA-512, SHA3-224, SHA3-256, SHA3-384, SHA3-512SHA-512
bhsRequest body hashstring(32-128): hexadecimal without leading 0x5ea71dc6...ae04ee54
mtdRequest methodstring(8): GET, POST etc.POST
urlRequest URLstring(256): valid URLhttps://example.com

Body hash algorithm and hash fields are empty for bodiless request such as GET.

JWT signing algorithms are: HS256 (HMAC SHA-256), HS384 (HMAC SHA-384), HS512 (HMAC SHA-512).

Try out signing here.

# Packages

No description provided by the author