Backend Configuration
LogicApp Configuration
The backend voucher redemption and generation engine of a N2VS deployment is a configured N2SVCD LogicApp instance. Inbound REST requests are received by the LogicApp for processing. These requests include voucher redemption, voucher generation and updates to voucher ranges.
A full example of the LogicApp configuration for the voucher server is:
<application name="N2VS-SERVICE-LOGIC" module="LogicApp" admin_alloc="1m" user_alloc="64m" overloaded_poll_ms="60000" overloaded_active_ms="60000">
<include>
<lib>../apps/logic/lib</lib>
</include>
<parameters>
<parameter name="edr_enabled" value="1"/>
<parameter name="default_edr_app_name" value="EDR"/>
<parameter name="db_app_name_smf" value="DB-SMF"/>
<parameter name="db_app_name_voucher" value="DB-VOUCHER"/>
<parameter name="rest_app_name_ocs" value="OCS-REST-Client"/>
<parameter name="default_edr_stream_key" value="n2vs"/>
<parameter name="trace_level" value="0"/>
<parameter name="max_trace_level" value="3"/>
<parameter name="trace_level" value="3"/>
<parameter name="trace_per_second" value="50"/>
<parameter name="default_lua_lib_path" value="/n2svcd/lua/lib/?.lc;/n2svcd/lua/lib/3rdparty/?.lc;/n2vs/lua/lib/?.lc;/n2vs/lua/lib/?.lua"/>
</parameters>
<config>
<services>
<service module="RestServerApp::RestLuaService" libs="../apps/rest_s/lib"
script_dir="/n2vs/lua/rest_api/">
<globals>
<global name="GENERATORS" type="array">
<generator>numeric</generator>
</global>
<global name="ENCRYPTORS" type="array">
<encryptor>unencrypted</encryptor>
<encryptor>hmacsha</encryptor>
</global>
<global name="DISTRIBUTION_METHODS" type="array">
<method>browser_download</method>
<method>local_file</method>
</global>
<global name="OCS_INTEGRATION">n2vs_mock_ocs</global>
</globals>
<triggers>
<!-- removed for clarity -->
</triggers>
</service>
</services>
<agents>
<agent module="DBApp::DBLuaAgent" libs="../apps/db/lib">
<config>
<db_timeout_ms>60000</db_timeout_ms>
</config>
</agent>
<agent module="RestClientApp::RestLuaAgent" libs="../apps/rest_c/lib"/>
<agent module="VoucherServer::RandomSecureAgent" libs="/n2vs/apps/vs/lib"/>
<agent module="VoucherServer::HMACAgent" libs="/n2vs/apps/vs/lib"/>
<agent module="VoucherServer::VoucherTemplateAgent" libs="/n2vs/apps/vs/lib"/>
</agents>
</config>
</application>
The following points are relevant to LogicApp configuration for N2VS when receiving REST requests:
- The
module
andlibs
parameters in theservice
must refer to theRestLuaService
provided by N2SVCD. - The
script_dir
parameter in theservice
will always point to the REST API Lua scripts provided by the voucher server - e.g./n2vs/lua/rest_api/
.
Lua Library Paths
For the lua_lib_path
parameter in the LogicApp service
, the following guidelines apply:
- The following library paths are required:
- N2SVCD libraries:
../lua/lib/?.lua
- N2SVCD 3rd party libraries:
../lua/lib/3rdparty/?.lua
- N2VS core libraries:
/n2vs/lua/lib/?.lua
- N2SVCD libraries:
- The path to the directory where the
GENERATORS
andENCRYPTORS
plugins can be found. The default generators and encryptors can be found in/n2vs/lua/lib
.
Compiled Lua
Any Lua libraries, both supplied by N-Squared and custom, may be pre-compiled
by using the Lua compiler utility.
If this is done, ensure that the lua_lib_path
is updated to reflect the
appropriate file suffix (.lc
) as generated by the compiler.
Globals
GENERATORS
The GENERATORS
configuration lists the N2VS generators (both custom and built-in) that
are available for use by the system for generating voucher HRNs. The following generators
are available to the system on installation:
Generation Method | Description |
---|---|
numeric |
Generates voucher HRNs of a fixed length (as configured by a user in the N2VS GUI) and made up of consistently random digits 0-9 |
ENCRYPTORS
The ENCRYPTORS
configuration lists the N2VS encryption methods (both custom and built-in) that
are available for use by the system for encyrpting voucher HRNs when stored to the voucher server
database. The following encryptors are available to the system on installation:
Encryption Method | Description |
---|---|
unencrypted |
Generated HRNs are not encrypted. The HRN is stored unencrypted. |
hmacsha |
The HMAC SHA algorithm is used to encrypted HRNs using a one-way hash function based on a private key configured for the voucher generator by the N2VS User. The hash function (SHA-256, SHA-512/256 etc) is configured at the same time. |
DISTRIBUTION_METHODS
The DISTRIBUTION_METHODS
configuration lists the mechanisms by which a voucher batch can be distributed.
Distribution is the act of exporting the unencrypted HRNs from a generated voucher batch in a format
that can be provided to distributors and then subsequently provided to users who can redeem vouchers by
providing the unencrypted HRN.
The following distribution methods are available to the system on installation:
Distribution Method | Description |
---|---|
browser_download |
When a N2VS GUI users distributes a voucher batch with this method, the system will generate a voucher file that is downloaded by the user’s browser and saved to disk for distribution then by the user. |
local_file |
When the N2VS distributes a voucher batch using this method, the voucher batch distribution file is stored to a file path available to the N2VS backend service. |
OCS_INTEGRATION
The OCS_INTEGRATION
configuration option defines the Lua library file that will be used to
perform the “Redeem” action for a voucher against an OCS.
Which OCS integration method is required will be determined by the type of system the voucher “Redeem” action should be performed against.