mirror of
https://github.com/rocky-linux/srpmproc.git
synced 2024-12-04 18:36:26 +00:00
enhancement: add http basic auth option
This commit is contained in:
parent
42c043f8d6
commit
985748b05d
@ -22,7 +22,7 @@ package data
|
||||
|
||||
import (
|
||||
"github.com/go-git/go-billy/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||
"github.com/rocky-linux/srpmproc/pkg/blob"
|
||||
)
|
||||
|
||||
@ -41,7 +41,7 @@ type ProcessData struct {
|
||||
ImportBranchPrefix string
|
||||
BranchPrefix string
|
||||
SingleTag string
|
||||
Authenticator *ssh.PublicKeys
|
||||
Authenticator transport.AuthMethod
|
||||
Importer ImportMode
|
||||
BlobStorage blob.Storage
|
||||
NoDupMode bool
|
||||
|
@ -24,6 +24,8 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/go-git/go-billy/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
|
||||
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
|
||||
"github.com/rocky-linux/srpmproc/pkg/blob"
|
||||
@ -70,6 +72,8 @@ type ProcessDataRequest struct {
|
||||
RpmPrefix string
|
||||
SshKeyLocation string
|
||||
SshUser string
|
||||
HttpUsername string
|
||||
HttpPassword string
|
||||
ManualCommits string
|
||||
UpstreamPrefix string
|
||||
GitCommitterName string
|
||||
@ -166,11 +170,18 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
|
||||
lastKeyLocation = filepath.Join(usr.HomeDir, ".ssh/id_rsa")
|
||||
}
|
||||
|
||||
var authenticator *ssh.PublicKeys
|
||||
var authenticator transport.AuthMethod
|
||||
|
||||
var err error
|
||||
// create ssh key authenticator
|
||||
authenticator, err = ssh.NewPublicKeysFromFile(req.SshUser, lastKeyLocation, "")
|
||||
if req.HttpUsername != "" {
|
||||
authenticator = &http.BasicAuth{
|
||||
Username: req.HttpUsername,
|
||||
Password: req.HttpPassword,
|
||||
}
|
||||
} else {
|
||||
// create ssh key authenticator
|
||||
authenticator, err = ssh.NewPublicKeysFromFile(req.SshUser, lastKeyLocation, "")
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("could not get git authenticator: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user