summaryrefslogtreecommitdiff
path: root/credentials.go
diff options
context:
space:
mode:
Diffstat (limited to 'credentials.go')
-rw-r--r--credentials.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/credentials.go b/credentials.go
index 843c6b2..273de2f 100644
--- a/credentials.go
+++ b/credentials.go
@@ -11,6 +11,7 @@ void _go_git_populate_credential_ssh_custom(git_credential_ssh_custom *cred);
import "C"
import (
"crypto/rand"
+ "errors"
"fmt"
"runtime"
"strings"
@@ -106,6 +107,19 @@ func (o *Credential) Free() {
o.ptr = nil
}
+// GetUserpassPlaintext returns the plaintext username/password combination stored in the Cred.
+func (o *Credential) GetUserpassPlaintext() (username, password string, err error) {
+ if o.Type() != CredentialTypeUserpassPlaintext {
+ err = errors.New("credential is not userpass plaintext")
+ return
+ }
+
+ plaintextCredPtr := (*C.git_cred_userpass_plaintext)(unsafe.Pointer(o.ptr))
+ username = C.GoString(plaintextCredPtr.username)
+ password = C.GoString(plaintextCredPtr.password)
+ return
+}
+
func NewCredentialUsername(username string) (*Credential, error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()