Commit cba0087
committed
fix: eliminate 16 SonarCloud security hotspots (S2092/S3330)
Replace cookie-based auth state passing with server-rendered data attributes
on the consent page. This eliminates all non-HttpOnly and non-Secure cookie
patterns that SonarCloud flags as security hotspots.
Previously, the consent page handler set browser cookies (auth_method,
*_redirect_url) that JavaScript read on page load. Since JS needed access,
these cookies could not be HttpOnly — triggering S3330 hotspots. Cookie
deletion calls in callbacks used Secure=false/HttpOnly=false — triggering
both S2092 and S3330.
Now the Go handler passes AuthMethod and RedirectURL via gin.H template
context. The HTML template embeds these as data-* attributes on the Alpine.js
root element. JavaScript reads from this.$el.dataset instead of cookies.
Changes:
- endpoints_oauth.go: Replace 4 SetCookie calls with gin.H template data
- endpoints_saml.go: Remove 2 cookie deletion calls (no cookies to delete)
- endpoints_oidcrp.go: Remove 2 cookie deletion calls
- endpoints_users.go: Remove 4 cookie deletion calls
- consent.html: Add data-auth-method and data-redirect-url attributes
- consent.js: Read from data attributes, remove getCookie helper1 parent bf06e78 commit cba0087
File tree
6 files changed
+19
-43
lines changed- internal/apigw
- httpserver
- staticembed
6 files changed
+19
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
| 252 | + | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
256 | 259 | | |
257 | 260 | | |
258 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | 99 | | |
103 | 100 | | |
104 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | 226 | | |
231 | 227 | | |
232 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | 210 | | |
217 | 211 | | |
218 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | 42 | | |
57 | 43 | | |
58 | 44 | | |
| |||
143 | 129 | | |
144 | 130 | | |
145 | 131 | | |
146 | | - | |
| 132 | + | |
147 | 133 | | |
148 | 134 | | |
149 | 135 | | |
| |||
226 | 212 | | |
227 | 213 | | |
228 | 214 | | |
229 | | - | |
| 215 | + | |
230 | 216 | | |
231 | | - | |
| 217 | + | |
232 | 218 | | |
233 | 219 | | |
234 | 220 | | |
| |||
240 | 226 | | |
241 | 227 | | |
242 | 228 | | |
243 | | - | |
| 229 | + | |
244 | 230 | | |
245 | | - | |
| 231 | + | |
246 | 232 | | |
247 | 233 | | |
248 | 234 | | |
| |||
257 | 243 | | |
258 | 244 | | |
259 | 245 | | |
260 | | - | |
| 246 | + | |
261 | 247 | | |
262 | | - | |
| 248 | + | |
263 | 249 | | |
264 | 250 | | |
265 | 251 | | |
| |||
0 commit comments