Skip to content

Commit dc0cbd7

Browse files
data-henrikl2fprod
andauthored
Change architecture to use app-based authentication (#42)
* switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * switch to OIDC and passport * replaced Architecture.svg * replaced Architecture.svg * update README for local tests * update README for local tests * update for local tests * ⚰️ removed unused * 💄 log user and set name for UI to use * ⚡️ removed references to sfsappid. Now AppID can be named as other services given we are not using the IKS plugin * don't fail if scan fails * force users to set cluster and resource group names * show localhost instead of 0.0.0.0 and give default in template * 🔒️ removed unused packages, updating some * tweak add/remove * keep failing if va scan does not pass * use terraform 1.5 * reference secrets manager * highlight failscan as a way to unblock toolchain in case image has vulnerabilities --------- Co-authored-by: Frederic Lavigne <[email protected]>
1 parent 62d480d commit dc0cbd7

16 files changed

+838
-387
lines changed

Architecture.svg

Lines changed: 1 addition & 1 deletion
Loading

Architecture_cbr.png

-68.7 KB
Binary file not shown.

Architecture_cbr.svg

Lines changed: 3 additions & 0 deletions
Loading

README.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ Refer to [this tutorial](https://cloud.ibm.com/docs/solution-tutorials?topic=sol
1313
![Architecture](Architecture.svg)
1414

1515
1. The user connects to the application.
16-
2. [App ID](https://cloud.ibm.com/catalog/services/AppID) secures the application and redirects the user to the authentication page. Users can sign up from there too.
17-
3. The application is running in a [Kubernetes cluster](https://cloud.ibm.com/containers-kubernetes/catalog/cluster) from an image stored in the [container registry](https://cloud.ibm.com/containers-kubernetes/launchRegistryView). The image is automatically scanned for vulnerabilities.
18-
4. Files uploaded by the user are stored in [Cloud Object Storage](https://cloud.ibm.com/catalog/services/cloud-object-storage).
19-
5. The bucket where the files are stored is using a user-provided key to encrypt the data.
20-
6. All activities related to managing the solution are logged by [Cloud Activity Tracker with LogDNA](https://cloud.ibm.com/catalog/services/logdnaat).
16+
2. Optionally [Secrets Manager](https://cloud.ibm.com/catalog/services/secrets-manager) is used to store/retrieve certificates.
17+
3. [App ID](https://cloud.ibm.com/catalog/services/AppID) secures the application and redirects the user to the authentication page. Users can sign up from there too.
18+
4. The application is running in a [Kubernetes cluster](https://cloud.ibm.com/containers-kubernetes/catalog/cluster) from an image stored in the [container registry](https://cloud.ibm.com/containers-kubernetes/launchRegistryView). The image is automatically scanned for vulnerabilities.
19+
5. Files uploaded by the user are stored in [Cloud Object Storage](https://cloud.ibm.com/catalog/services/cloud-object-storage).
20+
6. The bucket where the files are stored is using a user-provided key to encrypt the data.
21+
7. All activities related to managing the solution are logged by [Cloud Activity Tracker with LogDNA](https://cloud.ibm.com/catalog/services/logdnaat).
2122

2223
The application can be deployed using a toolchain.
2324

2425
# Enhance cloud security by applying context-based restrictions
2526
To further enhance security, context-based restrictions are implemented on top the deployed resources as shown.
26-
![](Architecture_cbr.png)
27+
![](Architecture_cbr.svg)
2728

2829
Refer to the tutorial [Enhance cloud security by applying context-based restrictions](https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-cbr-enhanced-security) for details and instructions.
2930

@@ -43,7 +44,7 @@ Please note that the Kubernetes cluster and the resources deployed via Terraform
4344

4445
### Deploy resources using Terraform managed by Schematics
4546

46-
Either create the Schematics workspace automatically by clicking this ["deploy link"](https://cloud.ibm.com/schematics/workspaces/create?repository=https://github.com/IBM-Cloud/secure-file-storage/tree/master/terraform&terraform_version=terraform_v1.2). Or set it up manually by going to the [Schematics workspaces](https://cloud.ibm.com/schematics/workspaces) and using https://github.com/IBM-Cloud/secure-file-storage/tree/master/terraform as source respository including the path and the latest version of Terraform runtime.
47+
Either create the Schematics workspace automatically by clicking this ["deploy link"](https://cloud.ibm.com/schematics/workspaces/create?repository=https://github.com/IBM-Cloud/secure-file-storage/tree/master/terraform&terraform_version=terraform_v1.5). Or set it up manually by going to the [Schematics workspaces](https://cloud.ibm.com/schematics/workspaces) and using https://github.com/IBM-Cloud/secure-file-storage/tree/master/terraform as source respository including the path and the latest version of Terraform runtime.
4748

4849
Configure all required variables:
4950
- **basename**: project basename which is used as prefix for names, e.g., secure-file-storage
@@ -54,6 +55,7 @@ Configure all required variables:
5455
- **toolchain_registry_namespace**: The existing namespace in the Container Registry to use.
5556
- **toolchain_registry_region**: The Container Registry region
5657
- **toolchain_apikey**: An IBM Cloud API key to use for building the container image with the app, pushing it to the Container Registry, and deploying it to the Kubernetes cluster.
58+
- **toolchain_failscan**: Set to false to not fail in case vulnerabilities are detected.
5759
- **deploy_cbr**: Indicates whether the CBR zones and rules should be deployed. `false` by default and can be set to `true`.
5860
- **cbr_enforcement_mode**: By default, the CBR rules are in `report` mode only. Change and set to `enforced` or `disabled`.
5961
- **cbr_homezone_iprange**: Can be set to the IP range of your home or bastion network.
@@ -99,23 +101,18 @@ Located in the [app](app) directory:
99101
| File | Description |
100102
| ---- | ----------- |
101103
|[app.js](app/app.js)|Implementation of the application.|
102-
|[app/credentials.template.env](credentials.template.env)|To be copied to `credentials.env` and filled with credentials to access services. `credentials.env` is used when running the app locally and to create a Kubernetes secret before deploying the application to a cluster manually.|
103-
|[app/Dockerfile](Dockerfile)|Docker image description file.|
104-
|[app/secure-file-storage.template.yaml](secure-file-storage.template.yaml)|Kubernetes deployment file with placeholders. To be copied to `secure-file-storage.yaml` and edited to match your environment.|
104+
|[app/credentials.template.env](app/credentials.template.env)|To be copied to `credentials.env` and filled with credentials to access services. `credentials.env` is used when running the app locally and to create a Kubernetes secret before deploying the application to a cluster manually.|
105+
|[app/Dockerfile](app/Dockerfile)|Docker image description file.|
106+
|[app/secure-file-storage.template.yaml](app/secure-file-storage.template.yaml)|Kubernetes deployment file with placeholders. To be copied to `secure-file-storage.yaml` and edited to match your environment.|
105107

106108

107109
### To test locally
108-
The app can be tested and developed locally, however it requires a version (same or different to the local version) of the app to be deployed in Kubernetes. The reason is that access is guarded by an access token. That token can only be issued in the Kubernetes environment with App ID intercepting requests.
109-
110-
To test locally:
111-
1. Follow the tutorial instructions to have the app deployed to a cluster. Specially the sections to create all the services and to populate the `credentials.env` file. You will need the public instead of the private COS endpoint in order to access Cloud Object Storage from your machine.
112-
1. Access the tokens with `https://secure-file-storage.<INGRESS_SUBDOMAIN>/api/tokens`. This will shows the raw App ID authorization header together with the decode JWT tokens for your session.
113-
1. In your local shell:
114-
```
115-
export TEST_AUTHORIZATION_HEADER="<value of the header attribute 'Bearer ... ...'>"
116-
```
117-
1. `npm start` or `node app.js` to start the app.
118-
1. Access the local app through the shown URL. Now, you can change the app source code and test locally.
110+
The app can be tested and developed locally, either directly by using `npm start` or by building and running a container by leveraging the `Dockerfile`.
111+
112+
1. Follow the tutorial instructions to create all the services and to populate the `credentials.env` file. You will need the public instead of the private COS endpoint in order to access Cloud Object Storage from your machine.
113+
2. Add `http://0.0.0.0/redirect_uri` to App ID as Web redirect URI. See the [section in tutorial](https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-cloud-e2e-security#cloud-e2e-security-11) for details.
114+
3. `npm start` or `node app.js` to start the app. To use a container, utilize `docker build` and `docker run` commands.
115+
4. Access the local app through the shown URL. Now, you can change the app source code and test locally.
119116

120117

121118
## License

app/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
FROM node:20
22
ENV NODE_ENV production
3+
4+
# updates to fix vulnerabilities
5+
RUN apt-get update; \
6+
apt-get install -yy libgnutls30 perl; \
7+
apt-get remove -yy libtiff6 libtiff-dev libde265-0 libnghttp2-14; \
8+
apt-get clean
9+
10+
# put app in /usr/src/app
311
WORKDIR /usr/src/app
412
COPY . .
513
RUN npm install --production --silent

0 commit comments

Comments
 (0)