Allow Protected Branches to Whitelist Deploy Keys (#8483)
Add an option to protected branches to add writing deploy keys to the whitelist for pushing. Please note this is technically a breaking change: previously if the owner of a repository was on the whitelist then any writing deploy key was effectively on the whitelist. This option will now need to be set if that is desired. Closes #8472 Details: * Allow Protected Branches to Whitelist Deploy Keys * Add migration * Ensure that IsDeployKey is set to false on the http pushes * add not null default false
This commit is contained in:
parent
b1c1e1549b
commit
0bfe5eb10b
13 changed files with 48 additions and 2 deletions
|
@ -152,6 +152,7 @@ type ProtectBranchForm struct {
|
|||
EnableWhitelist bool
|
||||
WhitelistUsers string
|
||||
WhitelistTeams string
|
||||
WhitelistDeployKeys bool
|
||||
EnableMergeWhitelist bool
|
||||
MergeWhitelistUsers string
|
||||
MergeWhitelistTeams string
|
||||
|
|
|
@ -31,11 +31,12 @@ type HookOptions struct {
|
|||
GitAlternativeObjectDirectories string
|
||||
GitQuarantinePath string
|
||||
ProtectedBranchID int64
|
||||
IsDeployKey bool
|
||||
}
|
||||
|
||||
// HookPreReceive check whether the provided commits are allowed
|
||||
func HookPreReceive(ownerName, repoName string, opts HookOptions) (int, string) {
|
||||
reqURL := setting.LocalURL + fmt.Sprintf("api/internal/hook/pre-receive/%s/%s?old=%s&new=%s&ref=%s&userID=%d&gitObjectDirectory=%s&gitAlternativeObjectDirectories=%s&gitQuarantinePath=%s&prID=%d",
|
||||
reqURL := setting.LocalURL + fmt.Sprintf("api/internal/hook/pre-receive/%s/%s?old=%s&new=%s&ref=%s&userID=%d&gitObjectDirectory=%s&gitAlternativeObjectDirectories=%s&gitQuarantinePath=%s&prID=%d&isDeployKey=%t",
|
||||
url.PathEscape(ownerName),
|
||||
url.PathEscape(repoName),
|
||||
url.QueryEscape(opts.OldCommitID),
|
||||
|
@ -46,6 +47,7 @@ func HookPreReceive(ownerName, repoName string, opts HookOptions) (int, string)
|
|||
url.QueryEscape(opts.GitAlternativeObjectDirectories),
|
||||
url.QueryEscape(opts.GitQuarantinePath),
|
||||
opts.ProtectedBranchID,
|
||||
opts.IsDeployKey,
|
||||
)
|
||||
|
||||
resp, err := newInternalRequest(reqURL, "GET").Response()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue