If you are going to use API Gateway for Mobile Ticket only, you should use the application_MobileTicket.yml file, which can be found next to the standard application.yml file in the API Gateway zip. For more information, see the Mobile Ticket manual, found on Qmatic World.
There are three configuration files available in the <installation_directory>\conf folder:
• In application.yml, you, for example, select the Orchestra services (entry point connector, service point connector, etc) that you want to expose. You also decide whether or not to use checksum validation.
As soon as application.yml is saved, API Gateway will be updated. No restart is needed!
Do not use the tab key, when editing the application.yml file!
• In logbackAPIGateway.xml, you configure the logging, in the same way as for Orchestra.
• In ehcache.xml, you configure a number of cache settings, for more information, see “Cache” .
This section describes all the settings that need to be configured in the application.yml file. We recommend that you configure all these settings at the same time.
API Token and Encrypted Password
After you have run the api-token-generator.bat script to generate an API Token and after you have run the password-encoder.bat script to encrypt your password, enter these into the api-tokens section of the application.yml file, as in the following example (Note that the values in the picture are not valid!):
The user superadmin should be removed, unless this is a test system.
Enabling HTTPS/SSL
The following picture explains the communication between the Mobile applications and API Gateway, on one hand, and between API Gateway and Orchestra on the other.
It is possible to, for example, use HTTP between Mobile applications and API Gateway and then HTTPS between API Gateway and Orchestra, if wanted.
The management.ssl setting should be set to false so that the shut down of API Gateway works as expected.
Running HTTPS from Mobile applications to API Gateway
Uncomment this section in the application.yml file:
ssl:
key-store: classpath:keystore.jks
key-store-password: secret
key-password: password
Make sure that the settings for key-store-password match the password for keystore.jks and that key-password matches the one set for the key/certificate.
If the regular Orchestra instruction has been followed, these are usually the same and they are set to "changeit".
The section should then now look like this:
server:
port: 9090
ssl:
key-store: classpath:keystore.jks
key-store-password: changeit
key-password: changeit
The server will listen only to HTTPS on port 9090.
The password is changeit by default, but can of course be changed.
It is currently not supported to listen on both HTTP and HTTPS, at the same time.
Running HTTPS from API Gateway towards Orchestra
To run HTTPS from API Gateway towards Orchestra, in the application.yml file, update the orchestra.central.url setting, so that it points to an https-url, as in the following example:
orchestra:
# define URL for orchestra central installation
central:
url: https://localhost:8443
Also, to use the SSL trust store for the JVM, uncomment this section:
trustStore: conf/truststore.jks
trustStorePass: changeit
Orchestra’s certificate needs to be imported into the API Gateway trust store. The password is changeit by default but can of course be changed.
To disable SSL certificate verification, uncomment the disableSslCertificateChecks parameter and set it to true.
This should not be used in production systems!
Routes
To configure the Routes settings, follow these steps:
1. Edit the routes section. Here, you define the routes that should be exposed via zuul proxy. These should match the connectors that you selected for the User that you created in Orchestra. In this way, only the needed parts of the system will be exposed.
Checksum validation is used, for example, to prevent the security risk where a User could manipulate the order of a Queue, in his/her favour, by for example guessing which Visit Id’s are in front of him/her in the Queue and then removing them.
If the validation fails, an error message is returned.
If you want to disable checksum validation (enabled by default), i.e. a validation of mobile query requests, you need to edit the following parameter in the application.yml file, and set it to false, as in the following example:
# use checksum validation for mobile requests
enableChecksum: false
However, if you want to keep it enabled, you also need to define which proxy routes this should be applied to. By default, this is applied to showing the status and deleting the Visit. The parameter field in the following section defines which path parameter that defines the Visit Id:
# define which proxy routes where checksum validation will be applied # name of the path parameter defining the visit_id must be defined as a parameter
checksumRoutes:
my_visit_delete:
parameter: ticket
my_visit_current_status:
parameter: visits
CORS Configuration
By default, CORS support is commented out and disabled in API Gateway.
When defining several paths, YAML list formatting is needed (-). See example below.
Example:
http:
cors:
paths:
# Defines configuration for endpoint '/foo'
- path: /foo
allowedOrigins: http://foo.com, http://bar.com
allowedHeaders: X-Foo, X-Bar, Content-Type
exposedHeaders: X-Foo, X-Bar
allowedMethods: GET, POST, PUT, OPTIONS, HEAD, DELETE, PATCH
The path tells which path the CORS configuration shall be applied on.
Required: TRUE
Example:
path: /foo
path: /foo/**
path: /**
Attribute: allowedOrigins
The allowedOrigins corresponds to CORS Http header Access-Control-Allow-Origin and list the acceptable Origin.
A comma separated list is supported.
Required: TRUE
Example:
allowedOrigins: http://foo.com, http://bar.com
allowedOrigins: '*'
Attribute: allowedHeaders
The allowedHeaders corresponds to CORS Http header Access-Control-Allow-Headers.
A comma separated list is supported.
Required: FALSE
Example:
allowedHeaders: X-Foo, X-Bar, Content-Type
allowedHeaders: '*'
Attribute: exposedHeaders
The exposedHeaders corresponds to CORS Http header Access-Control-Expose-Headers.
A comma separated list is supported.
Required: FALSE
Example:
exposedHeaders: X-Foo, X-Bar
exposedHeaders: '*'
Attribute: allowedMethods
The allowedMethods corresponds to CORS Http header Access-Control-Allow-Methods.
A comma separated list is supported.
Required: FALSE
Example:
allowedMethods: GET, POST, PUT, OPTIONS, HEAD, DELETE, PATCH
allowedMethods: '*'
Attribute: allowCredentials
The allowCredentials corresponds to CORS Http header Access-Control-Allow-Credentials.
A boolean value.
Required: FALSE
Example:
allowCredentials: true
Attribute: maxAge
The maxAge corresponds to CORS Http header Access-Control-Max-Age.
A numeric value in seconds.
Required: FALSE
Example:
maxAge: 3600
Duplication of CORS response headers
The Orchestra server that is located inside the API Gateway also returns CORS headers. To avoid duplication of CORS headers sent back to client Zuul configuration property zuul.ignored-headers can be used to ignore specified headers.