Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Identify accounts by their registered name

62576fa8157d431dcf2d360f3ebe481de77bda03 · Keenan Nemetz · 14d ago · parent 642e5994

Identify accounts by their registered name

Drop the internal account id and display name. Users, keys, passkeys,
invites, sessions, ACL entries, approvals, locks and CI records now all
use the registered name as the single identity.

The roster migrates in place: old id-keyed tables are rebuilt around the
name, and access-rule/lock references are rewritten through the same
mapping. Display-name editing and whoami --id are removed.

server/web/requests.go +9−16

@@ -42,14 +42,11 @@ func (w *Web) requestForm(r *http.Request, m *repo.Meta) requestFormData {
42 42 }
43 43 baseBranches := branches
44 44 headBranches := branches
45 accountID := w.accountID(r)
45 accountID := w.accountName(r)
46 46 acl, _ := m.ACL()
47 47 canOpen := acl != nil && accountID != "" && acl.CanOpenRequest(accountID)
48 48 if acl != nil && acl.RoleFor(accountID) == access.Contributor {
49 49 name := accountID
50 if w.Ident != nil {
51 name = w.Ident.Name(accountID)
52 }
53 50 headBranches = nil
54 51 for _, branch := range branches {
55 52 if access.IsContributorRef(name, "refs/heads/"+branch) {
@@ -191,7 +188,7 @@ func (w *Web) NewChangePage(rw http.ResponseWriter, r *http.Request) {
191 188 return
192 189 }
193 190 acl, err := m.ACL()
194 if err != nil || !acl.CanOpenRequest(pr.account.ID) {
191 if err != nil || !acl.CanOpenRequest(pr.account.Name) {
195 192 http.Error(rw, "you do not have permission to open change requests here", http.StatusForbidden)
196 193 return
197 194 }
@@ -212,7 +209,7 @@ func (w *Web) NewChangePage(rw http.ResponseWriter, r *http.Request) {
212 209 // which approvals currently apply.
213 210 type requestApproval struct {
214 211 metadata.Approval
215 // Name is the approver's current name; the file itself is keyed by account id.
212 // Name is the approver's account name; the file itself is keyed by that name.
216 213 Name string
217 214 // Current is false when the approval names a commit or base that is no longer
218 215 // what the request asks for, which is the normal state after a force-push.
@@ -326,15 +323,11 @@ func (w *Web) requestSidebar(r *http.Request, m *repo.Meta, req *metadata.Reques
326 323 approvals := make([]requestApproval, 0, len(req.Approvals))
327 324 current := 0
328 325 for _, a := range req.Approvals {
329 name := a.Principal
330 if w.Ident != nil {
331 name = w.Ident.Label(a.Principal)
332 }
333 326 c := a.Head == req.Head && a.Base == req.Base
334 327 if c {
335 328 current++
336 329 }
337 approvals = append(approvals, requestApproval{Approval: a, Name: name, Current: c})
330 approvals = append(approvals, requestApproval{Approval: a, Name: w.who(a.Principal), Current: c})
338 331 }
339 332 required := 0
340 333 if acl != nil {
@@ -357,16 +350,16 @@ func (w *Web) requestSidebar(r *http.Request, m *repo.Meta, req *metadata.Reques
357 350 })
358 351 }
359 352 }
360 canApprove := acl != nil && req.Open() && w.canApprove(r, acl, req.AuthorID)
353 canApprove := acl != nil && req.Open() && w.canApprove(r, acl, req.Author)
361 354 canClose := false
362 355 if pr := w.principal(r); pr != nil && acl != nil {
363 canClose = acl.CanTriage(pr.account.ID) || req.AuthorID == pr.account.ID
356 canClose = acl.CanTriage(pr.account.Name) || req.Author == pr.account.Name
364 357 }
365 358 var contributorCI *requestCI
366 359 if req.Open() {
367 360 if ref := w.pendingContributorCI(m, req.Head); ref != "" {
368 361 canAllow := false
369 if id := w.accountID(r); id != "" && acl != nil && acl.CanApprove(id) {
362 if id := w.accountName(r); id != "" && acl != nil && acl.CanApprove(id) {
370 363 canAllow = true
371 364 }
372 365 contributorCI = &requestCI{Ref: strings.TrimPrefix(ref, "refs/heads/"), CanAllow: canAllow}
@@ -598,7 +591,7 @@ func (w *Web) requestDiscussion(r *http.Request, m *repo.Meta, req *metadata.Req
598 591 func (w *Web) markRequestCommentActions(r *http.Request, m *repo.Meta, requestID string, comments []requestCommentView, canDiscuss bool) {
599 592 pr := w.principal(r)
600 593 acl, _ := m.ACL()
601 admin := pr != nil && acl != nil && acl.RoleFor(pr.account.ID).AtLeast(access.Admin)
594 admin := pr != nil && acl != nil && acl.RoleFor(pr.account.Name).AtLeast(access.Admin)
602 595 csrf := ""
603 596 if pr != nil {
604 597 csrf = pr.session.CSRF
@@ -645,7 +638,7 @@ func (w *Web) RequestCommentForm(rw http.ResponseWriter, r *http.Request) {
645 638 return
646 639 }
647 640 acl, err := m.ACL()
648 if err != nil || !acl.CanDiscuss(pr.account.ID) {
641 if err != nil || !acl.CanDiscuss(pr.account.Name) {
649 642 http.Error(rw, "you do not have permission to comment here", http.StatusForbidden)
650 643 return
651 644 }