@ -69,6 +69,7 @@ import (
"net/http"
"net/http"
"strings"
"strings"
auth_model "code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/perm"
"code.gitea.io/gitea/models/perm"
access_model "code.gitea.io/gitea/models/perm/access"
access_model "code.gitea.io/gitea/models/perm/access"
@ -206,9 +207,36 @@ func reqPackageAccess(accessMode perm.AccessMode) func(ctx *context.APIContext)
}
}
// Contexter middleware already checks token for user sign in process.
// Contexter middleware already checks token for user sign in process.
func reqToken ( ) func ( ctx * context . APIContext ) {
func reqToken ( requiredScope auth_model . AccessTokenScope ) func ( ctx * context . APIContext ) {
return func ( ctx * context . APIContext ) {
return func ( ctx * context . APIContext ) {
if true == ctx . Data [ "IsApiToken" ] {
// If OAuth2 token is present
if _ , ok := ctx . Data [ "ApiTokenScope" ] ; ctx . Data [ "IsApiToken" ] == true && ok {
// no scope required
if requiredScope == "" {
return
}
// check scope
scope := ctx . Data [ "ApiTokenScope" ] . ( auth_model . AccessTokenScope )
allow , err := scope . HasScope ( requiredScope )
if err != nil {
ctx . Error ( http . StatusForbidden , "reqToken" , "parsing token failed: " + err . Error ( ) )
return
}
if allow {
return
}
// if requires 'repo' scope, but only has 'public_repo' scope, allow it only if the repo is public
if requiredScope == auth_model . AccessTokenScopeRepo {
if allowPublicRepo , err := scope . HasScope ( auth_model . AccessTokenScopePublicRepo ) ; err == nil && allowPublicRepo {
if ctx . Repo . Repository != nil && ! ctx . Repo . Repository . IsPrivate {
return
}
}
}
ctx . Error ( http . StatusForbidden , "reqToken" , "token does not have required scope: " + requiredScope )
return
return
}
}
if ctx . Context . IsBasicAuth {
if ctx . Context . IsBasicAuth {
@ -631,7 +659,7 @@ func Routes(ctx gocontext.Context) *web.Route {
} ) )
} ) )
m . Group ( "" , func ( ) {
m . Group ( "" , func ( ) {
// Miscellaneous
// Miscellaneous (no scope required)
if setting . API . EnableSwagger {
if setting . API . EnableSwagger {
m . Get ( "/swagger" , func ( ctx * context . APIContext ) {
m . Get ( "/swagger" , func ( ctx * context . APIContext ) {
ctx . Redirect ( setting . AppSubURL + "/api/swagger" )
ctx . Redirect ( setting . AppSubURL + "/api/swagger" )
@ -657,7 +685,7 @@ func Routes(ctx gocontext.Context) *web.Route {
m . Get ( "/repository" , settings . GetGeneralRepoSettings )
m . Get ( "/repository" , settings . GetGeneralRepoSettings )
} )
} )
// Notifications
// Notifications (requires 'notification' scope)
m . Group ( "/notifications" , func ( ) {
m . Group ( "/notifications" , func ( ) {
m . Combo ( "" ) .
m . Combo ( "" ) .
Get ( notify . ListNotifications ) .
Get ( notify . ListNotifications ) .
@ -666,9 +694,9 @@ func Routes(ctx gocontext.Context) *web.Route {
m . Combo ( "/threads/{id}" ) .
m . Combo ( "/threads/{id}" ) .
Get ( notify . GetThread ) .
Get ( notify . GetThread ) .
Patch ( notify . ReadThread )
Patch ( notify . ReadThread )
} , reqToken ( ) )
} , reqToken ( auth_model . AccessTokenScopeNotification ) )
// Users
// Users (no scope required)
m . Group ( "/users" , func ( ) {
m . Group ( "/users" , func ( ) {
m . Get ( "/search" , reqExploreSignIn ( ) , user . Search )
m . Get ( "/search" , reqExploreSignIn ( ) , user . Search )
@ -688,6 +716,7 @@ func Routes(ctx gocontext.Context) *web.Route {
} , context_service . UserAssignmentAPI ( ) )
} , context_service . UserAssignmentAPI ( ) )
} )
} )
// (no scope required)
m . Group ( "/users" , func ( ) {
m . Group ( "/users" , func ( ) {
m . Group ( "/{username}" , func ( ) {
m . Group ( "/{username}" , func ( ) {
m . Get ( "/keys" , user . ListPublicKeys )
m . Get ( "/keys" , user . ListPublicKeys )
@ -703,57 +732,62 @@ func Routes(ctx gocontext.Context) *web.Route {
m . Get ( "/subscriptions" , user . GetWatchedRepos )
m . Get ( "/subscriptions" , user . GetWatchedRepos )
} , context_service . UserAssignmentAPI ( ) )
} , context_service . UserAssignmentAPI ( ) )
} , reqToken ( ) )
} , reqToken ( "" ) )
m . Group ( "/user" , func ( ) {
m . Group ( "/user" , func ( ) {
m . Get ( "" , user . GetAuthenticatedUser )
m . Get ( "" , user . GetAuthenticatedUser )
m . Group ( "/settings" , func ( ) {
m . Group ( "/settings" , func ( ) {
m . Get ( "" , user . GetUserSettings )
m . Get ( "" , reqToken ( auth_model . AccessTokenScopeReadUser ) , user . GetUserSettings )
m . Patch ( "" , bind ( api . UserSettingsOptions { } ) , user . UpdateUserSettings )
m . Patch ( "" , reqToken ( auth_model . AccessTokenScopeUser ) , bind ( api . UserSettingsOptions { } ) , user . UpdateUserSettings )
} , reqToken ( ) )
} )
m . Combo ( "/emails" ) . Get ( user . ListEmails ) .
m . Combo ( "/emails" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadUser ) , user . ListEmails ) .
Post ( bind ( api . CreateEmailOption { } ) , user . AddEmail ) .
Post ( reqToken ( auth_model . AccessTokenScopeUser ) , bind ( api . CreateEmailOption { } ) , user . AddEmail ) .
Delete ( bind ( api . DeleteEmailOption { } ) , user . DeleteEmail )
Delete ( reqToken ( auth_model . AccessTokenScopeUser ) , bind ( api . DeleteEmailOption { } ) , user . DeleteEmail )
m . Get ( "/followers" , user . ListMyFollowers )
m . Get ( "/followers" , user . ListMyFollowers )
m . Group ( "/following" , func ( ) {
m . Group ( "/following" , func ( ) {
m . Get ( "" , user . ListMyFollowing )
m . Get ( "" , user . ListMyFollowing )
m . Group ( "/{username}" , func ( ) {
m . Group ( "/{username}" , func ( ) {
m . Get ( "" , user . CheckMyFollowing )
m . Get ( "" , user . CheckMyFollowing )
m . Put ( "" , user . Follow )
m . Put ( "" , reqToken ( auth_model . AccessTokenScopeUserFollow ) , user . Follow ) // requires 'user:follow' scope
m . Delete ( "" , user . Unfollow )
m . Delete ( "" , reqToken ( auth_model . AccessTokenScopeUserFollow ) , user . Unfollow ) // requires 'user:follow' scope
} , context_service . UserAssignmentAPI ( ) )
} , context_service . UserAssignmentAPI ( ) )
} )
} )
// (admin:public_key scope)
m . Group ( "/keys" , func ( ) {
m . Group ( "/keys" , func ( ) {
m . Combo ( "" ) . Get ( user . ListMyPublicKeys ) .
m . Combo ( "" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadPublicKey ) , user . ListMyPublicKeys ) .
Post ( bind ( api . CreateKeyOption { } ) , user . CreatePublicKey )
Post ( reqToken ( auth_model . AccessTokenScopeWritePublicKey ) , bind ( api . CreateKeyOption { } ) , user . CreatePublicKey )
m . Combo ( "/{id}" ) . Get ( user . GetPublicKey ) .
m . Combo ( "/{id}" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadPublicKey ) , user . GetPublicKey ) .
Delete ( user . DeletePublicKey )
Delete ( reqToken ( auth_model . AccessTokenScopeWritePublicKey ) , user . DeletePublicKey )
} )
} )
// (admin:application scope)
m . Group ( "/applications" , func ( ) {
m . Group ( "/applications" , func ( ) {
m . Combo ( "/oauth2" ) .
m . Combo ( "/oauth2" ) .
Get ( user . ListOauth2Applications ) .
Get ( reqToken ( auth_model . AccessTokenScopeReadApplication ) , user . ListOauth2Applications ) .
Post ( bind ( api . CreateOAuth2ApplicationOptions { } ) , user . CreateOauth2Application )
Post ( reqToken ( auth_model . AccessTokenScopeWriteApplication ) , bind ( api . CreateOAuth2ApplicationOptions { } ) , user . CreateOauth2Application )
m . Combo ( "/oauth2/{id}" ) .
m . Combo ( "/oauth2/{id}" ) .
Delete ( user . DeleteOauth2Application ) .
Delete ( reqToken ( auth_model . AccessTokenScopeWriteApplication ) , user . DeleteOauth2Application ) .
Patch ( bind ( api . CreateOAuth2ApplicationOptions { } ) , user . UpdateOauth2Application ) .
Patch ( reqToken ( auth_model . AccessTokenScopeWriteApplication ) , bind ( api . CreateOAuth2ApplicationOptions { } ) , user . UpdateOauth2Application ) .
Get ( user . GetOauth2Application )
Get ( reqToken ( auth_model . AccessTokenScopeReadApplication ) , user . GetOauth2Application )
} , reqToken ( ) )
} )
// (admin:gpg_key scope)
m . Group ( "/gpg_keys" , func ( ) {
m . Group ( "/gpg_keys" , func ( ) {
m . Combo ( "" ) . Get ( user . ListMyGPGKeys ) .
m . Combo ( "" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadGPGKey ) , user . ListMyGPGKeys ) .
Post ( bind ( api . CreateGPGKeyOption { } ) , user . CreateGPGKey )
Post ( reqToken ( auth_model . AccessTokenScopeWriteGPGKey ) , bind ( api . CreateGPGKeyOption { } ) , user . CreateGPGKey )
m . Combo ( "/{id}" ) . Get ( user . GetGPGKey ) .
m . Combo ( "/{id}" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadGPGKey ) , user . GetGPGKey ) .
Delete ( user . DeleteGPGKey )
Delete ( reqToken ( auth_model . AccessTokenScopeWriteGPGKey ) , user . DeleteGPGKey )
} )
} )
m . Get ( "/gpg_key_token" , reqToken ( auth_model . AccessTokenScopeReadGPGKey ) , user . GetVerificationToken )
m . Post ( "/gpg_key_verify" , reqToken ( auth_model . AccessTokenScopeReadGPGKey ) , bind ( api . VerifyGPGKeyOption { } ) , user . VerifyUserGPGKey )
m . Get ( "/gpg_key_token" , user . GetVerificationToken )
// (repo scope)
m . Post ( "/gpg_key_verify" , bind ( api . VerifyGPGKeyOption { } ) , user . VerifyUserGPGKey )
m . Combo ( "/repos" , reqToken ( auth_model . AccessTokenScopeRepo ) ) . Get ( user . ListMyRepos ) .
m . Combo ( "/repos" ) . Get ( user . ListMyRepos ) .
Post ( bind ( api . CreateRepoOption { } ) , repo . Create )
Post ( bind ( api . CreateRepoOption { } ) , repo . Create )
// (repo scope)
m . Group ( "/starred" , func ( ) {
m . Group ( "/starred" , func ( ) {
m . Get ( "" , user . GetMyStarredRepos )
m . Get ( "" , user . GetMyStarredRepos )
m . Group ( "/{username}/{reponame}" , func ( ) {
m . Group ( "/{username}/{reponame}" , func ( ) {
@ -761,57 +795,57 @@ func Routes(ctx gocontext.Context) *web.Route {
m . Put ( "" , user . Star )
m . Put ( "" , user . Star )
m . Delete ( "" , user . Unstar )
m . Delete ( "" , user . Unstar )
} , repoAssignment ( ) )
} , repoAssignment ( ) )
} )
} , reqToken ( auth_model . AccessTokenScopeRepo ) )
m . Get ( "/times" , repo . ListMyTrackedTimes )
m . Get ( "/times" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . ListMyTrackedTimes )
m . Get ( "/stopwatches" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . GetStopwatches )
m . Get ( "/stopwatches" , repo . GetStopwatches )
m . Get ( "/subscriptions" , reqToken ( auth_model . AccessTokenScopeRepo ) , user . GetMyWatchedRepos )
m . Get ( "/teams" , reqToken ( auth_model . AccessTokenScopeRepo ) , org . ListUserTeams )
m . Get ( "/subscriptions" , user . GetMyWatchedRepos )
} , reqToken ( "" ) )
m . Get ( "/teams" , org . ListUserTeams )
} , reqToken ( ) )
// Repositories
// Repositories
m . Post ( "/org/{org}/repos" , reqToken ( ) , bind ( api . CreateRepoOption { } ) , repo . CreateOrgRepoDeprecated )
m . Post ( "/org/{org}/repos" , reqToken ( auth_model . AccessTokenScopeAdminOrg ) , bind ( api . CreateRepoOption { } ) , repo . CreateOrgRepoDeprecated )
m . Combo ( "/repositories/{id}" , reqToken ( ) ) . Get ( repo . GetByID )
m . Combo ( "/repositories/{id}" , reqToken ( auth_model . AccessTokenScopeRepo ) ) . Get ( repo . GetByID )
m . Group ( "/repos" , func ( ) {
m . Group ( "/repos" , func ( ) {
m . Get ( "/search" , repo . Search )
m . Get ( "/search" , repo . Search )
m . Get ( "/issues/search" , repo . SearchIssues )
m . Get ( "/issues/search" , repo . SearchIssues )
m . Post ( "/migrate" , reqToken ( ) , bind ( api . MigrateRepoOptions { } ) , repo . Migrate )
// (repo scope)
m . Post ( "/migrate" , reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . MigrateRepoOptions { } ) , repo . Migrate )
m . Group ( "/{username}/{reponame}" , func ( ) {
m . Group ( "/{username}/{reponame}" , func ( ) {
m . Combo ( "" ) . Get ( reqAnyRepoReader ( ) , repo . Get ) .
m . Combo ( "" ) . Get ( reqAnyRepoReader ( ) , repo . Get ) .
Delete ( reqToken ( ) , reqOwner ( ) , repo . Delete ) .
Delete ( reqToken ( auth_model . AccessTokenScopeDeleteRepo ) , reqOwner ( ) , repo . Delete ) .
Patch ( reqToken ( ) , reqAdmin ( ) , bind ( api . EditRepoOption { } ) , repo . Edit )
Patch ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqAdmin ( ) , bind ( api . EditRepoOption { } ) , repo . Edit )
m . Post ( "/generate" , reqToken ( ) , reqRepoReader ( unit . TypeCode ) , bind ( api . GenerateRepoOption { } ) , repo . Generate )
m . Post ( "/generate" , reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoReader ( unit . TypeCode ) , bind ( api . GenerateRepoOption { } ) , repo . Generate )
m . Post ( "/transfer" , reqOwner ( ) , bind ( api . TransferRepoOption { } ) , repo . Transfer )
m . Group ( "/transfer" , func ( ) {
m . Post ( "/transfer/accept" , reqToken ( ) , repo . AcceptTransfer )
m . Post ( "" , reqOwner ( ) , bind ( api . TransferRepoOption { } ) , repo . Transfer )
m . Post ( "/transfer/reject" , reqToken ( ) , repo . RejectTransfer )
m . Post ( "/accept" , repo . AcceptTransfer )
m . Combo ( "/notifications" ) .
m . Post ( "/reject" , repo . RejectTransfer )
Get ( reqToken ( ) , notify . ListRepoNotifications ) .
} , reqToken ( auth_model . AccessTokenScopeRepo ) )
Put ( reqToken ( ) , notify . ReadRepoNotifications )
m . Combo ( "/notifications" , reqToken ( auth_model . AccessTokenScopeNotification ) ) .
Get ( notify . ListRepoNotifications ) .
Put ( notify . ReadRepoNotifications )
m . Group ( "/hooks/git" , func ( ) {
m . Group ( "/hooks/git" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListGitHooks )
m . Combo ( "" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadRepoHook ) , repo . ListGitHooks )
m . Group ( "/{id}" , func ( ) {
m . Group ( "/{id}" , func ( ) {
m . Combo ( "" ) . Get ( repo . GetGitHook ) .
m . Combo ( "" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadRepoHook ) , repo . GetGitHook ) .
Patch ( bind ( api . EditGitHookOption { } ) , repo . EditGitHook ) .
Patch ( reqToken ( auth_model . AccessTokenScopeWriteRepoHook ) , bind ( api . EditGitHookOption { } ) , repo . EditGitHook ) .
Delete ( repo . DeleteGitHook )
Delete ( reqToken ( auth_model . AccessTokenScopeWriteRepoHook ) , repo . DeleteGitHook )
} )
} )
} , reqToken ( ) , req Admin ( ) , reqGitHook ( ) , context . ReferencesGitRepo ( true ) )
} , reqAdmin ( ) , reqGitHook ( ) , context . ReferencesGitRepo ( true ) )
m . Group ( "/hooks" , func ( ) {
m . Group ( "/hooks" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListHooks ) .
m . Combo ( "" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadRepoHook ) , repo . ListHooks ) .
Post ( bind ( api . CreateHookOption { } ) , repo . CreateHook )
Post ( reqToken ( auth_model . AccessTokenScopeWriteRepoHook ) , bind ( api . CreateHookOption { } ) , repo . CreateHook )
m . Group ( "/{id}" , func ( ) {
m . Group ( "/{id}" , func ( ) {
m . Combo ( "" ) . Get ( repo . GetHook ) .
m . Combo ( "" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadRepoHook ) , repo . GetHook ) .
Patch ( bind ( api . EditHookOption { } ) , repo . EditHook ) .
Patch ( reqToken ( auth_model . AccessTokenScopeWriteRepoHook ) , bind ( api . EditHookOption { } ) , repo . EditHook ) .
Delete ( repo . DeleteHook )
Delete ( reqToken ( auth_model . AccessTokenScopeWriteRepoHook ) , repo . DeleteHook )
m . Post ( "/tests" , context . ReferencesGitRepo ( ) , context . RepoRefForAPI , repo . TestHook )
m . Post ( "/tests" , reqToken ( auth_model . AccessTokenScopeReadRepoHook ) , context . ReferencesGitRepo ( ) , context . RepoRefForAPI , repo . TestHook )
} )
} )
} , reqToken ( ) , req Admin ( ) , reqWebhooksEnabled ( ) )
} , reqAdmin ( ) , reqWebhooksEnabled ( ) )
m . Group ( "/collaborators" , func ( ) {
m . Group ( "/collaborators" , func ( ) {
m . Get ( "" , reqAnyRepoReader ( ) , repo . ListCollaborators )
m . Get ( "" , reqAnyRepoReader ( ) , repo . ListCollaborators )
m . Group ( "/{collaborator}" , func ( ) {
m . Group ( "/{collaborator}" , func ( ) {
@ -819,26 +853,26 @@ func Routes(ctx gocontext.Context) *web.Route {
Put ( reqAdmin ( ) , bind ( api . AddCollaboratorOption { } ) , repo . AddCollaborator ) .
Put ( reqAdmin ( ) , bind ( api . AddCollaboratorOption { } ) , repo . AddCollaborator ) .
Delete ( reqAdmin ( ) , repo . DeleteCollaborator )
Delete ( reqAdmin ( ) , repo . DeleteCollaborator )
m . Get ( "/permission" , repo . GetRepoPermissions )
m . Get ( "/permission" , repo . GetRepoPermissions )
} , reqToken ( ) )
} )
} , reqToken ( ) )
} , reqToken ( auth_model . AccessTokenScopeRepo ) )
m . Get ( "/assignees" , reqToken ( ) , reqAnyRepoReader ( ) , repo . GetAssignees )
m . Get ( "/assignees" , reqToken ( auth_model . AccessTokenScopeRepo ) , reqAnyRepoReader ( ) , repo . GetAssignees )
m . Get ( "/reviewers" , reqToken ( ) , reqAnyRepoReader ( ) , repo . GetReviewers )
m . Get ( "/reviewers" , reqToken ( auth_model . AccessTokenScopeRepo ) , reqAnyRepoReader ( ) , repo . GetReviewers )
m . Group ( "/teams" , func ( ) {
m . Group ( "/teams" , func ( ) {
m . Get ( "" , reqAnyRepoReader ( ) , repo . ListTeams )
m . Get ( "" , reqAnyRepoReader ( ) , repo . ListTeams )
m . Combo ( "/{team}" ) . Get ( reqAnyRepoReader ( ) , repo . IsTeam ) .
m . Combo ( "/{team}" ) . Get ( reqAnyRepoReader ( ) , repo . IsTeam ) .
Put ( reqAdmin ( ) , repo . AddTeam ) .
Put ( reqAdmin ( ) , repo . AddTeam ) .
Delete ( reqAdmin ( ) , repo . DeleteTeam )
Delete ( reqAdmin ( ) , repo . DeleteTeam )
} , reqToken ( ) )
} , reqToken ( auth_model . AccessTokenScopeRepo ) )
m . Get ( "/raw/*" , context . ReferencesGitRepo ( ) , context . RepoRefForAPI , reqRepoReader ( unit . TypeCode ) , repo . GetRawFile )
m . Get ( "/raw/*" , context . ReferencesGitRepo ( ) , context . RepoRefForAPI , reqRepoReader ( unit . TypeCode ) , repo . GetRawFile )
m . Get ( "/media/*" , context . ReferencesGitRepo ( ) , context . RepoRefForAPI , reqRepoReader ( unit . TypeCode ) , repo . GetRawFileOrLFS )
m . Get ( "/media/*" , context . ReferencesGitRepo ( ) , context . RepoRefForAPI , reqRepoReader ( unit . TypeCode ) , repo . GetRawFileOrLFS )
m . Get ( "/archive/*" , reqRepoReader ( unit . TypeCode ) , repo . GetArchive )
m . Get ( "/archive/*" , reqRepoReader ( unit . TypeCode ) , repo . GetArchive )
m . Combo ( "/forks" ) . Get ( repo . ListForks ) .
m . Combo ( "/forks" ) . Get ( repo . ListForks ) .
Post ( reqToken ( ) , reqRepoReader ( unit . TypeCode ) , bind ( api . CreateForkOption { } ) , repo . CreateFork )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoReader ( unit . TypeCode ) , bind ( api . CreateForkOption { } ) , repo . CreateFork )
m . Group ( "/branches" , func ( ) {
m . Group ( "/branches" , func ( ) {
m . Get ( "" , repo . ListBranches )
m . Get ( "" , repo . ListBranches )
m . Get ( "/*" , repo . GetBranch )
m . Get ( "/*" , repo . GetBranch )
m . Delete ( "/*" , reqRepoWriter ( unit . TypeCode ) , repo . DeleteBranch )
m . Delete ( "/*" , reqToken ( auth_model . AccessTokenScopeRepo ) , req RepoWriter ( unit . TypeCode ) , repo . DeleteBranch )
m . Post ( "" , reqRepoWriter ( unit . TypeCode ) , bind ( api . CreateBranchRepoOption { } ) , repo . CreateBranch )
m . Post ( "" , reqToken ( auth_model . AccessTokenScopeRepo ) , req RepoWriter ( unit . TypeCode ) , bind ( api . CreateBranchRepoOption { } ) , repo . CreateBranch )
} , context . ReferencesGitRepo ( ) , reqRepoReader ( unit . TypeCode ) )
} , context . ReferencesGitRepo ( ) , reqRepoReader ( unit . TypeCode ) )
m . Group ( "/branch_protections" , func ( ) {
m . Group ( "/branch_protections" , func ( ) {
m . Get ( "" , repo . ListBranchProtections )
m . Get ( "" , repo . ListBranchProtections )
@ -848,74 +882,74 @@ func Routes(ctx gocontext.Context) *web.Route {
m . Patch ( "" , bind ( api . EditBranchProtectionOption { } ) , repo . EditBranchProtection )
m . Patch ( "" , bind ( api . EditBranchProtectionOption { } ) , repo . EditBranchProtection )
m . Delete ( "" , repo . DeleteBranchProtection )
m . Delete ( "" , repo . DeleteBranchProtection )
} )
} )
} , reqToken ( ) , reqAdmin ( ) )
} , reqToken ( auth_model . AccessTokenScopeRepo ) , reqAdmin ( ) )
m . Group ( "/tags" , func ( ) {
m . Group ( "/tags" , func ( ) {
m . Get ( "" , repo . ListTags )
m . Get ( "" , repo . ListTags )
m . Get ( "/*" , repo . GetTag )
m . Get ( "/*" , repo . GetTag )
m . Post ( "" , reqRepoWriter ( unit . TypeCode ) , bind ( api . CreateTagOption { } ) , repo . CreateTag )
m . Post ( "" , reqToken ( auth_model . AccessTokenScopeRepo ) , req RepoWriter ( unit . TypeCode ) , bind ( api . CreateTagOption { } ) , repo . CreateTag )
m . Delete ( "/*" , repo . DeleteTag )
m . Delete ( "/*" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . DeleteTag )
} , reqRepoReader ( unit . TypeCode ) , context . ReferencesGitRepo ( true ) )
} , reqRepoReader ( unit . TypeCode ) , context . ReferencesGitRepo ( true ) )
m . Group ( "/keys" , func ( ) {
m . Group ( "/keys" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListDeployKeys ) .
m . Combo ( "" ) . Get ( repo . ListDeployKeys ) .
Post ( bind ( api . CreateKeyOption { } ) , repo . CreateDeployKey )
Post ( bind ( api . CreateKeyOption { } ) , repo . CreateDeployKey )
m . Combo ( "/{id}" ) . Get ( repo . GetDeployKey ) .
m . Combo ( "/{id}" ) . Get ( repo . GetDeployKey ) .
Delete ( repo . DeleteDeploykey )
Delete ( repo . DeleteDeploykey )
} , reqToken ( ) , reqAdmin ( ) )
} , reqToken ( auth_model . AccessTokenScopeRepo ) , reqAdmin ( ) )
m . Group ( "/times" , func ( ) {
m . Group ( "/times" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListTrackedTimesByRepository )
m . Combo ( "" ) . Get ( repo . ListTrackedTimesByRepository )
m . Combo ( "/{timetrackingusername}" ) . Get ( repo . ListTrackedTimesByUser )
m . Combo ( "/{timetrackingusername}" ) . Get ( repo . ListTrackedTimesByUser )
} , mustEnableIssues , reqToken ( ) )
} , mustEnableIssues , reqToken ( auth_model . AccessTokenScopeRepo ) )
m . Group ( "/wiki" , func ( ) {
m . Group ( "/wiki" , func ( ) {
m . Combo ( "/page/{pageName}" ) .
m . Combo ( "/page/{pageName}" ) .
Get ( repo . GetWikiPage ) .
Get ( repo . GetWikiPage ) .
Patch ( mustNotBeArchived , reqRepoWriter ( unit . TypeWiki ) , bind ( api . CreateWikiPageOptions { } ) , repo . EditWikiPage ) .
Patch ( mustNotBeArchived , reqToken ( auth_model . AccessTokenScopeRepo ) , req RepoWriter ( unit . TypeWiki ) , bind ( api . CreateWikiPageOptions { } ) , repo . EditWikiPage ) .
Delete ( mustNotBeArchived , reqRepoWriter ( unit . TypeWiki ) , repo . DeleteWikiPage )
Delete ( mustNotBeArchived , reqToken ( auth_model . AccessTokenScopeRepo ) , req RepoWriter ( unit . TypeWiki ) , repo . DeleteWikiPage )
m . Get ( "/revisions/{pageName}" , repo . ListPageRevisions )
m . Get ( "/revisions/{pageName}" , repo . ListPageRevisions )
m . Post ( "/new" , mustNotBeArchived , reqRepoWriter ( unit . TypeWiki ) , bind ( api . CreateWikiPageOptions { } ) , repo . NewWikiPage )
m . Post ( "/new" , mustNotBeArchived , reqToken ( auth_model . AccessTokenScopeRepo ) , req RepoWriter ( unit . TypeWiki ) , bind ( api . CreateWikiPageOptions { } ) , repo . NewWikiPage )
m . Get ( "/pages" , repo . ListWikiPages )
m . Get ( "/pages" , repo . ListWikiPages )
} , mustEnableWiki )
} , mustEnableWiki )
m . Group ( "/issues" , func ( ) {
m . Group ( "/issues" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListIssues ) .
m . Combo ( "" ) . Get ( repo . ListIssues ) .
Post ( reqToken ( ) , mustNotBeArchived , bind ( api . CreateIssueOption { } ) , repo . CreateIssue )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , bind ( api . CreateIssueOption { } ) , repo . CreateIssue )
m . Group ( "/comments" , func ( ) {
m . Group ( "/comments" , func ( ) {
m . Get ( "" , repo . ListRepoIssueComments )
m . Get ( "" , repo . ListRepoIssueComments )
m . Group ( "/{id}" , func ( ) {
m . Group ( "/{id}" , func ( ) {
m . Combo ( "" ) .
m . Combo ( "" ) .
Get ( repo . GetIssueComment ) .
Get ( repo . GetIssueComment ) .
Patch ( mustNotBeArchived , reqToken ( ) , bind ( api . EditIssueCommentOption { } ) , repo . EditIssueComment ) .
Patch ( mustNotBeArchived , reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . EditIssueCommentOption { } ) , repo . EditIssueComment ) .
Delete ( reqToken ( ) , repo . DeleteIssueComment )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , repo . DeleteIssueComment )
m . Combo ( "/reactions" ) .
m . Combo ( "/reactions" ) .
Get ( repo . GetIssueCommentReactions ) .
Get ( repo . GetIssueCommentReactions ) .
Post ( reqToken ( ) , bind ( api . EditReactionOption { } ) , repo . PostIssueCommentReaction ) .
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . EditReactionOption { } ) , repo . PostIssueCommentReaction ) .
Delete ( reqToken ( ) , bind ( api . EditReactionOption { } ) , repo . DeleteIssueCommentReaction )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . EditReactionOption { } ) , repo . DeleteIssueCommentReaction )
m . Group ( "/assets" , func ( ) {
m . Group ( "/assets" , func ( ) {
m . Combo ( "" ) .
m . Combo ( "" ) .
Get ( repo . ListIssueCommentAttachments ) .
Get ( repo . ListIssueCommentAttachments ) .
Post ( reqToken ( ) , mustNotBeArchived , repo . CreateIssueCommentAttachment )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , repo . CreateIssueCommentAttachment )
m . Combo ( "/{asset}" ) .
m . Combo ( "/{asset}" ) .
Get ( repo . GetIssueCommentAttachment ) .
Get ( repo . GetIssueCommentAttachment ) .
Patch ( reqToken ( ) , mustNotBeArchived , bind ( api . EditAttachmentOptions { } ) , repo . EditIssueCommentAttachment ) .
Patch ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , bind ( api . EditAttachmentOptions { } ) , repo . EditIssueCommentAttachment ) .
Delete ( reqToken ( ) , mustNotBeArchived , repo . DeleteIssueCommentAttachment )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , repo . DeleteIssueCommentAttachment )
} , mustEnableAttachments )
} , mustEnableAttachments )
} )
} )
} )
} )
m . Group ( "/{index}" , func ( ) {
m . Group ( "/{index}" , func ( ) {
m . Combo ( "" ) . Get ( repo . GetIssue ) .
m . Combo ( "" ) . Get ( repo . GetIssue ) .
Patch ( reqToken ( ) , bind ( api . EditIssueOption { } ) , repo . EditIssue ) .
Patch ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . EditIssueOption { } ) , repo . EditIssue ) .
Delete ( reqToken ( ) , reqAdmin ( ) , context . ReferencesGitRepo ( ) , repo . DeleteIssue )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqAdmin ( ) , context . ReferencesGitRepo ( ) , repo . DeleteIssue )
m . Group ( "/comments" , func ( ) {
m . Group ( "/comments" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListIssueComments ) .
m . Combo ( "" ) . Get ( repo . ListIssueComments ) .
Post ( reqToken ( ) , mustNotBeArchived , bind ( api . CreateIssueCommentOption { } ) , repo . CreateIssueComment )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , bind ( api . CreateIssueCommentOption { } ) , repo . CreateIssueComment )
m . Combo ( "/{id}" , reqToken ( ) ) . Patch ( bind ( api . EditIssueCommentOption { } ) , repo . EditIssueCommentDeprecated ) .
m . Combo ( "/{id}" , reqToken ( auth_model . AccessTokenScopeRepo ) ) . Patch ( bind ( api . EditIssueCommentOption { } ) , repo . EditIssueCommentDeprecated ) .
Delete ( repo . DeleteIssueCommentDeprecated )
Delete ( repo . DeleteIssueCommentDeprecated )
} )
} )
m . Get ( "/timeline" , repo . ListIssueCommentsAndTimeline )
m . Get ( "/timeline" , repo . ListIssueCommentsAndTimeline )
m . Group ( "/labels" , func ( ) {
m . Group ( "/labels" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListIssueLabels ) .
m . Combo ( "" ) . Get ( repo . ListIssueLabels ) .
Post ( reqToken ( ) , bind ( api . IssueLabelsOption { } ) , repo . AddIssueLabels ) .
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . IssueLabelsOption { } ) , repo . AddIssueLabels ) .
Put ( reqToken ( ) , bind ( api . IssueLabelsOption { } ) , repo . ReplaceIssueLabels ) .
Put ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . IssueLabelsOption { } ) , repo . ReplaceIssueLabels ) .
Delete ( reqToken ( ) , repo . ClearIssueLabels )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , repo . ClearIssueLabels )
m . Delete ( "/{id}" , reqToken ( ) , repo . DeleteIssueLabel )
m . Delete ( "/{id}" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . DeleteIssueLabel )
} )
} )
m . Group ( "/times" , func ( ) {
m . Group ( "/times" , func ( ) {
m . Combo ( "" ) .
m . Combo ( "" ) .
@ -923,125 +957,125 @@ func Routes(ctx gocontext.Context) *web.Route {
Post ( bind ( api . AddTimeOption { } ) , repo . AddTime ) .
Post ( bind ( api . AddTimeOption { } ) , repo . AddTime ) .
Delete ( repo . ResetIssueTime )
Delete ( repo . ResetIssueTime )
m . Delete ( "/{id}" , repo . DeleteTime )
m . Delete ( "/{id}" , repo . DeleteTime )
} , reqToken ( ) )
} , reqToken ( auth_model . AccessTokenScopeRepo ) )
m . Combo ( "/deadline" ) . Post ( reqToken ( ) , bind ( api . EditDeadlineOption { } ) , repo . UpdateIssueDeadline )
m . Combo ( "/deadline" ) . Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . EditDeadlineOption { } ) , repo . UpdateIssueDeadline )
m . Group ( "/stopwatch" , func ( ) {
m . Group ( "/stopwatch" , func ( ) {
m . Post ( "/start" , reqToken ( ) , repo . StartIssueStopwatch )
m . Post ( "/start" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . StartIssueStopwatch )
m . Post ( "/stop" , reqToken ( ) , repo . StopIssueStopwatch )
m . Post ( "/stop" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . StopIssueStopwatch )
m . Delete ( "/delete" , reqToken ( ) , repo . DeleteIssueStopwatch )
m . Delete ( "/delete" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . DeleteIssueStopwatch )
} )
} )
m . Group ( "/subscriptions" , func ( ) {
m . Group ( "/subscriptions" , func ( ) {
m . Get ( "" , repo . GetIssueSubscribers )
m . Get ( "" , repo . GetIssueSubscribers )
m . Get ( "/check" , reqToken ( ) , repo . CheckIssueSubscription )
m . Get ( "/check" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . CheckIssueSubscription )
m . Put ( "/{user}" , reqToken ( ) , repo . AddIssueSubscription )
m . Put ( "/{user}" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . AddIssueSubscription )
m . Delete ( "/{user}" , reqToken ( ) , repo . DelIssueSubscription )
m . Delete ( "/{user}" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . DelIssueSubscription )
} )
} )
m . Combo ( "/reactions" ) .
m . Combo ( "/reactions" ) .
Get ( repo . GetIssueReactions ) .
Get ( repo . GetIssueReactions ) .
Post ( reqToken ( ) , bind ( api . EditReactionOption { } ) , repo . PostIssueReaction ) .
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . EditReactionOption { } ) , repo . PostIssueReaction ) .
Delete ( reqToken ( ) , bind ( api . EditReactionOption { } ) , repo . DeleteIssueReaction )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . EditReactionOption { } ) , repo . DeleteIssueReaction )
m . Group ( "/assets" , func ( ) {
m . Group ( "/assets" , func ( ) {
m . Combo ( "" ) .
m . Combo ( "" ) .
Get ( repo . ListIssueAttachments ) .
Get ( repo . ListIssueAttachments ) .
Post ( reqToken ( ) , mustNotBeArchived , repo . CreateIssueAttachment )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , repo . CreateIssueAttachment )
m . Combo ( "/{asset}" ) .
m . Combo ( "/{asset}" ) .
Get ( repo . GetIssueAttachment ) .
Get ( repo . GetIssueAttachment ) .
Patch ( reqToken ( ) , mustNotBeArchived , bind ( api . EditAttachmentOptions { } ) , repo . EditIssueAttachment ) .
Patch ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , bind ( api . EditAttachmentOptions { } ) , repo . EditIssueAttachment ) .
Delete ( reqToken ( ) , mustNotBeArchived , repo . DeleteIssueAttachment )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , repo . DeleteIssueAttachment )
} , mustEnableAttachments )
} , mustEnableAttachments )
} )
} )
} , mustEnableIssuesOrPulls )
} , mustEnableIssuesOrPulls )
m . Group ( "/labels" , func ( ) {
m . Group ( "/labels" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListLabels ) .
m . Combo ( "" ) . Get ( repo . ListLabels ) .
Post ( reqToken ( ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , bind ( api . CreateLabelOption { } ) , repo . CreateLabel )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , bind ( api . CreateLabelOption { } ) , repo . CreateLabel )
m . Combo ( "/{id}" ) . Get ( repo . GetLabel ) .
m . Combo ( "/{id}" ) . Get ( repo . GetLabel ) .
Patch ( reqToken ( ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , bind ( api . EditLabelOption { } ) , repo . EditLabel ) .
Patch ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , bind ( api . EditLabelOption { } ) , repo . EditLabel ) .
Delete ( reqToken ( ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , repo . DeleteLabel )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , repo . DeleteLabel )
} )
} )
m . Post ( "/markdown" , bind ( api . MarkdownOption { } ) , misc . Markdown )
m . Post ( "/markdown" , reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . MarkdownOption { } ) , misc . Markdown )
m . Post ( "/markdown/raw" , misc . MarkdownRaw )
m . Post ( "/markdown/raw" , reqToken ( auth_model . AccessTokenScopeRepo ) , misc . MarkdownRaw )
m . Group ( "/milestones" , func ( ) {
m . Group ( "/milestones" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListMilestones ) .
m . Combo ( "" ) . Get ( repo . ListMilestones ) .
Post ( reqToken ( ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , bind ( api . CreateMilestoneOption { } ) , repo . CreateMilestone )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , bind ( api . CreateMilestoneOption { } ) , repo . CreateMilestone )
m . Combo ( "/{id}" ) . Get ( repo . GetMilestone ) .
m . Combo ( "/{id}" ) . Get ( repo . GetMilestone ) .
Patch ( reqToken ( ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , bind ( api . EditMilestoneOption { } ) , repo . EditMilestone ) .
Patch ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , bind ( api . EditMilestoneOption { } ) , repo . EditMilestone ) .
Delete ( reqToken ( ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , repo . DeleteMilestone )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeIssues , unit . TypePullRequests ) , repo . DeleteMilestone )
} )
} )
m . Get ( "/stargazers" , repo . ListStargazers )
m . Get ( "/stargazers" , repo . ListStargazers )
m . Get ( "/subscribers" , repo . ListSubscribers )
m . Get ( "/subscribers" , repo . ListSubscribers )
m . Group ( "/subscription" , func ( ) {
m . Group ( "/subscription" , func ( ) {
m . Get ( "" , user . IsWatching )
m . Get ( "" , user . IsWatching )
m . Put ( "" , reqToken ( ) , user . Watch )
m . Put ( "" , reqToken ( auth_model . AccessTokenScopeRepo ) , user . Watch )
m . Delete ( "" , reqToken ( ) , user . Unwatch )
m . Delete ( "" , reqToken ( auth_model . AccessTokenScopeRepo ) , user . Unwatch )
} )
} )
m . Group ( "/releases" , func ( ) {
m . Group ( "/releases" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListReleases ) .
m . Combo ( "" ) . Get ( repo . ListReleases ) .
Post ( reqToken ( ) , reqRepoWriter ( unit . TypeReleases ) , context . ReferencesGitRepo ( ) , bind ( api . CreateReleaseOption { } ) , repo . CreateRelease )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeReleases ) , context . ReferencesGitRepo ( ) , bind ( api . CreateReleaseOption { } ) , repo . CreateRelease )
m . Group ( "/{id}" , func ( ) {
m . Group ( "/{id}" , func ( ) {
m . Combo ( "" ) . Get ( repo . GetRelease ) .
m . Combo ( "" ) . Get ( repo . GetRelease ) .
Patch ( reqToken ( ) , reqRepoWriter ( unit . TypeReleases ) , context . ReferencesGitRepo ( ) , bind ( api . EditReleaseOption { } ) , repo . EditRelease ) .
Patch ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeReleases ) , context . ReferencesGitRepo ( ) , bind ( api . EditReleaseOption { } ) , repo . EditRelease ) .
Delete ( reqToken ( ) , reqRepoWriter ( unit . TypeReleases ) , repo . DeleteRelease )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeReleases ) , repo . DeleteRelease )
m . Group ( "/assets" , func ( ) {
m . Group ( "/assets" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListReleaseAttachments ) .
m . Combo ( "" ) . Get ( repo . ListReleaseAttachments ) .
Post ( reqToken ( ) , reqRepoWriter ( unit . TypeReleases ) , repo . CreateReleaseAttachment )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeReleases ) , repo . CreateReleaseAttachment )
m . Combo ( "/{asset}" ) . Get ( repo . GetReleaseAttachment ) .
m . Combo ( "/{asset}" ) . Get ( repo . GetReleaseAttachment ) .
Patch ( reqToken ( ) , reqRepoWriter ( unit . TypeReleases ) , bind ( api . EditAttachmentOptions { } ) , repo . EditReleaseAttachment ) .
Patch ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeReleases ) , bind ( api . EditAttachmentOptions { } ) , repo . EditReleaseAttachment ) .
Delete ( reqToken ( ) , reqRepoWriter ( unit . TypeReleases ) , repo . DeleteReleaseAttachment )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeReleases ) , repo . DeleteReleaseAttachment )
} )
} )
} )
} )
m . Group ( "/tags" , func ( ) {
m . Group ( "/tags" , func ( ) {
m . Combo ( "/{tag}" ) .
m . Combo ( "/{tag}" ) .
Get ( repo . GetReleaseByTag ) .
Get ( repo . GetReleaseByTag ) .
Delete ( reqToken ( ) , reqRepoWriter ( unit . TypeReleases ) , repo . DeleteReleaseByTag )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeReleases ) , repo . DeleteReleaseByTag )
} )
} )
} , reqRepoReader ( unit . TypeReleases ) )
} , reqRepoReader ( unit . TypeReleases ) )
m . Post ( "/mirror-sync" , reqToken ( ) , reqRepoWriter ( unit . TypeCode ) , repo . MirrorSync )
m . Post ( "/mirror-sync" , reqToken ( auth_model . AccessTokenScopeRepo ) , reqRepoWriter ( unit . TypeCode ) , repo . MirrorSync )
m . Post ( "/push_mirrors-sync" , reqAdmin ( ) , repo . PushMirrorSync )
m . Post ( "/push_mirrors-sync" , reqAdmin ( ) , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . PushMirrorSync )
m . Group ( "/push_mirrors" , func ( ) {
m . Group ( "/push_mirrors" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListPushMirrors ) .
m . Combo ( "" ) . Get ( repo . ListPushMirrors ) .
Post ( bind ( api . CreatePushMirrorOption { } ) , repo . AddPushMirror )
Post ( bind ( api . CreatePushMirrorOption { } ) , repo . AddPushMirror )
m . Combo ( "/{name}" ) .
m . Combo ( "/{name}" ) .
Delete ( repo . DeletePushMirrorByRemoteName ) .
Delete ( repo . DeletePushMirrorByRemoteName ) .
Get ( repo . GetPushMirrorByName )
Get ( repo . GetPushMirrorByName )
} , reqAdmin ( ) )
} , reqAdmin ( ) , reqToken ( auth_model . AccessTokenScopeRepo ) )
m . Get ( "/editorconfig/{filename}" , context . ReferencesGitRepo ( ) , context . RepoRefForAPI , reqRepoReader ( unit . TypeCode ) , repo . GetEditorconfig )
m . Get ( "/editorconfig/{filename}" , context . ReferencesGitRepo ( ) , context . RepoRefForAPI , reqRepoReader ( unit . TypeCode ) , repo . GetEditorconfig )
m . Group ( "/pulls" , func ( ) {
m . Group ( "/pulls" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListPullRequests ) .
m . Combo ( "" ) . Get ( repo . ListPullRequests ) .
Post ( reqToken ( ) , mustNotBeArchived , bind ( api . CreatePullRequestOption { } ) , repo . CreatePullRequest )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , bind ( api . CreatePullRequestOption { } ) , repo . CreatePullRequest )
m . Group ( "/{index}" , func ( ) {
m . Group ( "/{index}" , func ( ) {
m . Combo ( "" ) . Get ( repo . GetPullRequest ) .
m . Combo ( "" ) . Get ( repo . GetPullRequest ) .
Patch ( reqToken ( ) , bind ( api . EditPullRequestOption { } ) , repo . EditPullRequest )
Patch ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . EditPullRequestOption { } ) , repo . EditPullRequest )
m . Get ( ".{diffType:diff|patch}" , repo . DownloadPullDiffOrPatch )
m . Get ( ".{diffType:diff|patch}" , repo . DownloadPullDiffOrPatch )
m . Post ( "/update" , reqToken ( ) , repo . UpdatePullRequest )
m . Post ( "/update" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . UpdatePullRequest )
m . Get ( "/commits" , repo . GetPullRequestCommits )
m . Get ( "/commits" , repo . GetPullRequestCommits )
m . Get ( "/files" , repo . GetPullRequestFiles )
m . Get ( "/files" , repo . GetPullRequestFiles )
m . Combo ( "/merge" ) . Get ( repo . IsPullRequestMerged ) .
m . Combo ( "/merge" ) . Get ( repo . IsPullRequestMerged ) .
Post ( reqToken ( ) , mustNotBeArchived , bind ( forms . MergePullRequestForm { } ) , repo . MergePullRequest ) .
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , bind ( forms . MergePullRequestForm { } ) , repo . MergePullRequest ) .
Delete ( reqToken ( ) , mustNotBeArchived , repo . CancelScheduledAutoMerge )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , mustNotBeArchived , repo . CancelScheduledAutoMerge )
m . Group ( "/reviews" , func ( ) {
m . Group ( "/reviews" , func ( ) {
m . Combo ( "" ) .
m . Combo ( "" ) .
Get ( repo . ListPullReviews ) .
Get ( repo . ListPullReviews ) .
Post ( reqToken ( ) , bind ( api . CreatePullReviewOptions { } ) , repo . CreatePullReview )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . CreatePullReviewOptions { } ) , repo . CreatePullReview )
m . Group ( "/{id}" , func ( ) {
m . Group ( "/{id}" , func ( ) {
m . Combo ( "" ) .
m . Combo ( "" ) .
Get ( repo . GetPullReview ) .
Get ( repo . GetPullReview ) .
Delete ( reqToken ( ) , repo . DeletePullReview ) .
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , repo . DeletePullReview ) .
Post ( reqToken ( ) , bind ( api . SubmitPullReviewOptions { } ) , repo . SubmitPullReview )
Post ( reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . SubmitPullReviewOptions { } ) , repo . SubmitPullReview )
m . Combo ( "/comments" ) .
m . Combo ( "/comments" ) .
Get ( repo . GetPullReviewComments )
Get ( repo . GetPullReviewComments )
m . Post ( "/dismissals" , reqToken ( ) , bind ( api . DismissPullReviewOptions { } ) , repo . DismissPullReview )
m . Post ( "/dismissals" , reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . DismissPullReviewOptions { } ) , repo . DismissPullReview )
m . Post ( "/undismissals" , reqToken ( ) , repo . UnDismissPullReview )
m . Post ( "/undismissals" , reqToken ( auth_model . AccessTokenScopeRepo ) , repo . UnDismissPullReview )
} )
} )
} )
} )
m . Combo ( "/requested_reviewers" ) .
m . Combo ( "/requested_reviewers" , reqToken ( auth_model . AccessTokenScopeRepo ) ) .
Delete ( reqToken ( ) , bind ( api . PullReviewRequestOptions { } ) , repo . DeleteReviewRequests ) .
Delete ( bind ( api . PullReviewRequestOptions { } ) , repo . DeleteReviewRequests ) .
Post ( reqToken ( ) , bind ( api . PullReviewRequestOptions { } ) , repo . CreateReviewRequests )
Post ( bind ( api . PullReviewRequestOptions { } ) , repo . CreateReviewRequests )
} )
} )
} , mustAllowPulls , reqRepoReader ( unit . TypeCode ) , context . ReferencesGitRepo ( ) )
} , mustAllowPulls , reqRepoReader ( unit . TypeCode ) , context . ReferencesGitRepo ( ) )
m . Group ( "/statuses" , func ( ) {
m . Group ( "/statuses" , func ( ) {
m . Combo ( "/{sha}" ) . Get ( repo . GetCommitStatuses ) .
m . Combo ( "/{sha}" ) . Get ( repo . GetCommitStatuses ) .
Post ( reqToken ( ) , reqRepoWriter ( unit . TypeCode ) , bind ( api . CreateStatusOption { } ) , repo . NewCommitStatus )
Post ( reqToken ( auth_model . AccessTokenScopeRepoStatus ) , reqRepoWriter ( unit . TypeCode ) , bind ( api . CreateStatusOption { } ) , repo . NewCommitStatus )
} , reqRepoReader ( unit . TypeCode ) )
} , reqRepoReader ( unit . TypeCode ) )
m . Group ( "/commits" , func ( ) {
m . Group ( "/commits" , func ( ) {
m . Get ( "" , context . ReferencesGitRepo ( ) , repo . GetAllCommits )
m . Get ( "" , context . ReferencesGitRepo ( ) , repo . GetAllCommits )
@ -1062,7 +1096,7 @@ func Routes(ctx gocontext.Context) *web.Route {
m . Get ( "/tags/{sha}" , repo . GetAnnotatedTag )
m . Get ( "/tags/{sha}" , repo . GetAnnotatedTag )
m . Get ( "/notes/{sha}" , repo . GetNote )
m . Get ( "/notes/{sha}" , repo . GetNote )
} , context . ReferencesGitRepo ( true ) , reqRepoReader ( unit . TypeCode ) )
} , context . ReferencesGitRepo ( true ) , reqRepoReader ( unit . TypeCode ) )
m . Post ( "/diffpatch" , reqRepoWriter ( unit . TypeCode ) , reqToken ( ) , bind ( api . ApplyDiffPatchFileOptions { } ) , repo . ApplyDiffPatch )
m . Post ( "/diffpatch" , reqRepoWriter ( unit . TypeCode ) , reqToken ( auth_model . AccessTokenScopeRepo ) , bind ( api . ApplyDiffPatchFileOptions { } ) , repo . ApplyDiffPatch )
m . Group ( "/contents" , func ( ) {
m . Group ( "/contents" , func ( ) {
m . Get ( "" , repo . GetContentsList )
m . Get ( "" , repo . GetContentsList )
m . Get ( "/*" , repo . GetContents )
m . Get ( "/*" , repo . GetContents )
@ -1070,15 +1104,15 @@ func Routes(ctx gocontext.Context) *web.Route {
m . Post ( "" , bind ( api . CreateFileOptions { } ) , reqRepoBranchWriter , repo . CreateFile )
m . Post ( "" , bind ( api . CreateFileOptions { } ) , reqRepoBranchWriter , repo . CreateFile )
m . Put ( "" , bind ( api . UpdateFileOptions { } ) , reqRepoBranchWriter , repo . UpdateFile )
m . Put ( "" , bind ( api . UpdateFileOptions { } ) , reqRepoBranchWriter , repo . UpdateFile )
m . Delete ( "" , bind ( api . DeleteFileOptions { } ) , reqRepoBranchWriter , repo . DeleteFile )
m . Delete ( "" , bind ( api . DeleteFileOptions { } ) , reqRepoBranchWriter , repo . DeleteFile )
} , reqToken ( ) )
} , reqToken ( auth_model . AccessTokenScopeRepo ) )
} , reqRepoReader ( unit . TypeCode ) )
} , reqRepoReader ( unit . TypeCode ) )
m . Get ( "/signing-key.gpg" , misc . SigningKey )
m . Get ( "/signing-key.gpg" , misc . SigningKey )
m . Group ( "/topics" , func ( ) {
m . Group ( "/topics" , func ( ) {
m . Combo ( "" ) . Get ( repo . ListTopics ) .
m . Combo ( "" ) . Get ( repo . ListTopics ) .
Put ( reqToken ( ) , reqAdmin ( ) , bind ( api . RepoTopicOptions { } ) , repo . UpdateTopics )
Put ( reqToken ( auth_model . AccessTokenScopeRepo ) , reqAdmin ( ) , bind ( api . RepoTopicOptions { } ) , repo . UpdateTopics )
m . Group ( "/{topic}" , func ( ) {
m . Group ( "/{topic}" , func ( ) {
m . Combo ( "" ) . Put ( reqToken ( ) , repo . AddTopic ) .
m . Combo ( "" ) . Put ( reqToken ( auth_model . AccessTokenScopeRepo ) , repo . AddTopic ) .
Delete ( reqToken ( ) , repo . DeleteTopic )
Delete ( reqToken ( auth_model . AccessTokenScopeRepo ) , repo . DeleteTopic )
} , reqAdmin ( ) )
} , reqAdmin ( ) )
} , reqAnyRepoReader ( ) )
} , reqAnyRepoReader ( ) )
m . Get ( "/issue_templates" , context . ReferencesGitRepo ( ) , repo . GetIssueTemplates )
m . Get ( "/issue_templates" , context . ReferencesGitRepo ( ) , repo . GetIssueTemplates )
@ -1089,49 +1123,49 @@ func Routes(ctx gocontext.Context) *web.Route {
// NOTE: these are Gitea package management API - see packages.CommonRoutes and packages.DockerContainerRoutes for endpoints that implement package manager APIs
// NOTE: these are Gitea package management API - see packages.CommonRoutes and packages.DockerContainerRoutes for endpoints that implement package manager APIs
m . Group ( "/packages/{username}" , func ( ) {
m . Group ( "/packages/{username}" , func ( ) {
m . Group ( "/{type}/{name}/{version}" , func ( ) {
m . Group ( "/{type}/{name}/{version}" , func ( ) {
m . Get ( "" , packages . GetPackage )
m . Get ( "" , reqToken ( auth_model . AccessTokenScopeReadPackage ) , packages . GetPackage )
m . Delete ( "" , reqPackageAccess ( perm . AccessModeWrite ) , packages . DeletePackage )
m . Delete ( "" , reqToken ( auth_model . AccessTokenScopeDeletePackage ) , req PackageAccess ( perm . AccessModeWrite ) , packages . DeletePackage )
m . Get ( "/files" , packages . ListPackageFiles )
m . Get ( "/files" , reqToken ( auth_model . AccessTokenScopeReadPackage ) , packages . ListPackageFiles )
} )
} )
m . Get ( "/" , packages . ListPackages )
m . Get ( "/" , reqToken ( auth_model . AccessTokenScopeReadPackage ) , packages . ListPackages )
} , context_service . UserAssignmentAPI ( ) , context . PackageAssignmentAPI ( ) , reqPackageAccess ( perm . AccessModeRead ) )
} , context_service . UserAssignmentAPI ( ) , context . PackageAssignmentAPI ( ) , reqPackageAccess ( perm . AccessModeRead ) )
// Organizations
// Organizations
m . Get ( "/user/orgs" , reqToken ( ) , org . ListMyOrgs )
m . Get ( "/user/orgs" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . ListMyOrgs )
m . Group ( "/users/{username}/orgs" , func ( ) {
m . Group ( "/users/{username}/orgs" , func ( ) {
m . Get ( "" , org . ListUserOrgs )
m . Get ( "" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . ListUserOrgs )
m . Get ( "/{org}/permissions" , reqToken ( ) , org . GetUserOrgsPermissions )
m . Get ( "/{org}/permissions" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . GetUserOrgsPermissions )
} , context_service . UserAssignmentAPI ( ) )
} , context_service . UserAssignmentAPI ( ) )
m . Post ( "/orgs" , reqToken ( ) , bind ( api . CreateOrgOption { } ) , org . Create )
m . Post ( "/orgs" , reqToken ( auth_model . AccessTokenScopeWriteOrg ) , bind ( api . CreateOrgOption { } ) , org . Create )
m . Get ( "/orgs" , org . GetAll )
m . Get ( "/orgs" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . GetAll )
m . Group ( "/orgs/{org}" , func ( ) {
m . Group ( "/orgs/{org}" , func ( ) {
m . Combo ( "" ) . Get ( org . Get ) .
m . Combo ( "" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . Get ) .
Patch ( reqToken ( ) , reqOrgOwnership ( ) , bind ( api . EditOrgOption { } ) , org . Edit ) .
Patch ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , reqOrgOwnership ( ) , bind ( api . EditOrgOption { } ) , org . Edit ) .
Delete ( reqToken ( ) , reqOrgOwnership ( ) , org . Delete )
Delete ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , reqOrgOwnership ( ) , org . Delete )
m . Combo ( "/repos" ) . Get ( user . ListOrgRepos ) .
m . Combo ( "/repos" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadOrg ) , user . ListOrgRepos ) .
Post ( reqToken ( ) , bind ( api . CreateRepoOption { } ) , repo . CreateOrgRepo )
Post ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , bind ( api . CreateRepoOption { } ) , repo . CreateOrgRepo )
m . Group ( "/members" , func ( ) {
m . Group ( "/members" , func ( ) {
m . Get ( "" , org . ListMembers )
m . Get ( "" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . ListMembers )
m . Combo ( "/{username}" ) . Get ( org . IsMember ) .
m . Combo ( "/{username}" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . IsMember ) .
Delete ( reqToken ( ) , reqOrgOwnership ( ) , org . DeleteMember )
Delete ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , reqOrgOwnership ( ) , org . DeleteMember )
} )
} )
m . Group ( "/public_members" , func ( ) {
m . Group ( "/public_members" , func ( ) {
m . Get ( "" , org . ListPublicMembers )
m . Get ( "" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . ListPublicMembers )
m . Combo ( "/{username}" ) . Get ( org . IsPublicMember ) .
m . Combo ( "/{username}" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . IsPublicMember ) .
Put ( reqToken ( ) , reqOrgMembership ( ) , org . PublicizeMember ) .
Put ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , reqOrgMembership ( ) , org . PublicizeMember ) .
Delete ( reqToken ( ) , reqOrgMembership ( ) , org . ConcealMember )
Delete ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , reqOrgMembership ( ) , org . ConcealMember )
} )
} )
m . Group ( "/teams" , func ( ) {
m . Group ( "/teams" , func ( ) {
m . Get ( "" , org . ListTeams )
m . Get ( "" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . ListTeams )
m . Post ( "" , reqOrgOwnership ( ) , bind ( api . CreateTeamOption { } ) , org . CreateTeam )
m . Post ( "" , reqToken ( auth_model . AccessTokenScopeWriteOrg ) , req OrgOwnership ( ) , bind ( api . CreateTeamOption { } ) , org . CreateTeam )
m . Get ( "/search" , org . SearchTeam )
m . Get ( "/search" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . SearchTeam )
} , reqToken ( ) , req OrgMembership ( ) )
} , reqOrgMembership ( ) )
m . Group ( "/labels" , func ( ) {
m . Group ( "/labels" , func ( ) {
m . Get ( "" , org . ListLabels )
m . Get ( "" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . ListLabels )
m . Post ( "" , reqToken ( ) , reqOrgOwnership ( ) , bind ( api . CreateLabelOption { } ) , org . CreateLabel )
m . Post ( "" , reqToken ( auth_model . AccessTokenScopeWriteOrg ) , reqOrgOwnership ( ) , bind ( api . CreateLabelOption { } ) , org . CreateLabel )
m . Combo ( "/{id}" ) . Get ( org . GetLabel ) .
m . Combo ( "/{id}" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . GetLabel ) .
Patch ( reqToken ( ) , reqOrgOwnership ( ) , bind ( api . EditLabelOption { } ) , org . EditLabel ) .
Patch ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , reqOrgOwnership ( ) , bind ( api . EditLabelOption { } ) , org . EditLabel ) .
Delete ( reqToken ( ) , reqOrgOwnership ( ) , org . DeleteLabel )
Delete ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , reqOrgOwnership ( ) , org . DeleteLabel )
} )
} )
m . Group ( "/hooks" , func ( ) {
m . Group ( "/hooks" , func ( ) {
m . Combo ( "" ) . Get ( org . ListHooks ) .
m . Combo ( "" ) . Get ( org . ListHooks ) .
@ -1139,27 +1173,27 @@ func Routes(ctx gocontext.Context) *web.Route {
m . Combo ( "/{id}" ) . Get ( org . GetHook ) .
m . Combo ( "/{id}" ) . Get ( org . GetHook ) .
Patch ( bind ( api . EditHookOption { } ) , org . EditHook ) .
Patch ( bind ( api . EditHookOption { } ) , org . EditHook ) .
Delete ( org . DeleteHook )
Delete ( org . DeleteHook )
} , reqToken ( ) , reqOrgOwnership ( ) , reqWebhooksEnabled ( ) )
} , reqToken ( auth_model . AccessTokenScopeAdminOrgHook ) , reqOrgOwnership ( ) , reqWebhooksEnabled ( ) )
} , orgAssignment ( true ) )
} , orgAssignment ( true ) )
m . Group ( "/teams/{teamid}" , func ( ) {
m . Group ( "/teams/{teamid}" , func ( ) {
m . Combo ( "" ) . Get ( org . GetTeam ) .
m . Combo ( "" ) . Get ( reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . GetTeam ) .
Patch ( reqOrgOwnership ( ) , bind ( api . EditTeamOption { } ) , org . EditTeam ) .
Patch ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , req OrgOwnership ( ) , bind ( api . EditTeamOption { } ) , org . EditTeam ) .
Delete ( reqOrgOwnership ( ) , org . DeleteTeam )
Delete ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , req OrgOwnership ( ) , org . DeleteTeam )
m . Group ( "/members" , func ( ) {
m . Group ( "/members" , func ( ) {
m . Get ( "" , org . GetTeamMembers )
m . Get ( "" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . GetTeamMembers )
m . Combo ( "/{username}" ) .
m . Combo ( "/{username}" ) .
Get ( org . GetTeamMember ) .
Get ( reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . GetTeamMember ) .
Put ( reqOrgOwnership ( ) , org . AddTeamMember ) .
Put ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , req OrgOwnership ( ) , org . AddTeamMember ) .
Delete ( reqOrgOwnership ( ) , org . RemoveTeamMember )
Delete ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , req OrgOwnership ( ) , org . RemoveTeamMember )
} )
} )
m . Group ( "/repos" , func ( ) {
m . Group ( "/repos" , func ( ) {
m . Get ( "" , org . GetTeamRepos )
m . Get ( "" , reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . GetTeamRepos )
m . Combo ( "/{org}/{reponame}" ) .
m . Combo ( "/{org}/{reponame}" ) .
Put ( org . AddTeamRepository ) .
Put ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , org . AddTeamRepository ) .
Delete ( org . RemoveTeamRepository ) .
Delete ( reqToken ( auth_model . AccessTokenScopeWriteOrg ) , org . RemoveTeamRepository ) .
Get ( org . GetTeamRepo )
Get ( reqToken ( auth_model . AccessTokenScopeReadOrg ) , org . GetTeamRepo )
} )
} )
} , orgAssignment ( false , true ) , reqToken ( ) , reqTeamMembership ( ) )
} , orgAssignment ( false , true ) , reqToken ( "" ) , reqTeamMembership ( ) )
m . Group ( "/admin" , func ( ) {
m . Group ( "/admin" , func ( ) {
m . Group ( "/cron" , func ( ) {
m . Group ( "/cron" , func ( ) {
@ -1187,7 +1221,7 @@ func Routes(ctx gocontext.Context) *web.Route {
m . Post ( "/{username}/{reponame}" , admin . AdoptRepository )
m . Post ( "/{username}/{reponame}" , admin . AdoptRepository )
m . Delete ( "/{username}/{reponame}" , admin . DeleteUnadoptedRepository )
m . Delete ( "/{username}/{reponame}" , admin . DeleteUnadoptedRepository )
} )
} )
} , reqToken ( ) , reqSiteAdmin ( ) )
} , reqToken ( auth_model . AccessTokenScopeSudo ) , reqSiteAdmin ( ) )
m . Group ( "/topics" , func ( ) {
m . Group ( "/topics" , func ( ) {
m . Get ( "/search" , repo . TopicSearch )
m . Get ( "/search" , repo . TopicSearch )