File tree 3 files changed +31
-1
lines changed
fr/brouillard/gitbucket/h2/controller
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,9 @@ sbt clean package
66
66
67
67
### 1.4.0
68
68
69
- - compatibility with gitbucket 4.10, scala 2.12
69
+ - compatibility with gitbucket 4.10, scala 2.12 [ #20 ] ( https://github.com/gitbucket-plugins/gitbucket-h2-backup-plugin/issues/20 )
70
+ - allow to secure ` database/backup ` endpoint [ #1 ] ( https://github.com/gitbucket-plugins/gitbucket-h2-backup-plugin/issues/1 ) ,[ #19 ] ( https://github.com/gitbucket-plugins/gitbucket-h2-backup-plugin/issues/19 )
71
+ see [ Securing backup endpoint] ( #securing-backup-endpoint ) paragraph
70
72
71
73
### 1.3.0
72
74
@@ -86,3 +88,15 @@ sbt clean package
86
88
87
89
- introduce gitbucket-h2-backup-plugin
88
90
- allows to backup h2 database via a live dump
91
+
92
+ ## Securing backup endpoint
93
+
94
+ In version 1.4.0, it is possible to secure the ` database/backup ` endpoint:
95
+
96
+ - launch gitbucket with System property _ secure.backup_ set to true (for example ` -Dsecure.backup=true ` on the command line)
97
+ - due to actual limitations of gibucket & plugins security, once the previous setting is activated,
98
+ a call to ` http://YOUR_GITBUCKET/database/backup ` will be temporary redirected ` http://YOUR_GITBUCKET/api/v3/plugins/database/backup ` .
99
+ You have to follow this temporary redirection.
100
+ - if you call the endpoint using _ httpie_ , use the ` --follow ` parameter
101
+ - this secured endpoint route is TEMPORARY you should not call it directly.
102
+ If you do think that it will change in the future when gitbucket will support secured routes for plugins.
Original file line number Diff line number Diff line change @@ -25,5 +25,6 @@ class Plugin extends gitbucket.core.plugin.Plugin {
25
25
override val controllers = Seq (
26
26
" /admin/h2backup" -> new H2BackupController ()
27
27
, " /database/backup" -> new H2BackupController ()
28
+ , " /api/v3/plugins/database/backup" -> new H2BackupController ()
28
29
)
29
30
}
Original file line number Diff line number Diff line change @@ -41,7 +41,22 @@ class H2BackupController extends ControllerBase with AdminAuthenticator {
41
41
html.export(flash.get(" info" ), flash.get(" dest" ).orElse(Some (defaultBackupFileName())));
42
42
})
43
43
44
+ get(" /api/v3/plugins/database/backup" ) {
45
+ context.loginAccount match {
46
+ case Some (x) if (x.isAdmin) => doExport()
47
+ case _ => org.scalatra.Unauthorized ()
48
+ }
49
+ }
50
+
44
51
get(" /database/backup" ) {
52
+ if (sys.props.get(" secure.backup" ) exists (_ equalsIgnoreCase " true" ))
53
+ org.scalatra.TemporaryRedirect (" /api/v3/plugins/database/backup?dest=" + params.getOrElse(" dest" , defaultBackupFileName()))
54
+ else {
55
+ doExport()
56
+ }
57
+ }
58
+
59
+ private def doExport (): Unit = {
45
60
val filePath : String = params.getOrElse(" dest" , defaultBackupFileName())
46
61
exportDatabase(new File (filePath))
47
62
Ok (" done: " + filePath)
You can’t perform that action at this time.
0 commit comments