mirror of
https://github.com/balzack/databag.git
synced 2025-02-15 21:19:16 +00:00
more golint cleanup
This commit is contained in:
parent
d0145bb579
commit
cee3975fbc
@ -138,6 +138,7 @@ const APPQueueDefault = ""
|
|||||||
//APPDefaultPath config for default path to store assets
|
//APPDefaultPath config for default path to store assets
|
||||||
const APPDefaultPath = "./asset"
|
const APPDefaultPath = "./asset"
|
||||||
|
|
||||||
|
//AppCardStatus compares cards status with string
|
||||||
func AppCardStatus(status string) bool {
|
func AppCardStatus(status string) bool {
|
||||||
if status == APPCardPending {
|
if status == APPCardPending {
|
||||||
return true
|
return true
|
||||||
@ -157,6 +158,7 @@ func AppCardStatus(status string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//AppTopicStatus compares topic status with string
|
||||||
func AppTopicStatus(status string) bool {
|
func AppTopicStatus(status string) bool {
|
||||||
if status == APPTopicConfirmed {
|
if status == APPTopicConfirmed {
|
||||||
return true
|
return true
|
||||||
|
@ -6,13 +6,28 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//CNFOpenAccess for allowing for public account creation
|
||||||
const CNFOpenAccess = "open_access"
|
const CNFOpenAccess = "open_access"
|
||||||
|
|
||||||
|
//CNFAccountLimit for limiting number of accounts for public creation
|
||||||
const CNFAccountLimit = "account_limit"
|
const CNFAccountLimit = "account_limit"
|
||||||
|
|
||||||
|
//CNFConfigured set when admin token has been set
|
||||||
const CNFConfigured = "configured"
|
const CNFConfigured = "configured"
|
||||||
|
|
||||||
|
//CNFToken identifies the admin token
|
||||||
const CNFToken = "token"
|
const CNFToken = "token"
|
||||||
|
|
||||||
|
//CNFDomain identifies the configured server hostname
|
||||||
const CNFDomain = "domain"
|
const CNFDomain = "domain"
|
||||||
|
|
||||||
|
//CNFStorage specifies the storage limit per account
|
||||||
const CNFStorage = "storage"
|
const CNFStorage = "storage"
|
||||||
|
|
||||||
|
//CNFAssetPath specifies the path to store assets
|
||||||
const CNFAssetPath = "asset_path"
|
const CNFAssetPath = "asset_path"
|
||||||
|
|
||||||
|
//CNFScriptPath specifies the path where transform scripts are found
|
||||||
const CNFScriptPath = "script_path"
|
const CNFScriptPath = "script_path"
|
||||||
|
|
||||||
func getStrConfigValue(configID string, empty string) string {
|
func getStrConfigValue(configID string, empty string) string {
|
||||||
|
@ -10,10 +10,12 @@ import (
|
|||||||
|
|
||||||
var keySize int = APPKeySize
|
var keySize int = APPKeySize
|
||||||
|
|
||||||
|
//SetKeySize sets the key size to use for new accounts
|
||||||
func SetKeySize(size int) {
|
func SetKeySize(size int) {
|
||||||
keySize = size
|
keySize = size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GenerateRsaKeyPair creates a public/private key for a new account
|
||||||
func GenerateRsaKeyPair() (*rsa.PrivateKey, *rsa.PublicKey, string, error) {
|
func GenerateRsaKeyPair() (*rsa.PrivateKey, *rsa.PublicKey, string, error) {
|
||||||
if keySize == 2048 {
|
if keySize == 2048 {
|
||||||
privkey, _ := rsa.GenerateKey(rand.Reader, keySize)
|
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 {
|
func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string {
|
||||||
privkeyBytes := x509.MarshalPKCS1PrivateKey(privkey)
|
privkeyBytes := x509.MarshalPKCS1PrivateKey(privkey)
|
||||||
privkeyPEM := pem.EncodeToMemory(
|
privkeyPEM := pem.EncodeToMemory(
|
||||||
@ -37,6 +40,7 @@ func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string {
|
|||||||
return string(privkeyPEM)
|
return string(privkeyPEM)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ParseRsaPrivateKeyFromPemStr loads account private key
|
||||||
func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error) {
|
func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error) {
|
||||||
block, _ := pem.Decode([]byte(privPEM))
|
block, _ := pem.Decode([]byte(privPEM))
|
||||||
if block == nil {
|
if block == nil {
|
||||||
@ -51,6 +55,7 @@ func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error) {
|
|||||||
return priv, nil
|
return priv, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ExportRsaPublicKeyAsPemStr exports account public key
|
||||||
func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) (string, error) {
|
func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) (string, error) {
|
||||||
pubkeyBytes, err := x509.MarshalPKIXPublicKey(pubkey)
|
pubkeyBytes, err := x509.MarshalPKIXPublicKey(pubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -66,6 +71,7 @@ func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) (string, error) {
|
|||||||
return string(pubkeyPEM), nil
|
return string(pubkeyPEM), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ParseRsaPublicKeyFromPemStr loads account public key
|
||||||
func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error) {
|
func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error) {
|
||||||
block, _ := pem.Decode([]byte(pubPEM))
|
block, _ := pem.Decode([]byte(pubPEM))
|
||||||
if block == nil {
|
if block == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user