-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Embed application config instead of just mTLS (#6)
* embed application config instead of just mtls * override embedded config with file * update embedded config instructions in readme * bump version
- Loading branch information
1 parent
7657ec8
commit 7a143a5
Showing
16 changed files
with
224 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/markbates/pkger" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var ( | ||
EmbeddedConfigFile string // To be set by ldflags at compile time | ||
) | ||
|
||
// ReadEmbeddedConfig attempts to read the embedded mTLS config and create a tls.Config | ||
func ReadEmbeddedConfig() error { | ||
if EmbeddedConfigFile == "" { | ||
return EmbeddedConfigDisabledError | ||
} | ||
f, err := pkger.Open(EmbeddedConfigFile) | ||
if err != nil { | ||
return errors.Wrap(err, "could not open embedded config") | ||
} | ||
defer f.Close() | ||
|
||
err = viper.ReadConfig(f) | ||
if err != nil { | ||
return errors.Wrap(err, "could not read embedded config") | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package config | ||
|
||
type Error string | ||
|
||
func (e Error) Error() string { return string(e) } | ||
|
||
const ClientCertificatesNotFoundError = Error("could not find client certificates") | ||
const EmbeddedConfigDisabledError = Error("embedded config is disabled") | ||
const HomeDirectoryError = Error("could not resolve user's home directory") | ||
const MissingTLSConfigError = Error("missing required mTLS configuration") | ||
const UnsupportedOSError = Error("running on unsupported operating system") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
consoleme_url: https://path_to_consoleme:port | ||
authentication_method: mtls # challenge or mtls | ||
mtls_settings: | ||
cert: mtls.crt | ||
key: mtls.key | ||
cafile: mtlsCA.pem | ||
insecure: false | ||
darwin: # weep will look in platform-specific directories for the three files specified above | ||
- "/run/mtls/certificates" | ||
- "/mtls/certificates" | ||
- "$HOME/.mtls/certificates" | ||
- "$HOME/.mtls" | ||
linux: | ||
- "/run/mtls/certificates" | ||
- "/mtls/certificates" | ||
- "$HOME/.mtls/certificates" | ||
- "$HOME/.mtls" | ||
windows: | ||
- "C:\\run\\mtls\\certificates" | ||
- "C:\\mtls\\certificates" | ||
- "$HOME\\.mtls\\certificates" | ||
- "$HOME\\.mtls" | ||
metadata: | ||
routes: | ||
- path: latest/user-data | ||
- path: latest/meta-data/local-ipv4 | ||
data: "127.0.0.1" | ||
- path: latest/meta-data/local-hostname | ||
data: ip-127-0-0-1.us-west-2.compute.internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.