Sfoglia il codice sorgente

Merge pull request #525 from porter-dev/beta.3.avoid-webhook-clash

switch to hex encoding for subdomains
abelanger5 5 anni fa
parent
commit
712d691c58

+ 1 - 1
internal/kubernetes/domain/domain.go

@@ -68,7 +68,7 @@ type CreateDNSRecordConfig struct {
 // NewDNSRecordForEndpoint generates a random subdomain and returns a DNSRecord
 // model
 func (c *CreateDNSRecordConfig) NewDNSRecordForEndpoint() *models.DNSRecord {
-	suffix, _ := repository.GenerateRandomBytes(16)
+	suffix, _ := repository.GenerateRandomBytes(8)
 
 	subdomain := fmt.Sprintf("%s-%s", c.ReleaseName, suffix)
 

+ 2 - 2
internal/repository/encrypt.go

@@ -4,7 +4,7 @@ import (
 	"crypto/aes"
 	"crypto/cipher"
 	"crypto/rand"
-	"encoding/base64"
+	"encoding/hex"
 	"errors"
 	"io"
 )
@@ -32,7 +32,7 @@ func GenerateRandomBytes(n int) (string, error) {
 		return "", err
 	}
 
-	return base64.URLEncoding.EncodeToString(b), nil
+	return hex.EncodeToString(b), nil
 }
 
 // Encrypt encrypts data using 256-bit AES-GCM.  This both hides the content of

+ 1 - 1
server/api/user_handler.go

@@ -170,7 +170,7 @@ func (app *App) HandleCLILoginUser(w http.ResponseWriter, r *http.Request) {
 	}
 
 	// generate 64 characters long authorization code
-	code, err := repository.GenerateRandomBytes(64)
+	code, err := repository.GenerateRandomBytes(32)
 
 	if err != nil {
 		app.handleErrorInternal(err, w)