AUTH-3455: Generate short-lived ssh cert per hostname

This commit is contained in:
Michael Borkenstein
2021-03-24 16:31:02 -05:00
parent da4d0b2bae
commit 63833b07dd
4 changed files with 21 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ package token
import (
"fmt"
"net/url"
"os"
"path/filepath"
"strings"
@@ -11,6 +12,16 @@ import (
"github.com/cloudflare/cloudflared/config"
)
// GenerateSSHCertFilePathFromURL will return a file path for creating short lived certificates
func GenerateSSHCertFilePathFromURL(url *url.URL, 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)
return filepath.Join(configPath, name), nil
}
// GenerateAppTokenFilePathFromURL will return a filepath for given Access org token
func GenerateAppTokenFilePathFromURL(appDomain, aud string, suffix string) (string, error) {
configPath, err := getConfigPath()