Skip to content

Commit

Permalink
Merge pull request #673 from naphelps/issue-637
Browse files Browse the repository at this point in the history
Issue 637: Added CORS Support
  • Loading branch information
naphelps authored May 1, 2023
2 parents cfa31cd + b6db83d commit 602abca
Show file tree
Hide file tree
Showing 154 changed files with 7,837 additions and 5,416 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file.

## [2.113.0] - 2023-04-26
- Issue 637 - Added CORS support. Can be configurated via the Exchange's config.json file.
- Changed Java package path to the prefix org.openhorizon.
- Moved source handling routing to new sub-package org.openhorizon.route..
- AdminRoutes and AgbotRoutes have been further sub-divided based on rest resource.
- Deprecated custom methods for handling Akka configuration parameters in favor of framework defaults.
- Backwards compatibility is still maintained.

## [2.112.0] - 2023-04-07
- Issue 640: Added `clusterNamespace` attribute to Deployment Patterns.
- Issue 641: Added `clusterNamespace` attribute to Nodes.
Expand Down
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ lazy val root = (project in file("."))
akkaVersion := "[2.6.16]",
description := "'Containerized exchange-api'",
name := "amd64_exchange-api",
organization := "com.horizon",
organization := "org.openhorizon",
release := versionFunc(),
resolvers += Classpaths.typesafeReleases,
scalaVersion := "2.13.10",
Expand All @@ -51,6 +51,7 @@ lazy val root = (project in file("."))
// "com.typesafe.akka" %% "akka-http-spray-json" % "[10.2.1,)",
"de.heikoseeberger" %% "akka-http-jackson" % "[1.39.2]",
// "com.typesafe.akka" %% "akka-http-jackson" % "[10.2.1,)", // Can not find any recent documentation on how to use this
"ch.megard" %% "akka-http-cors" % "[1.1.2]",

"org.json4s" %% "json4s-native" % "4.0.6",
"org.json4s" %% "json4s-jackson" % "4.0.6",
Expand Down
101 changes: 67 additions & 34 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
copyright:
years: 2022 - 2023
lastupdated: "2023-03-14"
lastupdated: "2023-04-26"
layout: page
title: "Exchange API Server"
description: "Open Horizon Exchange API Documentation"
Expand Down Expand Up @@ -61,15 +61,15 @@ services in the exchange.

```json
{
"akka": {
"loglevel": "DEBUG"
},
"api": {
"db": {
"jdbcUrl": "jdbc:postgresql://localhost/postgres", // my local postgres db
"user": "myuser",
"password": ""
},
"logging": {
"level": "DEBUG"
},
"root": {
"password": "myrootpw"
}
Expand Down Expand Up @@ -97,7 +97,7 @@ services in the exchange.
## Building and Running in Local Sandbox
- `sbt`
- `~reStart`
- `reStart`
- Once the server starts, to see the swagger output, browse: [http://localhost:8080/v1/swagger](http://localhost:8080/v1/swagger){:target="_blank"}{: .externalLink}
- To try a simple rest method curl: `curl -X GET "http://localhost:8080/v1/admin/version"`. You should get the exchange version number as the response.
- When testing the exchange in an OpenShift Cluster the variables `EXCHANGE_IAM_ORG`, `EXCHANGE_IAM_KEY` and `EXCHANGE_MULT_ACCOUNT_ID` must be set accordingly.
Expand All @@ -121,8 +121,9 @@ export ICP_EXTERNAL_MGMT_INGRESS=<icp-external-host>:8443
When at the `sbt` sub-command prompt:

- Get a list of tasks: `task -V`
- Start your app such that it will restart on code changes: `~reStart`
- Start your app such that it will restart on code changes: `reStart`
- Clean all built files (if the incremental build needs to be reset): `clean`
- Check and attempt to resolve any binary incompatibilities in dependency stack: `evicted`

## Running the Automated Tests in Local Sandbox

Expand Down Expand Up @@ -187,7 +188,6 @@ Project uses Scapegoat. To use:

- Log output of the exchange svr can be seen via `docker logs -f exchange-api`, or might also go to `/var/log/syslog` depending on the docker and syslog configuration.
- Manually test container locally: `curl -sS -w %{http_code} http://localhost:8080/v1/admin/version`
- **Note:** The exchange-api does not support HTTPS until issue https://github.com/open-horizon/exchange-api/issues/259 is completed.
- Run the automated tests: `sbt test`
- **Note:** Swagger does not yet work in the local docker container.
- At this point you probably want to run `docker rm -f amd64_exchange-api` to stop your local docker container so it stops listening on your 8080 port. Otherwise you may be very confused when you go back to running the exchange via `sbt`, but it doesn't seem to be executing your tests.
Expand Down Expand Up @@ -348,6 +348,58 @@ Now you can disable root by setting `api.root.enabled` to `false` in `/etc/horiz
`src/main/resources/config.json` is the default configuration file for the Exchange. This file is bundled in the Exchange jar. To run the exchange server with different values, copy this to `/etc/horizon/exchange/config.json`. In your version of the config file, you only have to set what you want to override.
### akka
Akka Actor: https://doc.akka.io/docs/akka/current/general/configuration-reference.html
</br>
Akka-Http: https://doc.akka.io/docs/akka-http/current/configuration.html
</br>
Log Level: http://logback.qos.ch/apidocs/ch/qos/logback/classic/Level.html
| Parameter Name | Default Value | Description |
|----------------|----------------|-------------|
| loglevel | `"INFO"` | |
- #### akka.coordinated-shutdown
| Parameter Name | Default Value | Description |
|-------------------------------|---------------|--------------------------------------------------------------------------------|
| phases.service-unbind.timeout | `"60s"` | Number of seconds to let in-flight requests complete before exiting the server |
- #### akka.http.parsing
| Parameter Name | Default Value | Description |
|------------------------|---------------|-------------|
| max-header-name-length | `128` | |
- #### akka.http.server
| Paramater Name | Default Value | Description |
|------------------|---------------|-------------|
| backlog | `100` | |
| bind-timeout | `"1s"` | |
| idle-timeout | `"60s"` | |
| linger-timeout | `"1m"` | |
| max-connections | `1024` | |
| pipelining-limit | `1` | |
| request-timeout | `"45s"` | |
| server-header | `""` | |
### akka-http-cors
https://github.com/lomigmegard/akka-http-cors#configuration
| Parameter Name | Default Value | Description |
|-----------------------------|---------------------------------------------------|--------------------------------------------------------------------------|
| allow-credentials | `true` | |
| allow-generic-http-requests | `true` | Do not apply `Origin` header check to non-preflight (`OPTIONS`) requests |
| allowed-headers | `["*"]` | |
| allowed-methods | `["DELETE","GET","OPTIONS","PATCH","POST","PUT"]` | |
| allowed-origins | `["*"]` | |
| exposed-headers | `["*"]` | |
| max-age | `0s` | |
### api.acls
| Parameter Name | Description |
Expand All @@ -360,22 +412,7 @@ Now you can disable root by setting `api.root.enabled` to `false` in `/etc/horiz
| SuperUser | |
| User | |
### api.akka
Akka Actor: https://doc.akka.io/docs/akka/current/general/configuration-reference.html
</br>
Akka-Http: https://doc.akka.io/docs/akka-http/current/configuration.html
| Parameter Name | Description |
|------------------------------------|-----------------------------------------|
| akka.http.server.backlog | |
| akka.http.server.bind-timeout | |
| akka.http.server.idle-timeout | |
| akka.http.server.linger-timeout | |
| akka.http.server.max-connections | |
| akka.http.server.pipelining-limit | |
| akka.http.server.request-timeout | |
| akka.http.server.server-header | Removes the Server header from response |
### api.akka [DEPRECATED]
### api.cache
Expand Down Expand Up @@ -447,11 +484,7 @@ Akka-Http: https://doc.akka.io/docs/akka-http/current/configuration.html
| maxPatterns | Maximum number of patterns 1 user is allowed to create, 0 for unlimited |
| maxServices | Maximum number of services 1 user is allowed to create, 0 for unlimited |
#### api.logging
| Parameter Name | Description |
|-------------------|---------------------------------------------------------------------------------------------|
| level | For possible values, see http://logback.qos.ch/apidocs/ch/qos/logback/classic/Level.html |
#### api.logging [DEPRECATED]
#### api.resourceChanges
Expand All @@ -470,12 +503,12 @@ Akka-Http: https://doc.akka.io/docs/akka-http/current/configuration.html
#### api.service
| Parameter Name | Description |
|-------------------------------------|--------------------------------------------------------------------------------|
| host | |
| port | Services HTTP traffic |
| portEncrypted | Services HTTPS traffic |
| shutdownWaitForRequestsToComplete | Number of seconds to let in-flight requests complete before exiting the server |
| Parameter Name | Description |
|------------------------------------------------|------------------------|
| host | |
| port | Services HTTP traffic |
| portEncrypted | Services HTTPS traffic |
| shutdownWaitForRequestsToComplete [DEPRECATED] | [DEPRECATED] |
#### api.tls
Expand Down
Loading

0 comments on commit 602abca

Please sign in to comment.