diff --git a/src/audit.go b/src/audit.go index 13c4fc0..de0813e 100644 --- a/src/audit.go +++ b/src/audit.go @@ -111,6 +111,9 @@ func (record *AuditRecord) DescribePrincipal() string { record.Principal.GetForgeUser().GetHandle(), record.Principal.GetForgeUser().GetId())) } + if record.Principal.GetRepoUrl() != "" { + items = append(items, record.Principal.GetRepoUrl()) + } if record.Principal.GetCliAdmin() { items = append(items, "") } diff --git a/src/pages.go b/src/pages.go index 2624e84..28ecb4e 100644 --- a/src/pages.go +++ b/src/pages.go @@ -65,6 +65,17 @@ func observeSiteUpdate(via string, result *UpdateResult) { } } +func copyForgeAuthToPrincipal(principal *Principal, auth *Authorization) { + if auth.forgeUser != nil { + principal.ForgeUser = auth.forgeUser + } + + repoURL := auth.ForgeRepoURL() + if repoURL != "" { + principal.RepoUrl = &repoURL + } +} + func normalizeHost(host string) string { return strings.ToLower(host) } @@ -526,10 +537,11 @@ func putPage(w http.ResponseWriter, r *http.Request) error { auth, err := AuthorizeUpdateFromArchive(r) if err != nil { return err - } else if auth.forgeUser != nil { - GetPrincipal(r.Context()).ForgeUser = auth.forgeUser } + principal := GetPrincipal(r.Context()) + copyForgeAuthToPrincipal(principal, auth) + repoURL := auth.ForgeRepoURL() if checkDryRun(w, r) { @@ -559,12 +571,14 @@ func patchPage(w http.ResponseWriter, r *http.Request) error { return err } - if auth, err := AuthorizeUpdateFromArchive(r); err != nil { + auth, err := AuthorizeUpdateFromArchive(r) + if err != nil { return err - } else if auth.forgeUser != nil { - GetPrincipal(r.Context()).ForgeUser = auth.forgeUser } + principal := GetPrincipal(r.Context()) + copyForgeAuthToPrincipal(principal, auth) + if checkDryRun(w, r) { return nil } @@ -691,12 +705,14 @@ func deletePage(w http.ResponseWriter, r *http.Request) error { return err } - if auth, err := AuthorizeDeletion(r); err != nil { + auth, err := AuthorizeDeletion(r) + if err != nil { return err - } else if auth.forgeUser != nil { - GetPrincipal(r.Context()).ForgeUser = auth.forgeUser } + principal := GetPrincipal(r.Context()) + copyForgeAuthToPrincipal(principal, auth) + if checkDryRun(w, r) { return nil } diff --git a/src/schema.pb.go b/src/schema.pb.go index bf8fb04..8d5d470 100644 --- a/src/schema.pb.go +++ b/src/schema.pb.go @@ -863,6 +863,7 @@ type Principal struct { IpAddress *string `protobuf:"bytes,1,opt,name=ip_address,json=ipAddress" json:"ip_address,omitempty"` CliAdmin *bool `protobuf:"varint,2,opt,name=cli_admin,json=cliAdmin" json:"cli_admin,omitempty"` ForgeUser *ForgeUser `protobuf:"bytes,3,opt,name=forge_user,json=forgeUser" json:"forge_user,omitempty"` + RepoUrl *string `protobuf:"bytes,4,opt,name=repo_url,json=repoUrl" json:"repo_url,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -918,6 +919,13 @@ func (x *Principal) GetForgeUser() *ForgeUser { return nil } +func (x *Principal) GetRepoUrl() string { + if x != nil && x.RepoUrl != nil { + return *x.RepoUrl + } + return "" +} + type ForgeUser struct { state protoimpl.MessageState `protogen:"open.v1"` Origin *string `protobuf:"bytes,1,opt,name=origin" json:"origin,omitempty"` @@ -1041,14 +1049,15 @@ const file_schema_proto_rawDesc = "" + "\x06domain\x18\n" + " \x01(\tR\x06domain\x12\x18\n" + "\aproject\x18\v \x01(\tR\aproject\x12%\n" + - "\bmanifest\x18\f \x01(\v2\t.ManifestR\bmanifest\"r\n" + + "\bmanifest\x18\f \x01(\v2\t.ManifestR\bmanifest\"\x8d\x01\n" + "\tPrincipal\x12\x1d\n" + "\n" + "ip_address\x18\x01 \x01(\tR\tipAddress\x12\x1b\n" + "\tcli_admin\x18\x02 \x01(\bR\bcliAdmin\x12)\n" + "\n" + "forge_user\x18\x03 \x01(\v2\n" + - ".ForgeUserR\tforgeUser\"K\n" + + ".ForgeUserR\tforgeUser\x12\x19\n" + + "\brepo_url\x18\x04 \x01(\tR\arepoUrl\"K\n" + "\tForgeUser\x12\x16\n" + "\x06origin\x18\x01 \x01(\tR\x06origin\x12\x0e\n" + "\x02id\x18\x02 \x01(\x03R\x02id\x12\x16\n" + diff --git a/src/schema.proto b/src/schema.proto index 867beb5..cbed95f 100644 --- a/src/schema.proto +++ b/src/schema.proto @@ -144,6 +144,7 @@ message Principal { string ip_address = 1; bool cli_admin = 2; ForgeUser forge_user = 3; + string repo_url = 4; } message ForgeUser {