more golint cleanup

This commit is contained in:
Roland Osborne 2022-07-22 21:39:44 -07:00
parent d0145bb579
commit cee3975fbc
3 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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 {