Skip to content

Commit

Permalink
Proxy through the console instead of our own separate service.
Browse files Browse the repository at this point in the history
  • Loading branch information
evanstoner committed Oct 16, 2024
1 parent e6ac053 commit 9be9125
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 64 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/container_build_apigw.yml

This file was deleted.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ The Falcon OpenShift Console Plugin is an open source project, not a CrowdStrike

## Deployment

### Prerequisites

This plugin currently only supports CrowdStrike's US-2 cloud region.

### Deploy the Helm chart

The Falcon OpenShift Console Plugin is available at [quay.io/crowdstrike/falcon-openshift-console-plugin](https://quay.io/crowdstrike/falcon-openshift-console-plugin) and the required API gateway is at [quay.io/crowdstrike/falcon-openshift-console-plugin-apigw](https://quay.io/crowdstrike/falcon-openshift-console-plugin-apigw)
The Falcon OpenShift Console Plugin is available at [quay.io/crowdstrike/falcon-openshift-console-plugin](https://quay.io/crowdstrike/falcon-openshift-console-plugin)

Install the chart using the name of the plugin as the Helm release name into a new namespace or an existing namespace as specified by the `plugin_console-plugin-template` parameter by using the following command:

Expand Down
7 changes: 0 additions & 7 deletions api-gateway/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions api-gateway/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions api-gateway/location.conf

This file was deleted.

3 changes: 0 additions & 3 deletions api-gateway/upstream.conf

This file was deleted.

20 changes: 20 additions & 0 deletions charts/openshift-console-plugin/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,31 @@ data:
include /etc/nginx/mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
upstream crowdstrike_api {
server api.us-2.crowdstrike.com:443;
}
server {
listen {{ .Values.plugin.port }} ssl;
listen [::]:{{ .Values.plugin.port }} ssl;
ssl_certificate /var/cert/tls.crt;
ssl_certificate_key /var/cert/tls.key;
root /usr/share/nginx/html;
location /crwdapi/ {
# respond to preflight requests
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'Authorization';
add_header Content-Type text/plain;
add_header Content-Length 0;
return 204;
}
# all other requests, proxy the response and then add CORS header
proxy_pass https://crowdstrike_api/;
add_header Access-Control-Allow-Origin $http_origin;
}
}
}
16 changes: 14 additions & 2 deletions charts/openshift-console-plugin/templates/consoleplugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@ metadata:
{{- include "openshift-console-plugin.labels" . | nindent 4 }}
spec:
displayName: {{ default (printf "%s Plugin" (include "openshift-console-plugin.name" .)) .Values.plugin.description }}
i18n:
i18n:
loadType: Preload
backend:
type: Service
service:
name: {{ template "openshift-console-plugin.name" . }}
namespace: {{ .Release.Namespace }}
port: {{ .Values.plugin.port }}
basePath: {{ .Values.plugin.basePath }}
basePath: {{ .Values.plugin.basePath }}
proxy:
# re-proxy the existing backend service, since the backend is normally exposed to only allow
# GET's, but our reverse proxy in the nginx config supports any method
# https://github.com/openshift/console/blob/master/pkg/plugins/handlers.go
- alias: reproxy
authorization: None
endpoint:
service:
name: {{ template "openshift-console-plugin.name" . }}
namespace: {{ .Release.Namespace }}
port: {{ .Values.plugin.port }}
type: Service
9 changes: 4 additions & 5 deletions src/components/shared/ProxiedFetch.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { consoleFetch } from '@openshift-console/dynamic-plugin-sdk';

// make requests to our reverse proxy instead of directly to the CrowdStrike API, since it doesn't
// support arbitrary CORS
export default function proxiedFetch(url, options) {
const proxyBase = window.location.origin.replace(
'console-openshift-console',
'api-gateway-falcon-openshift-console-plugin',
);
const proxyBase = '/api/proxy/plugin/falcon-openshift-console-plugin/reproxy/crwdapi';
const path = url.substr(url.indexOf('.com') + 4);
return fetch(proxyBase + path, options);
return consoleFetch(proxyBase + path, options);
}

0 comments on commit 9be9125

Please sign in to comment.