diff --git a/net/server/internal/appValues.go b/net/server/internal/appValues.go index 019757af..9bcf7d44 100644 --- a/net/server/internal/appValues.go +++ b/net/server/internal/appValues.go @@ -138,6 +138,7 @@ const APPQueueDefault = "" //APPDefaultPath config for default path to store assets const APPDefaultPath = "./asset" +//AppCardStatus compares cards status with string func AppCardStatus(status string) bool { if status == APPCardPending { return true @@ -157,6 +158,7 @@ func AppCardStatus(status string) bool { return false } +//AppTopicStatus compares topic status with string func AppTopicStatus(status string) bool { if status == APPTopicConfirmed { return true diff --git a/net/server/internal/configUtil.go b/net/server/internal/configUtil.go index ed5a8e7b..1433626c 100644 --- a/net/server/internal/configUtil.go +++ b/net/server/internal/configUtil.go @@ -6,13 +6,28 @@ import ( "gorm.io/gorm" ) +//CNFOpenAccess for allowing for public account creation const CNFOpenAccess = "open_access" + +//CNFAccountLimit for limiting number of accounts for public creation const CNFAccountLimit = "account_limit" + +//CNFConfigured set when admin token has been set const CNFConfigured = "configured" + +//CNFToken identifies the admin token const CNFToken = "token" + +//CNFDomain identifies the configured server hostname const CNFDomain = "domain" + +//CNFStorage specifies the storage limit per account const CNFStorage = "storage" + +//CNFAssetPath specifies the path to store assets const CNFAssetPath = "asset_path" + +//CNFScriptPath specifies the path where transform scripts are found const CNFScriptPath = "script_path" func getStrConfigValue(configID string, empty string) string { diff --git a/net/server/internal/keyUtil.go b/net/server/internal/keyUtil.go index 629b65f3..4da24e64 100644 --- a/net/server/internal/keyUtil.go +++ b/net/server/internal/keyUtil.go @@ -10,10 +10,12 @@ import ( var keySize int = APPKeySize +//SetKeySize sets the key size to use for new accounts func SetKeySize(size int) { keySize = size } +//GenerateRsaKeyPair creates a public/private key for a new account func GenerateRsaKeyPair() (*rsa.PrivateKey, *rsa.PublicKey, string, error) { if keySize == 2048 { privkey, _ := rsa.GenerateKey(rand.Reader, keySize) @@ -26,6 +28,7 @@ func GenerateRsaKeyPair() (*rsa.PrivateKey, *rsa.PublicKey, string, error) { } } +//ExportRsaPrivateKeyAsPemString exports account private key func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string { privkeyBytes := x509.MarshalPKCS1PrivateKey(privkey) privkeyPEM := pem.EncodeToMemory( @@ -37,6 +40,7 @@ func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string { return string(privkeyPEM) } +//ParseRsaPrivateKeyFromPemStr loads account private key func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error) { block, _ := pem.Decode([]byte(privPEM)) if block == nil { @@ -51,6 +55,7 @@ func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error) { return priv, nil } +//ExportRsaPublicKeyAsPemStr exports account public key func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) (string, error) { pubkeyBytes, err := x509.MarshalPKIXPublicKey(pubkey) if err != nil { @@ -66,6 +71,7 @@ func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) (string, error) { return string(pubkeyPEM), nil } +//ParseRsaPublicKeyFromPemStr loads account public key func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error) { block, _ := pem.Decode([]byte(pubPEM)) if block == nil {