Skip to content

Commit e3fbeda

Browse files
committed
add working example for preventing XSS
1 parent 37d2dc6 commit e3fbeda

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

README.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,36 @@ This plugin provides *Project Pages* for
2727

2828
- 0.1: tested with gitbucket 3.9
2929

30-
## Security
31-
32-
The simplistic design of this plugin suffers from XSS vulnerability,
33-
you **have to** trust your users.
34-
Or if you're really panic, nginx could be used (or any other front proxy).
35-
Suppose you use `gitbucket.local` for gitbucket and `pages.local` for pages:
36-
37-
- redirect `/[^/]+/[^/]+/pages.*` under `gitbucket.local` ot use
38-
`pages.local`
39-
- restrict `pages.local` to only have access to pages url above
30+
## Security (panic mode)
31+
32+
To prevent XSS, one must use two different domain to host pages and
33+
gitbucket. Below is a working example of nginx config to achieve that.
34+
35+
```
36+
server {
37+
listen 80;
38+
server_name git.local;
39+
40+
location ~ ^/([^/]+)/([^/]+)/pages/(.*)$ {
41+
rewrite ^/([^/]+)/([^/]+)/pages/(.*)$ http://doc.local/$1/$2/pages/$3 redirect;
42+
}
43+
44+
location / {
45+
proxy_pass 127.0.0.1:8080;
46+
}
47+
}
48+
49+
server {
50+
listen 80;
51+
server_name doc.local;
52+
53+
location ~ ^/([^/]+)/([^/]+)/(.*)$ {
54+
proxy_pass 127.0.0.1:8080;
55+
}
56+
57+
location / {
58+
return 403;
59+
}
60+
}
61+
```
4062

0 commit comments

Comments
 (0)