-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from nodeset-org/daemon-auth
Add support for daemon JWT authorization
- Loading branch information
Showing
18 changed files
with
161 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
|
||
csconfig "github.com/nodeset-org/hyperdrive-constellation/shared/config" | ||
"github.com/nodeset-org/hyperdrive-daemon/shared/auth" | ||
hdconfig "github.com/nodeset-org/hyperdrive-daemon/shared/config" | ||
swconfig "github.com/nodeset-org/hyperdrive-stakewise/shared/config" | ||
) | ||
|
||
var ( | ||
hdApiKeyRelPath string = filepath.Join(hdconfig.SecretsDir, hdconfig.DaemonKeyFilename) | ||
swApiKeyRelPath string = filepath.Join(hdconfig.SecretsDir, hdconfig.ModulesName, swconfig.ModuleName, hdconfig.DaemonKeyFilename) | ||
csApiKeyRelPath string = filepath.Join(hdconfig.SecretsDir, hdconfig.ModulesName, csconfig.ModuleName, hdconfig.DaemonKeyFilename) | ||
) | ||
|
||
// Create the metrics and modules folders, and deploy the config templates for Prometheus and Grafana | ||
func (c *HyperdriveClient) GenerateDaemonAuthKeys(config *GlobalConfig) error { | ||
// Create the API key for the Hyperdrive daemon | ||
hdApiKeyPath := filepath.Join(c.Context.UserDirPath, hdApiKeyRelPath) | ||
err := auth.GenerateAuthKeyIfNotPresent(hdApiKeyPath, auth.DefaultKeyLength) | ||
if err != nil { | ||
return fmt.Errorf("error generating Hyperdrive daemon API key: %w", err) | ||
} | ||
|
||
// Create the API key for the StakeWise module if enabled | ||
if config.StakeWise.Enabled.Value { | ||
swApiKeyPath := filepath.Join(c.Context.UserDirPath, swApiKeyRelPath) | ||
err = auth.GenerateAuthKeyIfNotPresent(swApiKeyPath, auth.DefaultKeyLength) | ||
if err != nil { | ||
return fmt.Errorf("error generating StakeWise module API key: %w", err) | ||
} | ||
} | ||
|
||
// Create the API key for the Constellation module if enabled | ||
if config.Constellation.Enabled.Value { | ||
csApiKeyPath := filepath.Join(c.Context.UserDirPath, csApiKeyRelPath) | ||
err = auth.GenerateAuthKeyIfNotPresent(csApiKeyPath, auth.DefaultKeyLength) | ||
if err != nil { | ||
return fmt.Errorf("error generating Constellation module API key: %w", err) | ||
} | ||
} | ||
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
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 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 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.