Skip to content

Commit 6f27ca1

Browse files
LDAP fix and cache clear fix
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
1 parent 498d598 commit 6f27ca1

1 file changed

Lines changed: 39 additions & 6 deletions

File tree

cla-backend-legacy/internal/api/handlers.go

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5323,6 +5323,8 @@ func (h *Handlers) GetProjectV2(w http.ResponseWriter, r *http.Request) {
53235323
}
53245324

53255325
projectDict := store.ItemToInterfaceMap(projItem)
5326+
projectExternalID := getAttrString(projItem, "project_external_id")
5327+
projectDict["logoUrl"] = fmt.Sprintf("%s/%s.png", os.Getenv("CLA_BUCKET_LOGO_URL"), projectExternalID)
53265328
delete(projectDict, "project_external_id")
53275329

53285330
// Remove document_tabs from all project document lists.
@@ -8915,14 +8917,27 @@ func (h *Handlers) RequestEmployeeSignatureV2(w http.ResponseWriter, r *http.Req
89158917

89168918
for _, gerrit := range gerrits {
89178919
groupID := strings.TrimSpace(getAttrString(gerrit, "group_id_ccla"))
8918-
if groupID == "" || h.lfGroup == nil {
8920+
if groupID == "" {
89198921
continue
89208922
}
8921-
res := h.lfGroup.AddUserToGroup(ctx, groupID, lfUsername)
8922-
if _, bad := res["error"]; bad {
8923-
logging.Warnf("request_employee_signature_gerrit add user to group failed group_id=%s user=%s result=%v", groupID, lfUsername, res)
8924-
respond.JSON(w, http.StatusOK, nil)
8925-
return
8923+
8924+
// LFGroup/LDAP membership updates are legacy best-effort side effects.
8925+
// Do not let a removed or unconfigured LFGroup service change the Gerrit
8926+
// acknowledgement response after the signature has already been saved.
8927+
lfGroupConfigured := h.lfGroup != nil &&
8928+
strings.TrimSpace(h.lfGroup.BaseURL) != "" &&
8929+
strings.TrimSpace(h.lfGroup.ClientID) != "" &&
8930+
strings.TrimSpace(h.lfGroup.ClientSecret) != "" &&
8931+
strings.TrimSpace(h.lfGroup.RefreshToken) != ""
8932+
if !lfGroupConfigured {
8933+
logging.Debugf("request_employee_signature_gerrit skipping legacy LFGroup update; LFGroup client not configured group_id=%s user=%s", groupID, lfUsername)
8934+
continue
8935+
}
8936+
8937+
if res := h.lfGroup.AddUserToGroup(ctx, groupID, lfUsername); res != nil {
8938+
if _, bad := res["error"]; bad {
8939+
logging.Warnf("request_employee_signature_gerrit ignored legacy LFGroup update failure group_id=%s user=%s result=%v", groupID, lfUsername, res)
8940+
}
89268941
}
89278942
}
89288943
} else {
@@ -10980,6 +10995,24 @@ func (h *Handlers) ClearCacheV2(w http.ResponseWriter, r *http.Request) {
1098010995
return
1098110996
}
1098210997
githublegacy.ClearCaches()
10998+
10999+
status, hdr, respBody, err := h.doRequestToV4(r.Context(), http.MethodPost, "/clear-cache", headerCloneForV4(r.Header), nil)
11000+
if err != nil {
11001+
respond.JSON(w, http.StatusBadGateway, map[string]any{"errors": map[string]any{"v4": err.Error()}})
11002+
return
11003+
}
11004+
if status >= 400 {
11005+
respond.JSON(w, http.StatusBadGateway, map[string]any{"errors": map[string]any{"v4": string(respBody)}})
11006+
return
11007+
}
11008+
11009+
copyV4ResponseHeaders(w, hdr)
11010+
if len(respBody) > 0 {
11011+
w.WriteHeader(status)
11012+
_, _ = w.Write(respBody)
11013+
return
11014+
}
11015+
1098311016
respond.JSON(w, http.StatusOK, map[string]string{"status": "OK"})
1098411017
}
1098511018

0 commit comments

Comments
 (0)