Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Postgres DB certificate handling and use a CSP during web development #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gary-archer
Copy link
Contributor

@gary-archer gary-archer commented Dec 29, 2024

A couple of odds and ends to make our example deployments more robust with reader appeal:

  • Simplify cloud native pod initialization of a Postgres SPIRE deployment using an init container
  • Use a CSP during web development, since that is easy to enable and ties in with the chapter 13 text

@gary-archer gary-archer changed the title Improvemens to SPIRE DB and web CSP Improvements to SPIRE DB and web CSP Dec 29, 2024

RUN apt-get update && apt-get install -y inotify-tools

COPY postgresql.conf /etc/postgresql/postgresql.conf
Copy link
Contributor Author

@gary-archer gary-archer Dec 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously I copied these files around in some initialization bash scripting which was a little non standard. Now I just copy in custom file and configure Postgres to use it in a more standard way..

@@ -63,9 +63,12 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON products TO demoapi;

## X509 SVID Downloads

Copy link
Contributor Author

@gary-archer gary-archer Dec 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously I had problems if Postgres started but the certificate was not available yet. Now I use a pattern of a init container to get the initial secret and a sidecar container to keep it updated.

((COUNT++))
done
```

Copy link
Contributor Author

@gary-archer gary-archer Dec 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whereas this type of polling felt non standard and is now removed.

@@ -76,6 +81,25 @@ spec:
readOnly: true
- name: svids
mountPath: /svids
initContainers:
Copy link
Contributor Author

@gary-archer gary-archer Dec 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The init container uses a SPIFFE helper configuration file with daemon_mode = false. Once the init container runs to completion, the main container starts and SVIDs are available to it. Demonstrating these two modes feels like a quite neat technique to show to the reader.

policy += " object-src 'none';";
policy += " frame-ancestors 'none';";
policy += " base-uri 'self';";
policy += " form-action 'self'";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously I had thought that webpack dev server required insecure options like unsafe-eval, but it turns out that it does not, as long as you use source maps. Therefore our example can use secure headers for development, like those in various online articles.

@gary-archer gary-archer changed the title Improvements to SPIRE DB and web CSP Improvements to SPIRE DB deployment and to use a CSP during web development Dec 29, 2024
@gary-archer gary-archer changed the title Improvements to SPIRE DB deployment and to use a CSP during web development Simplify Postgres DB certificate handling and use a CSP during web development Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant