Skip to content

Users in owner team get 404 when accessing organisation repos #4867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 7 tasks
cybrwshl opened this issue Sep 4, 2018 · 8 comments
Closed
2 of 7 tasks

Users in owner team get 404 when accessing organisation repos #4867

cybrwshl opened this issue Sep 4, 2018 · 8 comments

Comments

@cybrwshl
Copy link

cybrwshl commented Sep 4, 2018

  • Gitea version (or commit ref): 38d8b8c
  • Git version: 2.15.2
  • Operating system: Alpine (gitea/gitea:1.5.1)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

Users that are in the owner team of a organisation get a 404 error if they try to access a repository of their organisaton. The gitea log shows the following messages:

... [...routers/repo/view.go:299 Home()] [E] Home: Du hast keine Berechtigung, um auf irgendeinen Bereich dieses Repositories zuzugreifen.

The users are only in this team and organisation. All broken repos belong to the same organisation. With a administrator user it is possible to use this repos without any problems.

EDIT:
Maybe this problem is related to #2686 .

EDIT2:
content of table repo_unit:

+-----+---------+------+--------------------------------------------------------------------+--------------+
| id  | repo_id | type | config                                                             | created_unix |
+-----+---------+------+--------------------------------------------------------------------+--------------+
| 267 |      43 |    1 | NULL                                                               |   1535012857 |
| 268 |      43 |    2 | {"EnableTimetracker":true,"AllowOnlyContributorsToTrackTime":true} |   1535012857 |
| 269 |      43 |    3 | NULL                                                               |   1535012857 |
| 270 |      43 |    4 | NULL                                                               |   1535012857 |
| 271 |      43 |    5 | NULL                                                               |   1535012857 |
+-----+---------+------+--------------------------------------------------------------------+--------------+
@OndrejSpanel
Copy link

I can see the same issue with a freshly installed Gitea version 1.5.1

The users can access other users private repositories when assigned as colaborators, but I cannot assign them as collaborators to an organization repository, when I attempt to do that I get error "The user is an organization member who cannot be added as a collaborator."

The error in the log is:

2018/09/06 11:24:01 [...routers/repo/http.go:217 HTTP()] [E] User XXXXX does not have allowed access to repository /home/gitea/gitea-repositories/nnnnn/nnnnn_private.git 's code

@lunny
Copy link
Member

lunny commented Sep 7, 2018

@OndrejSpanel #4814 will resolve your problem. But your problem is different from this one.

@cybrwshl
Copy link
Author

Are there any further information that I should provide you? Or something I could check?

@cybrwshl
Copy link
Author

I solved the problem by myself. The table team_unit was completly empty, so inserted the needed entries for all owner teams.

@nuno-silva
Copy link
Contributor

I have upgraded from gitea 1.4.3 to 1.5.2 and am experiencing this problem. My team_unit table is empty.
@lunny has this been fixed in any version/commit prior to 1.5.2? Should I do as @cybrwshl and insert the entries manually? 😢

@lafriks
Copy link
Member

lafriks commented Oct 14, 2018

@nuno-silva I believe so :(

@lunny
Copy link
Member

lunny commented Oct 15, 2018

@nuno-silva as @lafriks said.

@nuno-silva
Copy link
Contributor

So I've tracked this down to commit 0b3ea42 (as part of #4034).
It seems like the team_unit table was added in this commit (or 1.5.0) and seems to have replaced the team.unit_types column.
The "move team units to team_unit table" migration should have populated the team_unit when I upgraded (in my case, from 1.4.3 to 1.5.2), right?

// v69 -> v70
NewMigration("move team units to team_unit table", moveTeamUnitsToTeamUnitTable),

I've just done a new migration (on another instance) from gitea 1.4.1 to 1.5.2 and it worked 😆 😕 . I fixed the other instance manually :/

For future reference, if you have this issue, what needs to be done is to turn each of the numbers in unit_types (for each row) from

select id as team_id,org_id,unit_types from team where unit_types is not NULL and unit_types like '%[%]%';

into an entry in the team_unit table.

For example:

MariaDB [gitea]> select id as team_id,org_id,unit_types from team where unit_types is not NULL and unit_types like '%[%]%';
+---------+--------+-----------------+
| team_id | org_id | unit_types      |
+---------+--------+-----------------+
|  1      |      3 | [1,2,3,4,5,6,7] |
+---------+--------+-----------------+
1 row in set (0.02 sec)

would be

MariaDB [gitea]> select * from team_unit;
+----+--------+---------+------+
| id | org_id | team_id | type |
+----+--------+---------+------+
|  1 |      3 |       1 |    1 |
|  2 |      3 |       1 |    2 |
|  3 |      3 |       1 |    3 |
|  4 |      3 |       1 |    4 |
|  5 |      3 |       1 |    5 |
|  6 |      3 |       1 |    6 |
|  7 |      3 |       1 |    7 |
+----+--------+---------+------+
7 rows in set (0.00 sec)

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants