summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2020-11-20 10:59:19 +1100
committerAsh McKenzie <amckenzie@gitlab.com>2020-11-20 10:59:19 +1100
commit97bb3321f711a21a33d1b9e1f3975654e23660b4 (patch)
tree61bc3e7e8dc33eba38da983e58a4ef0ddd750c23
parentf558aa505cb2803cc0680e9176f1e78b1f1a711a (diff)
downloadgitlab-shell-97bb3321f711a21a33d1b9e1f3975654e23660b4.tar.gz
Include key ID and type in metadata
-rw-r--r--internal/handler/exec.go3
-rw-r--r--internal/handler/exec_test.go6
2 files changed, 8 insertions, 1 deletions
diff --git a/internal/handler/exec.go b/internal/handler/exec.go
index fdf3810..5ead63e 100644
--- a/internal/handler/exec.go
+++ b/internal/handler/exec.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
+ "strconv"
"strings"
log "github.com/sirupsen/logrus"
@@ -73,6 +74,8 @@ func (gc *GitalyCommand) PrepareContext(ctx context.Context, repository *pb.Repo
if !ok {
md = metadata.New(nil)
}
+ md.Append("key_id", strconv.Itoa(response.KeyId))
+ md.Append("key_type", response.KeyType)
md.Append("user_id", response.UserId)
md.Append("username", response.Username)
md.Append("remote_ip", sshenv.LocalAddr())
diff --git a/internal/handler/exec_test.go b/internal/handler/exec_test.go
index 89f2526..0dbd538 100644
--- a/internal/handler/exec_test.go
+++ b/internal/handler/exec_test.go
@@ -112,13 +112,17 @@ func TestPrepareContext(t *testing.T) {
GlProjectPath: "group/private",
},
response: &accessverifier.Response{
+ KeyId: 1,
+ KeyType: "key",
UserId: "6",
Username: "jane.doe",
},
want: map[string]string{
- "remote_ip": "10.0.0.1",
+ "key_id": "1",
+ "key_type": "key",
"user_id": "6",
"username": "jane.doe",
+ "remote_ip": "10.0.0.1",
},
},
}