37 lines
738 B
Go
37 lines
738 B
Go
package auth
|
|
|
|
import (
|
|
"bufio"
|
|
"encoding/base64"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
"syscall"
|
|
|
|
"golang.org/x/term"
|
|
)
|
|
|
|
func GetHeader(guid string, password string) string {
|
|
b64 := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", guid, password)))
|
|
return fmt.Sprintf("Basic %s", b64)
|
|
}
|
|
|
|
func collect_uofg() (string, string, error) {
|
|
reader := bufio.NewReader(os.Stdin)
|
|
|
|
fmt.Print("Enter your GUID: ")
|
|
username, err := reader.ReadString('\n')
|
|
if err != nil {
|
|
return "", "", err
|
|
}
|
|
|
|
fmt.Print("Enter your password: ")
|
|
bytePassword, err := term.ReadPassword(int(syscall.Stdin))
|
|
if err != nil {
|
|
return "", "", err
|
|
}
|
|
|
|
password := string(bytePassword)
|
|
|
|
return strings.TrimSpace(username), strings.TrimSpace(password), nil
|
|
}
|