@ -79,7 +79,6 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
api "code.gitea.io/gitea/modules/structs"
@ -95,7 +94,7 @@ import (
"code.gitea.io/gitea/routers/api/v1/user"
"code.gitea.io/gitea/routers/api/v1/user"
"code.gitea.io/gitea/routers/common"
"code.gitea.io/gitea/routers/common"
"code.gitea.io/gitea/services/auth"
"code.gitea.io/gitea/services/auth"
context_service "code.gitea.io/gitea/services/context"
"code.gitea.io/gitea/services/context"
"code.gitea.io/gitea/services/forms"
"code.gitea.io/gitea/services/forms"
_ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation
_ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation
@ -855,11 +854,11 @@ func Routes() *web.Route {
m . Group ( "/user/{username}" , func ( ) {
m . Group ( "/user/{username}" , func ( ) {
m . Get ( "" , activitypub . Person )
m . Get ( "" , activitypub . Person )
m . Post ( "/inbox" , activitypub . ReqHTTPSignature ( ) , activitypub . PersonInbox )
m . Post ( "/inbox" , activitypub . ReqHTTPSignature ( ) , activitypub . PersonInbox )
} , context_service . UserAssignmentAPI ( ) )
} , context . UserAssignmentAPI ( ) )
m . Group ( "/user-id/{user-id}" , func ( ) {
m . Group ( "/user-id/{user-id}" , func ( ) {
m . Get ( "" , activitypub . Person )
m . Get ( "" , activitypub . Person )
m . Post ( "/inbox" , activitypub . ReqHTTPSignature ( ) , activitypub . PersonInbox )
m . Post ( "/inbox" , activitypub . ReqHTTPSignature ( ) , activitypub . PersonInbox )
} , context_service . UserIDAssignmentAPI ( ) )
} , context . UserIDAssignmentAPI ( ) )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryActivityPub ) )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryActivityPub ) )
}
}
@ -915,7 +914,7 @@ func Routes() *web.Route {
} , reqSelfOrAdmin ( ) , reqBasicOrRevProxyAuth ( ) )
} , reqSelfOrAdmin ( ) , reqBasicOrRevProxyAuth ( ) )
m . Get ( "/activities/feeds" , user . ListUserActivityFeeds )
m . Get ( "/activities/feeds" , user . ListUserActivityFeeds )
} , context_service . UserAssignmentAPI ( ) , individualPermsChecker )
} , context . UserAssignmentAPI ( ) , individualPermsChecker )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryUser ) )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryUser ) )
// Users (requires user scope)
// Users (requires user scope)
@ -933,7 +932,7 @@ func Routes() *web.Route {
m . Get ( "/starred" , user . GetStarredRepos )
m . Get ( "/starred" , user . GetStarredRepos )
m . Get ( "/subscriptions" , user . GetWatchedRepos )
m . Get ( "/subscriptions" , user . GetWatchedRepos )
} , context_service . UserAssignmentAPI ( ) )
} , context . UserAssignmentAPI ( ) )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryUser ) , reqToken ( ) )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryUser ) , reqToken ( ) )
// Users (requires user scope)
// Users (requires user scope)
@ -968,7 +967,7 @@ func Routes() *web.Route {
m . Get ( "" , user . CheckMyFollowing )
m . Get ( "" , user . CheckMyFollowing )
m . Put ( "" , user . Follow )
m . Put ( "" , user . Follow )
m . Delete ( "" , user . Unfollow )
m . Delete ( "" , user . Unfollow )
} , context_service . UserAssignmentAPI ( ) )
} , context . UserAssignmentAPI ( ) )
} )
} )
// (admin:public_key scope)
// (admin:public_key scope)
@ -1415,14 +1414,14 @@ func Routes() *web.Route {
m . Get ( "/files" , reqToken ( ) , packages . ListPackageFiles )
m . Get ( "/files" , reqToken ( ) , packages . ListPackageFiles )
} )
} )
m . Get ( "/" , reqToken ( ) , packages . ListPackages )
m . Get ( "/" , reqToken ( ) , packages . ListPackages )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryPackage ) , context_service . UserAssignmentAPI ( ) , context . PackageAssignmentAPI ( ) , reqPackageAccess ( perm . AccessModeRead ) )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryPackage ) , context . UserAssignmentAPI ( ) , context . PackageAssignmentAPI ( ) , reqPackageAccess ( perm . AccessModeRead ) )
// Organizations
// Organizations
m . Get ( "/user/orgs" , reqToken ( ) , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryUser , auth_model . AccessTokenScopeCategoryOrganization ) , org . ListMyOrgs )
m . Get ( "/user/orgs" , reqToken ( ) , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryUser , auth_model . AccessTokenScopeCategoryOrganization ) , org . ListMyOrgs )
m . Group ( "/users/{username}/orgs" , func ( ) {
m . Group ( "/users/{username}/orgs" , func ( ) {
m . Get ( "" , reqToken ( ) , org . ListUserOrgs )
m . Get ( "" , reqToken ( ) , org . ListUserOrgs )
m . Get ( "/{org}/permissions" , reqToken ( ) , org . GetUserOrgsPermissions )
m . Get ( "/{org}/permissions" , reqToken ( ) , org . GetUserOrgsPermissions )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryUser , auth_model . AccessTokenScopeCategoryOrganization ) , context_service . UserAssignmentAPI ( ) )
} , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryUser , auth_model . AccessTokenScopeCategoryOrganization ) , context . UserAssignmentAPI ( ) )
m . Post ( "/orgs" , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryOrganization ) , reqToken ( ) , bind ( api . CreateOrgOption { } ) , org . Create )
m . Post ( "/orgs" , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryOrganization ) , reqToken ( ) , bind ( api . CreateOrgOption { } ) , org . Create )
m . Get ( "/orgs" , org . GetAll , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryOrganization ) )
m . Get ( "/orgs" , org . GetAll , tokenRequiresScopes ( auth_model . AccessTokenScopeCategoryOrganization ) )
m . Group ( "/orgs/{org}" , func ( ) {
m . Group ( "/orgs/{org}" , func ( ) {
@ -1520,7 +1519,7 @@ func Routes() *web.Route {
m . Post ( "/orgs" , bind ( api . CreateOrgOption { } ) , admin . CreateOrg )
m . Post ( "/orgs" , bind ( api . CreateOrgOption { } ) , admin . CreateOrg )
m . Post ( "/repos" , bind ( api . CreateRepoOption { } ) , admin . CreateRepo )
m . Post ( "/repos" , bind ( api . CreateRepoOption { } ) , admin . CreateRepo )
m . Post ( "/rename" , bind ( api . RenameUserOption { } ) , admin . RenameUser )
m . Post ( "/rename" , bind ( api . RenameUserOption { } ) , admin . RenameUser )
} , context_service . UserAssignmentAPI ( ) )
} , context . UserAssignmentAPI ( ) )
} )
} )
m . Group ( "/emails" , func ( ) {
m . Group ( "/emails" , func ( ) {
m . Get ( "" , admin . GetAllEmails )
m . Get ( "" , admin . GetAllEmails )