Skip to content

Commit

Permalink
fix dump-proxy for users
Browse files Browse the repository at this point in the history
  • Loading branch information
dciangot committed Jun 11, 2020
1 parent ab248ed commit b1c4b93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ func main() {
log.Fatalf("Failed to map %s with token %s: %s", username, token, err.Error())
}
} else if dumpProxy {
if token == "" || username == "" {
log.Fatal("Please specify --username and --token")
if token == "" {
log.Fatal("Please specify the access token with --token")
}

err := tts.DumpProxy(username, token, credentials)
err := tts.DumpProxy(token, credentials)
if err != nil {
log.Fatalf("Error retrieving proxy: %s", err)
}
Expand Down
9 changes: 7 additions & 2 deletions pkg/v1/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"log"
"os"
"os/user"
"strings"

iam "github.com/dodas-ts/dodas-go-client/cmd"
Expand Down Expand Up @@ -81,7 +82,7 @@ func (c *TTSClient) MapUser(user string, accessToken string, kubeClientset *kube
}

// DumpProxy ..
func DumpProxy(user string, accessToken string, credentials string) error {
func DumpProxy(accessToken string, credentials string) error {

request := iam.Request{
URL: credentials,
Expand Down Expand Up @@ -121,9 +122,13 @@ func DumpProxy(user string, accessToken string, credentials string) error {
return fmt.Errorf("code %d: %s", statusCode, body)
}

currentUser, err := user.Current()
if err != nil {
return fmt.Errorf("Failed to retrieve current: %s", err)
}
key := "/tmp/user.key"
cert := "/tmp/user.cert"
dest := "/tmp/" + user + ".pem"
dest := "/tmp/userproxy_" + string(currentUser.Uid) + ".pem"

passwd := secrets["Passphrase"]

Expand Down

0 comments on commit b1c4b93

Please sign in to comment.