Skip to content

Commit

Permalink
simply token generation; createToken+createServiceName (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Nov 28, 2022
1 parent ab627d1 commit ebb13ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.idea
*.db
automated-release-build
etc/dev.yml
17 changes: 3 additions & 14 deletions controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
"github.com/openziti/edge/rest_management_api_client"
"github.com/openziti/edge/rest_util"
"github.com/teris-io/shortid"
"net/http"
"strings"
)
Expand Down Expand Up @@ -44,10 +43,6 @@ func edgeClient() (*rest_management_api_client.ZitiEdgeManagement, error) {
return rest_util.NewEdgeManagementClientWithUpdb(cfg.Ziti.Username, cfg.Ziti.Password, cfg.Ziti.ApiEndpoint, caPool)
}

func createToken() (string, error) {
return shortid.Generate()
}

func createServiceName() (string, error) {
gen, err := nanoid.CustomASCII("abcdefghijklmnopqrstuvwxyz0123456789", 12)
if err != nil {
Expand All @@ -56,18 +51,12 @@ func createServiceName() (string, error) {
return gen(), nil
}

func dnsSafeShortId() (string, error) {
sid, err := shortid.Generate()
func createToken() (string, error) {
gen, err := nanoid.CustomASCII("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 12)
if err != nil {
return "", err
}
for sid[0] == '-' || sid[0] == '_' {
sid, err = shortid.Generate()
if err != nil {
return "", err
}
}
return sid, nil
return gen(), nil
}

func hashPassword(raw string) string {
Expand Down

0 comments on commit ebb13ac

Please sign in to comment.