Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit e716c29

Browse files
authored
Air-gapped mode (#926)
1 parent 1f434d4 commit e716c29

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

quesma/licensing/runner.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
package licensing
44

55
import (
6+
"crypto/sha256"
7+
"encoding/hex"
68
"fmt"
79
"github.com/google/uuid"
810
"github.com/rs/zerolog"
@@ -19,14 +21,33 @@ type LicenseModule struct {
1921
}
2022

2123
const (
22-
installationIdFile = ".installation_id"
24+
installationIdFile = ".installation_id"
25+
quesmaAirGapModeEnvVar = "QUESMA_AIRGAP_KEY"
2326
)
2427

28+
func isAirgapKeyValid(key string) bool {
29+
hasher := sha256.New()
30+
hasher.Write([]byte(key))
31+
keyHash := hex.EncodeToString(hasher.Sum(nil))
32+
return keyHash == "78b14371a310f4e4f7e6c19a444f771bbe5d2c4f2154715191334bcf58420435"
33+
}
34+
2535
func Init(config *config.QuesmaConfiguration) *LicenseModule {
2636
l := &LicenseModule{
2737
Config: config,
2838
LicenseKey: []byte(config.LicenseKey),
2939
}
40+
if airgapKey, isSet := os.LookupEnv(quesmaAirGapModeEnvVar); isSet {
41+
if isAirgapKeyValid(airgapKey) {
42+
l.logInfo("Running Quesma in airgapped mode")
43+
l.License = &License{
44+
InstallationID: "air-gapped-installation-id",
45+
ClientID: "air-gapped-client-id",
46+
}
47+
return l
48+
}
49+
}
50+
l.logInfo("Initializing license module")
3051
l.Run()
3152
return l
3253
}

0 commit comments

Comments
 (0)