Skip to content

Commit

Permalink
Spelling and grammar fixes (#198)
Browse files Browse the repository at this point in the history
* Fix example file modes were strings rather than ints

Signed-off-by: Keegan Witt <[email protected]>

* Spelling and grammar fixes

Signed-off-by: Keegan Witt <[email protected]>

---------

Signed-off-by: Keegan Witt <[email protected]>
Co-authored-by: Faisal Memon <[email protected]>
  • Loading branch information
keeganwitt and faisal-memon authored Oct 10, 2024
1 parent 2b30f58 commit cd08dc0
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/tests/it/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ elif ((TEST_FAILED > 1)); then
echo -e "${RED}${TEST_FAILED} tests failed.${RESET}"
exit 1
else
echo -e "${GREEN}✔️ All tests succeded.${RESET}"
echo -e "${GREEN}✔️ All tests succeeded.${RESET}"
exit 0
fi
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ svid_key_file_name = "svid_key.pem"
svid_bundle_file_name = "svid_bundle.pem"
jwt_svids = [{jwt_audience="your-audience", jwt_svid_file_name="jwt_svid.token"}]
jwt_bundle_file_name = "bundle.json"
cert_file_mode = "0444"
key_file_mode = "0444"
jwt_bundle_file_mode = "0444"
jwt_svid_file_mode = "0444"
cert_file_mode = 0444
key_file_mode = 0444
jwt_bundle_file_mode = 0444
jwt_svid_file_mode = 0444
```

### Windows example
Expand Down
2 changes: 1 addition & 1 deletion examples/mosquitto/helper.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmd = "/usr/sbin/mosquitto"
# Query for configuration reloading
cmd_args = "-c ./examples/mosquitto/mosquitto.conf"

# Directory to store certificates (must match with the ssl setings in postgresql.conf)
# Directory to store certificates (must match with the ssl settings in postgresql.conf)
cert_dir = "/opt/spire/certs/mosquitto"

# No renew signal is used in this example
Expand Down
4 changes: 2 additions & 2 deletions examples/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ useradd mysql-client
### 7. Create the registration entries
Create the following registration entries:
+ For the MySQL client workload, the DNS name must match the database user name. The selector used for this entry is the user name: `mysql-client`.
+ For the MySQL client workload, the DNS name must match the database username. The selector used for this entry is the username: `mysql-client`.
```bash
./spire-server entry create \
-spiffeID spiffe://example.org/mysql-client \
Expand All @@ -95,7 +95,7 @@ Create the following registration entries:
-dns mysql-user
```
+ For the MySQL server, we use the root user name as selector:
+ For the MySQL server, we use the root username as selector:
```bash
./spire-server entry create \
-spiffeID spiffe://example.org/mysql-server \
Expand Down
14 changes: 7 additions & 7 deletions examples/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is an example of how **spiffe-helper** can be used to authenticate users to a **PostgreSQL** database using x509 SVIDs.

Postgres provides a feature that allows users to authenticate using [certificate authentication](https://www.postgresql.org/docs/9.5/auth-methods.html#AUTH-CERT). The server validates that the CN (Common Name) attribute of the certificate presented by the client matches the database user name or a [mapped](https://www.postgresql.org/docs/9.5/auth-username-maps.html) value.
Postgres provides a feature that allows users to authenticate using [certificate authentication](https://www.postgresql.org/docs/9.5/auth-methods.html#AUTH-CERT). The server validates that the CN (Common Name) attribute of the certificate presented by the client matches the database username or a [mapped](https://www.postgresql.org/docs/9.5/auth-username-maps.html) value.

This guide sets up the authentication configuration for the username: `postgres-user`.

Expand All @@ -15,8 +15,8 @@ The following assumptions are made:

+ At least one SPIRE server and one agent are deployed with trust domain `example.org`.

### 1. Install PosgreSQL
Install [PosgreSQL](https://www.postgresql.org/docs/12/tutorial-install.html) and make sure the service is up running.
### 1. Install PostgreSQL
Install [PostgreSQL](https://www.postgresql.org/docs/12/tutorial-install.html) and make sure the service is up running.
```
systemctl status postgresql@12-main
```
Expand All @@ -28,7 +28,7 @@ It creates a test database (`testdb`) and grants privileges to it.
sudo -u postgres psql -f create_user.sql
```

### 3. Configure PosgreSQL SSL settings
### 3. Configure PostgreSQL SSL settings
Make PostgreSQL server to use the certificates and key provided by SPIRE by setting the following SSL configurables in the PostgreSQL configuration file (`postgresql.conf`).
```bash
ssl = on
Expand Down Expand Up @@ -91,7 +91,7 @@ useradd postgresql-client
### 8. Create the registration entries
Create the following registration entries:
+ For the PostgreSQL client, the DNS name must match the database user name. The selector used for this entry is the user name: `postgresql-client`.
+ For the PostgreSQL client, the DNS name must match the database username. The selector used for this entry is the username: `postgresql-client`.
```bash
./spire-server entry create \
-spiffeID spiffe://example.org/psql-client \
Expand All @@ -101,7 +101,7 @@ Create the following registration entries:
-dns postgres-user
```
+ For the PostgreSQL server, we use the postgres user name as selector:
+ For the PostgreSQL server, we use the postgres username as selector:
```bash
./spire-server entry create \
-spiffeID spiffe://example.org/postgresql-server \
Expand Down Expand Up @@ -130,7 +130,7 @@ mkdir examples/postgresql/svids
sudo chown postgresql-client:postgresql-client examples/postgresql/svids
```
Connect to posgresql running the provided script with the `postgresql-client` user.
Connect to PostgreSQL running the provided script with the `postgresql-client` user.
```
sudo -u postgresql-client examples/postgresql/connect.sh
```
2 changes: 1 addition & 1 deletion examples/postgresql/helper.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cmd = "/usr/bin/psql"
# Query for configuration reloading
cmd_args = "-p 5432 -c \"SELECT pg_reload_conf();\""

# Directory to store certificates (must match with the ssl setings in postgresql.conf)
# Directory to store certificates (must match with the ssl settings in postgresql.conf)
cert_dir = "/opt/spire/certs/postgresql"

# No renew signal is used in this example
Expand Down
2 changes: 1 addition & 1 deletion pkg/disk/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestWriteJWTSVID(t *testing.T) {
err = WriteJWTSVID(jwtSVID, tempDir, jwtSVIDFilename, jwtSVIDFileMode)
require.NoError(t, err)

// Read back and check its the same
// Read back and check it's the same
actualToken, err := os.ReadFile(path.Join(tempDir, jwtSVIDFilename))
require.NoError(t, err)
require.Equal(t, token, string(actualToken))
Expand Down
6 changes: 3 additions & 3 deletions pkg/sidecar/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type Config struct {
// If true, merge intermediate certificates into Bundle file instead of SVID file.
// This is the exptected format for MySQL and some other applications.
// This is the expected format for MySQL and some other applications.
AddIntermediatesToBundle bool

// The address of the Agent Workload API.
Expand All @@ -23,7 +23,7 @@ type Config struct {
// The directory name to store the x509s and/or JWTs.
CertDir string

// If true, fetche x509 certificate and then exit(0).
// If true, fetches x509 certificate and then exit(0).
ExitWhenReady bool

// Permissions to use when writing x509 SVID to disk
Expand All @@ -41,7 +41,7 @@ type Config struct {
// If true, includes trust domains from federated servers in the CA bundle.
IncludeFederatedDomains bool

// An array with the audience and file name to store the JWT SVIDs. File is Base64-encoded string).
// An array with the audience and file name to store the JWT SVIDs. File is Base64-encoded string.
JWTSVIDs []JWTConfig

// File name to be used to store JWT Bundle in JSON format.
Expand Down
10 changes: 5 additions & 5 deletions pkg/sidecar/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ func (s *Sidecar) CertReadyChan() <-chan struct{} {

func (s *Sidecar) setupClients(ctx context.Context) error {
if s.x509Enabled() || s.jwtBundleEnabled() {
client, err := workloadapi.New(ctx, s.getWorkloadAPIAdress())
client, err := workloadapi.New(ctx, s.getWorkloadAPIAddress())
if err != nil {
return err
}
s.client = client
}

if s.jwtSVIDsEnabled() {
jwtSource, err := workloadapi.NewJWTSource(ctx, workloadapi.WithClientOptions(s.getWorkloadAPIAdress()))
jwtSource, err := workloadapi.NewJWTSource(ctx, workloadapi.WithClientOptions(s.getWorkloadAPIAddress()))
if err != nil {
return err
}
Expand Down Expand Up @@ -364,12 +364,12 @@ func getCmdArgs(args string) ([]string, error) {
return cmdArgs, nil
}

// JWTBundleWatcher is an implementation of workload.JWTBundleWatcher interface
// JWTBundlesWatcher is an implementation of workload.JWTBundleWatcher interface
type JWTBundlesWatcher struct {
sidecar *Sidecar
}

// OnJWTBundlesUpdate is ran every time a bundle is updated
// OnJWTBundlesUpdate is run every time a bundle is updated
func (w JWTBundlesWatcher) OnJWTBundlesUpdate(jwkSet *jwtbundle.Set) {
w.sidecar.config.Log.Debug("Updating JWT bundle")
if err := disk.WriteJWTBundleSet(jwkSet, w.sidecar.config.CertDir, w.sidecar.config.JWTBundleFilename, w.sidecar.config.JWTBundleFileMode); err != nil {
Expand All @@ -380,7 +380,7 @@ func (w JWTBundlesWatcher) OnJWTBundlesUpdate(jwkSet *jwtbundle.Set) {
w.sidecar.config.Log.Info("JWT bundle updated")
}

// OnJWTBundlesWatchError is ran when the client runs into an error
// OnJWTBundlesWatchError is run when the client runs into an error
func (w JWTBundlesWatcher) OnJWTBundlesWatchError(err error) {
if status.Code(err) != codes.Canceled {
w.sidecar.config.Log.Errorf("Error while watching JWT bundles: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sidecar/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestSidecar_RunDaemon(t *testing.T) {
svidChainWithIntermediate, svidKeyWithIntermediate := domain1Inter.CreateX509SVID(spiffeIDWithIntermediate.String())
require.Len(t, svidChainWithIntermediate, 2)

// Add cert with intermediate into an svid
// Add cert with intermediate into a svid
svidWithIntermediate := []*x509svid.SVID{
{
ID: spiffeIDWithIntermediate,
Expand Down
2 changes: 1 addition & 1 deletion pkg/sidecar/util_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"golang.org/x/sys/unix"
)

func (s *Sidecar) getWorkloadAPIAdress() workloadapi.ClientOption {
func (s *Sidecar) getWorkloadAPIAddress() workloadapi.ClientOption {
return workloadapi.WithAddr("unix://" + s.config.AgentAddress)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sidecar/util_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/spiffe/go-spiffe/v2/workloadapi"
)

func (s *Sidecar) getWorkloadAPIAdress() workloadapi.ClientOption {
func (s *Sidecar) getWorkloadAPIAddress() workloadapi.ClientOption {
return workloadapi.WithNamedPipeName(s.config.AgentAddress)
}

Expand Down
4 changes: 2 additions & 2 deletions test/util/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func LoadCertificates(path string) ([]*x509.Certificate, error) {
}

var certs []*x509.Certificate
for blockno := 0; ; blockno++ {
for blockNumber := 0; ; blockNumber++ {
var block *pem.Block
block, rest = pem.Decode(rest)
if block == nil {
Expand All @@ -46,7 +46,7 @@ func LoadCertificates(path string) ([]*x509.Certificate, error) {

cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return nil, fmt.Errorf("unable to parse certificate in block %d: %w", blockno, err)
return nil, fmt.Errorf("unable to parse certificate in block %d: %w", blockNumber, err)
}
certs = append(certs, cert)
}
Expand Down

0 comments on commit cd08dc0

Please sign in to comment.