Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
487d12a
First take for hiding users from explore page
sergey-dryabzhinsky Jun 4, 2021
4d194d6
Update admin user forms
sergey-dryabzhinsky Jun 4, 2021
62f2bd9
Update template for new user by admin
sergey-dryabzhinsky Jun 4, 2021
1258a6e
Add migration to list to process
sergey-dryabzhinsky Jun 4, 2021
51520a3
Format files
sergey-dryabzhinsky Jun 4, 2021
8064e02
Update swagger template
sergey-dryabzhinsky Jun 4, 2021
9d5447f
Filter users via query, not in template
sergey-dryabzhinsky Jun 5, 2021
f0b582c
Fix user edit by admin - store new field
sergey-dryabzhinsky Jun 5, 2021
266bee8
Update locale strings for user profile page
sergey-dryabzhinsky Jun 5, 2021
b419594
Hide user from public api user/userSearch by swagger, only there
sergey-dryabzhinsky Jun 6, 2021
0194b9d
Simplify userSearch limits if hide_from_explore_page set
sergey-dryabzhinsky Jun 6, 2021
1fe1a41
Check user2 too
sergey-dryabzhinsky Jun 6, 2021
9e68bb7
And add new colum for select
sergey-dryabzhinsky Jun 6, 2021
f6fbef7
Add 2 tests for api_user_search
sergey-dryabzhinsky Jun 6, 2021
71bf397
Remove useles field
sergey-dryabzhinsky Jun 6, 2021
9925724
Fix test unused/undeclared vars
sergey-dryabzhinsky Jun 6, 2021
6580f93
Fix request string formating
sergey-dryabzhinsky Jun 6, 2021
132a727
Update swapper template
sergey-dryabzhinsky Jun 6, 2021
3d74a84
Remove whitespace
sergey-dryabzhinsky Jun 6, 2021
5cb908c
Typo in fixture
sergey-dryabzhinsky Jun 6, 2021
39df5f3
Don't break old tests, use new user31
sergey-dryabzhinsky Jun 6, 2021
c38ed85
Fix unit-tests - use user31, fix fixture typo
sergey-dryabzhinsky Jun 7, 2021
5c03ff1
Pass Actor to api user search
sergey-dryabzhinsky Jun 7, 2021
0655b1f
Token auth is basic auth? Trace request from who
sergey-dryabzhinsky Jun 7, 2021
a1bae9c
Fixes for user search:
sergey-dryabzhinsky Jun 7, 2021
8b0979c
Merge branch 'main' into sergeyd-user-dont-want-exhibit-selfs
sergey-dryabzhinsky Jun 8, 2021
e1d9935
Rename migration
sergey-dryabzhinsky Jun 8, 2021
5d27211
Merge branch 'main-gitea' into sergeyd-user-dont-want-exhibit-selfs
sergey-dryabzhinsky Jun 9, 2021
f9ba4f7
Mention API searches in new locale strings
sergey-dryabzhinsky Jun 9, 2021
6bfa28e
Add note about visibility by admins
sergey-dryabzhinsky Jun 9, 2021
7066c1f
Rewrote user hiding based on Visibility field:
sergey-dryabzhinsky Jun 10, 2021
fdf1f8e
Fix lint errors
sergey-dryabzhinsky Jun 10, 2021
c80d1c8
One more step to use `Visibility` field:
sergey-dryabzhinsky Jun 10, 2021
c4c1e68
Fix test
sergey-dryabzhinsky Jun 10, 2021
9e90a73
Use edit test - new always set default visibility
sergey-dryabzhinsky Jun 10, 2021
66a0b41
One more time edit test
sergey-dryabzhinsky Jun 10, 2021
231d8ba
Next try - new user, update visibility
sergey-dryabzhinsky Jun 10, 2021
06bea36
One more try
sergey-dryabzhinsky Jun 10, 2021
aee5bd6
We can change visibility type on create - so allow it, default value …
sergey-dryabzhinsky Jun 10, 2021
cfe9ce0
Update fixture
sergey-dryabzhinsky Jun 10, 2021
efe7865
Merge branch 'main' into sergeyd-user-dont-want-exhibit-selfs
sergey-dryabzhinsky Jun 10, 2021
4fd5c86
Fix api User output?
sergey-dryabzhinsky Jun 10, 2021
16e24bd
Try to fix Visibility type conversion
sergey-dryabzhinsky Jun 10, 2021
ddc8e4c
Try to use int for visibility
sergey-dryabzhinsky Jun 11, 2021
1874740
Rewrite a little, api output for User.visibility not integer
sergey-dryabzhinsky Jun 11, 2021
ba59339
Fix swagger
sergey-dryabzhinsky Jun 11, 2021
cd70c81
Fix user test
sergey-dryabzhinsky Jun 11, 2021
96018c3
Update integrations/api_user_search_test.go
6543 Jun 15, 2021
9e051e3
Return back to string, remove zero check
sergey-dryabzhinsky Jun 16, 2021
e9e80ab
Convert visibility for API User
sergey-dryabzhinsky Jun 16, 2021
d5d20f2
Test strings now
sergey-dryabzhinsky Jun 16, 2021
d41fb82
Fixes for swagger
sergey-dryabzhinsky Jun 16, 2021
04950ca
Merge branch 'main' into sergeyd-user-dont-want-exhibit-selfs
6543 Jun 16, 2021
197f6c1
Merge branch 'master' into sergeyd-user-dont-want-exhibit-selfs
6543 Jun 16, 2021
379444f
fix
6543 Jun 16, 2021
dfe8e37
binding do not support pointer at the moment
6543 Jun 16, 2021
53ecfb5
fix TestAPIRepoTransfer
6543 Jun 16, 2021
4208b60
respect setting.Service.DefaultUserVisibilityMode
6543 Jun 16, 2021
b677e38
fix unit test :D
6543 Jun 16, 2021
994e7b9
Update new ini-option description
sergey-dryabzhinsky Jun 17, 2021
830eb28
Merge branch 'main-gitea' into sergeyd-user-dont-want-exhibit-selfs
sergey-dryabzhinsky Jun 17, 2021
87455ff
Update other ini-option description
sergey-dryabzhinsky Jun 17, 2021
06e1e73
Fix swagger template
sergey-dryabzhinsky Jun 17, 2021
a19c673
Merge branch 'main' into sergeyd-user-dont-want-exhibit-selfs
6543 Jun 18, 2021
7c95a06
Small fixes as suggested
sergey-dryabzhinsky Jun 25, 2021
f768063
Fix user_test - need to check with app-default value, fix selected va…
sergey-dryabzhinsky Jun 25, 2021
efa6ed5
Merge branch 'master' into sergeyd-user-dont-want-exhibit-selfs
6543 Jun 25, 2021
7fcb9be
User-Repos respect user Visible setting
6543 Jun 25, 2021
d04c728
Respect current User in list search
sergey-dryabzhinsky Jun 25, 2021
e4b39c2
hide user provile
6543 Jun 25, 2021
fd4f147
fix lint
6543 Jun 25, 2021
f24d3bc
Append simple visibility check to user GetInfo api
sergey-dryabzhinsky Jun 25, 2021
89255e9
Fix visibility check for api get user info:
sergey-dryabzhinsky Jun 25, 2021
79770b5
Improve the team test
zeripath Jun 26, 2021
06fbdd5
Update models/repo_permission.go
zeripath Jun 26, 2021
f258297
Merge branch 'main' into sergeyd-user-dont-want-exhibit-selfs
zeripath Jun 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions routers/api/v1/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ func GetInfo(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"

u := GetUserByParams(ctx)
if !u.IsVisibleToUser(ctx.User) {
ctx.JSON(http.StatusNotFound, nil)
Copy link
Member

@noerw noerw Jun 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must run after the ctx.Written() check below, otherwise we generate an internal server error.

Also there still is an information leak because the 404 response differs between a "true" 404, and this case.
Try the following .patch:

diff --git a/routers/api/v1/user/helper.go b/routers/api/v1/user/helper.go
index fcdac257e..a3500e0ee 100644
--- a/routers/api/v1/user/helper.go
+++ b/routers/api/v1/user/helper.go
@@ -17,7 +17,7 @@ func GetUserByParamsName(ctx *context.APIContext, name string) *models.User {
 	user, err := models.GetUserByName(username)
 	if err != nil {
 		if models.IsErrUserNotExist(err) {
-			if redirectUserID, err := models.LookupUserRedirect(username); err == nil {
+			if redirectUserID, err2 := models.LookupUserRedirect(username); err2 == nil {
 				context.RedirectToUser(ctx.Context, username, redirectUserID)
 			} else {
 				ctx.NotFound("GetUserByName", err)
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go
index 44d392c47..1cf77bea4 100644
--- a/routers/api/v1/user/user.go
+++ b/routers/api/v1/user/user.go
@@ -103,11 +103,12 @@ func GetInfo(ctx *context.APIContext) {
 	//     "$ref": "#/responses/notFound"
 
 	u := GetUserByParams(ctx)
-	if !u.IsVisibleToUser(ctx.User) {
-		ctx.JSON(http.StatusNotFound, nil)
+	if ctx.Written() {
 		return
 	}
-	if ctx.Written() {
+	if !u.IsVisibleToUser(ctx.User) {
+		// fake ErrUserNotExist error message to not leak information about existence
+		ctx.NotFound("GetUserByName", models.ErrUserNotExist{Name: ctx.Params(":username")})
 		return
 	}
 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return
}
if ctx.Written() {
return
}
Expand Down