Skip to content

Commit

Permalink
Merge branch 'bug/IAM' of https://github.com/cubeddu/graph-explorer i…
Browse files Browse the repository at this point in the history
…nto service-test-deploy
  • Loading branch information
michaelnchin committed Nov 18, 2023
2 parents 8628582 + fea0ebc commit d1ea99a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ To provide a default connection such that initial loads of the graph explorer al
- `GRAPH_CONNECTION_URL` - `None` - See [Add a New Connection](#connections-ui)
- Required if `USING_PROXY_SERVER=True` and `IAM=True`
- `AWS_REGION` - `None` - See [Add a New Connection](#connections-ui)
- `SERVICE_TYPE` - `Neptune-db`
- `SERVICE_TYPE` - `neptune-db`

#### JSON Configuration Approach

Expand All @@ -135,7 +135,7 @@ First, create a `config.json` file containing values for the connection attribut
"GRAPH_CONNECTION_URL": "https://cluster-cqmizgqgrsbf.us-west-2.neptune.amazonaws.com:8182",
"USING_PROXY_SERVER": true, (Can be string or boolean)
"IAM": true, (Can be string or boolean)
"SERVICE_TYPE": "Neptune-db",
"SERVICE_TYPE": "neptune-db",
"AWS_REGION": "us-west-2",
"GRAPH_TYPE": "gremlin" (Possible Values: "gremlin", "sparql", "opencypher"),
"GRAPH_EXP_HTTPS_CONNECTION": true (Can be string or boolean),
Expand Down Expand Up @@ -163,7 +163,7 @@ docker run -p 80:80 -p 443:443 \
--env IAM=false \
--env GRAPH_CONNECTION_URL=https://cluster-cqmizgqgrsbf.us-west-2.neptune.amazonaws.com:8182 \
--env AWS_REGION=us-west-2 \
--env SERVICE_TYPE=Neptune-db \
--env SERVICE_TYPE=neptune-db \
--env PROXY_SERVER_HTTPS_CONNECTION=true \
--env GRAPH_EXP_FETCH_REQUEST_TIMEOUT=9000 \
graph-explorer
Expand Down
8 changes: 5 additions & 3 deletions packages/graph-explorer-proxy-server/node-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const path = require("path");
const pino = require("pino");
const { fromNodeProviderChain } = require("@aws-sdk/credential-providers");
const aws4 = require("aws4");
const serviceType = process.env.SERVICE_TYPE || "neptune-db";

dotenv.config({ path: "../graph-explorer/.env" });

Expand Down Expand Up @@ -88,13 +87,16 @@ const errorHandler = (error, request, response, next) => {
) => {
// remove the existing host headers, we want ensure that we are passing the DB endpoint hostname.
delete headers["host"];
if (headers["aws-neptune-region"]) {
const serviceType = headers["service-type"];
const AWSRegion = headers["aws-neptune-region"];

if (AWSRegion && serviceType) {
data = await getIAMHeaders({
host: url.hostname,
port: url.port,
path: url.pathname + url.search,
service: serviceType,
region: headers["aws-neptune-region"],
region: AWSRegion,
});
headers = { ...headers, ...data };
}
Expand Down
3 changes: 3 additions & 0 deletions packages/graph-explorer/src/connector/AbstractConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ export abstract class AbstractConnector {
if (this._connection?.awsAuthEnabled) {
headers["aws-neptune-region"] = this._connection?.awsRegion || "";
}
if (this._connection?.serviceType) {
headers["service-type"] = this._connection?.serviceType || "";
}

return headers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const ConnectionDetail = ({ isSync, onSyncChange }: ConnectionDetailProps) => {
url: config.connection?.url,
type: config.connection?.queryEngine,
fetchTimeMs: config.connection?.fetchTimeoutMs,
serviceType: config.connection?.serviceType,
}}
/>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const CreateConnection = ({
proxyConnection: initialData?.proxyConnection || false,
graphDbUrl: initialData?.graphDbUrl || "",
awsAuthEnabled: initialData?.awsAuthEnabled || false,
serviceType: initialData?.serviceType || "neptune-db",
serviceType: initialData?.serviceType || "neptune-graph",
awsRegion: initialData?.awsRegion || "",
enableCache: true,
cacheTimeMs: (initialData?.cacheTimeMs ?? 10 * 60 * 1000) / 60000,
Expand Down Expand Up @@ -177,7 +177,7 @@ const CreateConnection = ({
return;
}

if (form.awsAuthEnabled && !form.awsRegion) {
if (form.awsAuthEnabled && !form.awsRegion && !form.serviceType) {
setError(true);
return;
}
Expand Down

0 comments on commit d1ea99a

Please sign in to comment.