Skip to content

Commit

Permalink
feat: adds support for wireless profiles in export
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-primrose committed Oct 3, 2024
1 parent 4365a54 commit 2fd317d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 21 deletions.
39 changes: 27 additions & 12 deletions pkg/config/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,38 @@ type Network struct {
}

type Wired struct {
DHCPEnabled bool `yaml:"dhcpEnabled"`
IPSyncEnabled bool `yaml:"ipSyncEnabled"`
SharedStaticIP bool `yaml:"sharedStaticIP"`
IPAddress string `yaml:"ipAddress"`
SubnetMask string `yaml:"subnetMask"`
DefaultGateway string `yaml:"defaultGateway"`
PrimaryDNS string `yaml:"primaryDNS"`
SecondaryDNS string `yaml:"secondaryDNS"`
Authentication string `yaml:"authentication"`
DHCPEnabled bool `yaml:"dhcpEnabled"`
IPSyncEnabled bool `yaml:"ipSyncEnabled"`
SharedStaticIP bool `yaml:"sharedStaticIP"`
IPAddress string `yaml:"ipAddress"`
SubnetMask string `yaml:"subnetMask"`
DefaultGateway string `yaml:"defaultGateway"`
PrimaryDNS string `yaml:"primaryDNS"`
SecondaryDNS string `yaml:"secondaryDNS"`
Authentication string `yaml:"authentication"`
IEEE8021x IEEE8021x `yaml:"ieee8021x"`
}

type Wireless struct {
Profiles []string `yaml:"profiles"`
Profiles []WirelessProfile `yaml:"profiles"`
}

type Authentication struct {
Profiles []string `yaml:"profiles"`
type WirelessProfile struct {
SSID string `yaml:"ssid"`
Password string `yaml:"password"`
AuthenticationMethod string `yaml:"authenticationMethod"`
EncryptionMethod string `yaml:"encryptionMethod"`
Priority int `yaml:"priority"`
IEEE8021x IEEE8021x `yaml:"ieee8021x"`
}

type IEEE8021x struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
AuthenticationProtocol int `yaml:"authenticationProtocol"`
ClientCert string `yaml:"clientCert"`
CACert string `yaml:"caCert"`
PrivateKey string `yaml:"privateKey"`
}

type TLS struct {
Expand Down
19 changes: 18 additions & 1 deletion pkg/security/decrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,24 @@ var (
Authentication: "",
},
Wireless: config.Wireless{
Profiles: []string{},
Profiles: []config.WirelessProfile{
{
SSID: "SSID",
Password: "Password",
AuthenticationMethod: "WPA3 SAE",
EncryptionMethod: "CCMP",
Priority: 1,
IEEE8021x: config.IEEE8021x{
ProfileName: "",
AuthenticationProtocol: 0,
Username: "",
Password: "",
ClientCert: "",
PrivateKey: "",
CACert: "",
},
},
},
},
},
Authentication: config.Authentication{
Expand Down
14 changes: 9 additions & 5 deletions pkg/security/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

// Storage struct to hold the service name and keyring interface

// NewStorage function to create a new Storage instance with a keyring interface (for testing)
// NewStorage function to create a new Storage instance with a keyring interface (for testing).
func NewStorage(serviceName string, kr Keyring) Storage {
return Storage{
ServiceName: serviceName,
Expand All @@ -21,39 +21,43 @@ func NewKeyRingStorage(serviceName string) Storage {
}
}

// SetKeyValue method to set a key-value pair in the keyring
// SetKeyValue method to set a key-value pair in the keyring.
func (s Storage) SetKeyValue(key, value string) error {
err := s.Keyring.Set(s.ServiceName, keyring.Item{
Key: key,
Data: []byte(value),
})

return err
}

// GetKeyValue method to get a value from the keyring by key
// GetKeyValue method to get a value from the keyring by key.
func (s Storage) GetKeyValue(key string) (string, error) {
data, err := s.Keyring.Get(s.ServiceName, key)

return string(data.Data), err
}

// Set method to set a key-value pair in the real keyring
// Set method to set a key-value pair in the real keyring.
func (r RealKeyring) Set(serviceName string, item keyring.Item) error {
kr, err := keyring.Open(keyring.Config{
ServiceName: serviceName,
})
if err != nil {
return err
}

return kr.Set(item)
}

// Get method to get a value from the real keyring by key
// Get method to get a value from the real keyring by key.
func (r RealKeyring) Get(serviceName, key string) (keyring.Item, error) {
kr, err := keyring.Open(keyring.Config{
ServiceName: serviceName,
})
if err != nil {
return keyring.Item{}, err
}

return kr.Get(key)
}
2 changes: 1 addition & 1 deletion pkg/security/testing/encryptedConfig.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
AAAAAAAAAAAAAAAACCK0c+Szra0BnRFT6juBsoI79nMUrqw6WxhxebiLr9T0fTuO2p8mDgjmEFl55xYL+RzFLZYK0U5BsXML9UgG/Gy8suVzTJLnwDXn5wbxk3qygvQdEpjvCuTuvzjMIJuiZPqhRY/egujIVNG24YEpbyAKkqKMUgRR7v4xHyrzfiwISxej0BO9yvPtVncGV1BXwZAUrEp42lEVVmpxqaW+HkEx0He3uhS8GtbfFgErI0V6lij+DbbWOOGC6+fuF2G7CaOiAPxD779bbBttxt53ceB+cZKKhjJxgVeCjBlFsKmJ/xdmcg+sZwMZnxPzIf8S5W92prKgeMh4t56EC5BIMxsgobB/S4YKsD7aAsnzbBsPmCkQvKUAsqaD5c9eDZZF8KX/TSfk4rWtzW/hq+B5ZUX9IAzjrFsLm49YiDXxHdLyZtFL99WTMdwx8yIhJntJSDvGurYcNCFRhUDgNoghYWZ8yyuUxi1OcQRSDaduqFW7QqT9QZV0nPgH6fsrMog1iR/ZuhtKAK7Uc4Kbdl/F/U2kpL5vMbq/7AeTd4VaCxpVrCjwljjRvEhbeAtoyZaQBuA4VAmEJyPghF8w1TG50gvXcYnG469hIxVnSAGxbSriXi/K2JjRgg/FQAAWiz4YeAMdXFPk8X1C2sueVQ1hbE58HDHL6EvLtpsap28IsWvEOnBKy8wA0N7J+PeBhHbbAnj3sDgJy8Xf/wra7mG9HAxoh9lA3+pyeXIp9Z3mwxCRQSpdJnGOCwg8JUNYuWgTQ7sW2ImkB0Fyg6DVIJqUesKeFJYWRnNBae2yqpINqXRm3pokeHWOd2/89BSbwXh6vwBnpYR1+pOsP6FxWYe5OKniDHLQSyd7bKpQ9TZob8/SPXgYQwB1Dc3P2AzjrTYJ1TQrojwQMEXT2DvBPKBP0BQEAcgEBmn0SQNTXulTsnf0LQg5YgFtgYOZmiJdSY8+bghlnvrflpom4iTqloR+oRZ0tjY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JCvVvTd2cghpOs3TrDGnKF8s/QGp2DlBejahy5dIkbXnuxXD7MdXZ+gznZMdiAlTQwfMwQbBKSKkGJZmyKNRIK37I+w3ahSYbS28Q5O+0+iA8yv7+vQupgw4WCvsiYhOinUontiz3o1GgpQD6TM8pPt9LGifRtC9A9I1aydO+bTvGYOfLQfnWoT9s1tr6HE+8KqJdjJ6UnOCsm/Bef+3moiYcZGDJO7rcRXniNobByHDHOVjwBBqI9MUWWKuOyyh22MVeVQZ/41ZJVT21kmUGvWNlBkGmlacj+BfShEBU+HNbPRk30vgpMji0cU6TTmUBpxXi0iPhJVZ6lbxza5VnlluVv78YliCqem6fKUhRJC4ShESLVmIFneYnhIfFPNJfC87MX8N9ZUw7Uy/iHQ8t2Ay2AsDF9hZ5GQTsHtRWNBnM8bGXN8Cnuv07KqZl4jBZnhSVZSKsOI7OCCPbkoa8JQK/XbVQKWVEmHhTXP043lTcmoGzg0HHg2j7+L0HX8dyKTuHNJJSeB2kYubJZT8sKOqwj1/hDT4YoHGJZBfJldCzQhjOHMsr6oVKf2QrQiN3bMF2ZloNcyhN3IrF5h6v8Ys1DJyENIpV2zyBd88EDIT4tY3iDhDbcPLAYl4yB9Ye4s5w80bWrSQu8KJ2n7pzzoYR/SaPFo+CVDRZu60hj7kYuz82sHWepA4a8aA4LAMko=
3 changes: 1 addition & 2 deletions pkg/security/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ type Keyring interface {
}

// RealKeyring struct to implement the Keyring interface using the real keyring package.
type RealKeyring struct {
}
type RealKeyring struct{}

0 comments on commit 2fd317d

Please sign in to comment.