Commit 10b19aab authored by Kim "BKC" Carlbäcker's avatar Kim "BKC" Carlbäcker

Authentication

parent 947d4d49
...@@ -5,7 +5,10 @@ import ( ...@@ -5,7 +5,10 @@ import (
"fmt" "fmt"
"os" "os"
"google.golang.org/grpc"
pb "gitlab.com/gitlab-org/gitaly-proto/go" pb "gitlab.com/gitlab-org/gitaly-proto/go"
"gitlab.com/gitlab-org/gitaly/auth"
"gitlab.com/gitlab-org/gitaly/client" "gitlab.com/gitlab-org/gitaly/client"
) )
...@@ -14,7 +17,12 @@ func ReceivePack(gitalyAddress string, request *pb.SSHReceivePackRequest) (int32 ...@@ -14,7 +17,12 @@ func ReceivePack(gitalyAddress string, request *pb.SSHReceivePackRequest) (int32
return -1, fmt.Errorf("no gitaly_address given") return -1, fmt.Errorf("no gitaly_address given")
} }
conn, err := client.Dial(gitalyAddress, client.DefaultDialOpts) connOpts := client.DefaultDialOpts
if token := os.Getenv("GITALY_TOKEN"); token != "" {
connOpts = append(client.DefaultDialOpts, grpc.WithPerRPCCredentials(gitalyauth.RPCCredentials(token)))
}
conn, err := client.Dial(gitalyAddress, connOpts)
if err != nil { if err != nil {
return -1, err return -1, err
} }
......
...@@ -5,7 +5,10 @@ import ( ...@@ -5,7 +5,10 @@ import (
"fmt" "fmt"
"os" "os"
"google.golang.org/grpc"
pb "gitlab.com/gitlab-org/gitaly-proto/go" pb "gitlab.com/gitlab-org/gitaly-proto/go"
"gitlab.com/gitlab-org/gitaly/auth"
"gitlab.com/gitlab-org/gitaly/client" "gitlab.com/gitlab-org/gitaly/client"
) )
...@@ -14,7 +17,12 @@ func UploadPack(gitalyAddress string, request *pb.SSHUploadPackRequest) (int32, ...@@ -14,7 +17,12 @@ func UploadPack(gitalyAddress string, request *pb.SSHUploadPackRequest) (int32,
return -1, fmt.Errorf("no gitaly_address given") return -1, fmt.Errorf("no gitaly_address given")
} }
conn, err := client.Dial(gitalyAddress, client.DefaultDialOpts) connOpts := client.DefaultDialOpts
if token := os.Getenv("GITALY_TOKEN"); token != "" {
connOpts = append(client.DefaultDialOpts, grpc.WithPerRPCCredentials(gitalyauth.RPCCredentials(token)))
}
conn, err := client.Dial(gitalyAddress, connOpts)
if err != nil { if err != nil {
return -1, err return -1, err
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment