Commit aabd660
committed
fix: confine app tokens to the projects and scopes they were granted
An app token carried the identity of the install's author — typically an
organization owner — and only the project-scoped path capped it to the
install's granted scopes. Everywhere else it acted with the author's own
privileges, so an install could reach any endpoint its author could, including
the one that repoints its own manifest and thereby widens its own scopes.
App tokens are now denied by default and admitted only where a project context
was actually established, which is the only place the scope cap applies. That
replaces the URL regex the enablement check used to depend on: the regex
matched `/v2/projects/` alone, so the same request against `/api/project/**`
or `/api/repository/**` skipped the check and reached projects the app was
never enabled for.
Managing apps is refused outright. Those endpoints sit under the project an app
is enabled for, so the project binding alone would admit them — an install
whose grant covers project.edit could otherwise enable further apps, disable
the ones already there, or mint a token belonging to another install.
The scope cap also only existed in getCurrentPermittedScopes, so the checks
performed inside handler bodies still fell back to the author's own
permissions; they now apply the same cap. Alongside: a token inherits the
read-only state of the session that minted it, an install whose author has been
disabled no longer authenticates, an expired token is reported as expired
rather than invalid, and a manifest may not claim a baseUrl on Tolgee's own
origin — the iframe sandbox keeps `allow-scripts allow-same-origin`, which
stops isolating anything if the app is served from the origin it is framed by.1 parent 280ad5f commit aabd660
26 files changed
Lines changed: 778 additions & 142 deletions
File tree
- backend
- api/src/main/kotlin/io/tolgee/api/v2/controllers
- apps
- project
- app/src
- main/kotlin/io/tolgee/configuration
- test/kotlin/io/tolgee
- api/v2/controllers/apps
- service/apps
- data/src
- main/kotlin/io/tolgee
- constants
- repository/apps
- security/authentication
- service
- apps
- project
- security
- util
- test/kotlin/io/tolgee
- security/authentication
- unit/apps
- security/src
- main/kotlin/io/tolgee/security
- authentication
- test/kotlin/io/tolgee/security
- authentication
- authorization
Lines changed: 3 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | | - | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | 109 | | |
115 | 110 | | |
116 | 111 | | |
| |||
Lines changed: 3 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | 76 | | |
86 | 77 | | |
87 | 78 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| 129 | + | |
127 | 130 | | |
128 | 131 | | |
129 | 132 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
144 | 147 | | |
145 | 148 | | |
146 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
147 | 153 | | |
148 | 154 | | |
149 | 155 | | |
| |||
0 commit comments