Identity: extend k8s user.Info (#90937)

This commit is contained in:
Ryan McKinley
2024-07-30 08:27:23 +03:00
committed by GitHub
parent efda5a3ef2
commit 728150bdbd
26 changed files with 214 additions and 106 deletions
+8 -4
View File
@@ -140,7 +140,8 @@ func (hs *HTTPServer) PostAnnotation(c *contextmodel.ReqContext) response.Respon
return response.Error(http.StatusBadRequest, "Failed to save annotation", err)
}
userID, err := c.SignedInUser.GetID().UserID()
// nolint:staticcheck
userID, err := c.SignedInUser.GetInternalID()
if err != nil {
return response.Error(http.StatusInternalServerError, "Failed to save annotation", err)
}
@@ -227,7 +228,8 @@ func (hs *HTTPServer) PostGraphiteAnnotation(c *contextmodel.ReqContext) respons
return response.Error(http.StatusBadRequest, "Failed to save Graphite annotation", err)
}
userID, err := c.SignedInUser.GetID().UserID()
// nolint:staticcheck
userID, err := c.SignedInUser.GetInternalID()
if err != nil {
return response.Error(http.StatusInternalServerError, "Failed to save Graphite annotation", err)
}
@@ -284,7 +286,8 @@ func (hs *HTTPServer) UpdateAnnotation(c *contextmodel.ReqContext) response.Resp
}
}
userID, err := c.SignedInUser.GetID().UserID()
// nolint:staticcheck
userID, err := c.SignedInUser.GetInternalID()
if err != nil {
return response.Error(http.StatusInternalServerError, "Failed to update annotation", err)
}
@@ -346,7 +349,8 @@ func (hs *HTTPServer) PatchAnnotation(c *contextmodel.ReqContext) response.Respo
}
}
userID, err := c.SignedInUser.GetID().UserID()
// nolint:staticcheck
userID, err := c.SignedInUser.GetInternalID()
if err != nil {
return response.Error(http.StatusInternalServerError, "Failed to update annotation", err)
}
+2 -1
View File
@@ -586,7 +586,8 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
&contextmodel.ReqContext{
SignedInUser: &user.SignedInUser{
Login: "test_user",
NamespacedID: identity.MustParseTypedID("user:1"),
FallbackType: identity.TypeUser,
UserID: 1,
},
},
&setting.Cfg{SendUserHeader: true},
+2 -1
View File
@@ -79,7 +79,8 @@ func TestPluginProxy(t *testing.T) {
&contextmodel.ReqContext{
SignedInUser: &user.SignedInUser{
Login: "test_user",
NamespacedID: identity.MustParseTypedID("user:1"),
FallbackType: identity.TypeUser,
UserID: 1,
},
Context: &web.Context{
Req: httpReq,