AUTH-3394: Creates a token per app instead of per path

This commit is contained in:
Michael Borkenstein
2021-03-02 14:35:40 -06:00
parent 4296b23087
commit 8e340d9598
8 changed files with 129 additions and 83 deletions

View File

@@ -2,7 +2,6 @@ package token
import (
"fmt"
"net/url"
"os"
"path/filepath"
"strings"
@@ -13,12 +12,13 @@ import (
)
// GenerateAppTokenFilePathFromURL will return a filepath for given Access org token
func GenerateAppTokenFilePathFromURL(url *url.URL, suffix string) (string, error) {
func GenerateAppTokenFilePathFromURL(appDomain, aud string, suffix string) (string, error) {
configPath, err := getConfigPath()
if err != nil {
return "", err
}
name := strings.Replace(fmt.Sprintf("%s%s-%s", url.Hostname(), url.EscapedPath(), suffix), "/", "-", -1)
name := fmt.Sprintf("%s-%s-%s", appDomain, aud, suffix)
name = strings.Replace(strings.Replace(name, "/", "-", -1), "*", "-", -1)
return filepath.Join(configPath, name), nil
}