File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -85,9 +85,17 @@ config = {
85
85
##
86
86
# 'userdata-root-path': '/opt/0-hub/public',
87
87
# 'workdir-root-path': '/opt/0-hub/workdir',
88
-
88
+
89
+ ## In order to host a hub which is a mirror of another
90
+ ## hub, since hub right now don't support multiple master,
91
+ ## you should enable this read-only mode to avoid modifying
92
+ ## your local database and be able to stay synced with your
93
+ ## main hub instance. For a normal or main hub instance,
94
+ ## keep this setting to False
95
+ 'readonly': False,
96
+
89
97
## By default, the hub is made to be used publicly
90
- ## and needs to be protected (with itsyou.online )
98
+ ## and needs to be protected (with threefold connect )
91
99
##
92
100
## If you are running a local test hub on your local
93
101
## network and you don't have any security issue, you
Original file line number Diff line number Diff line change @@ -272,6 +272,13 @@ def logout():
272
272
def login_method ():
273
273
return internalRedirect ("logins.html" )
274
274
275
+ @app .route ('/readonly' )
276
+ def read_only_mode ():
277
+ if not config ['readonly' ]:
278
+ return redirect ("/" )
279
+
280
+ return globalTemplate ("readonly.html" , {})
281
+
275
282
@app .route ('/login-iyo' )
276
283
@hub .itsyouonline .force_login ()
277
284
def login_iyo ():
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ def apicall():
8
8
def decorator (handler ):
9
9
@wraps (handler )
10
10
def _wrapper (* args , ** kwargs ):
11
+ if config ['readonly' ]:
12
+ return jsonify ({"message" : "readonly mode" , "status" : "error" }), 400
13
+
11
14
if not config ['authentication' ]:
12
15
session ['accounts' ] = ['Administrator' ]
13
16
session ['username' ] = 'Administrator'
@@ -48,6 +51,9 @@ def protected():
48
51
def decorator (handler ):
49
52
@wraps (handler )
50
53
def _wrapper (* args , ** kwargs ):
54
+ if config ['readonly' ]:
55
+ return redirect ("/readonly" )
56
+
51
57
if not config ['authentication' ]:
52
58
session ['accounts' ] = ['Administrator' ]
53
59
session ['username' ] = 'Administrator'
Original file line number Diff line number Diff line change
1
+ {% extends "layout.html" %}
2
+ {% block title %}Zero-OS Hub{% endblock %}
3
+
4
+ {% block content %}
5
+ < div class ="jumbotron ">
6
+ < div class ="container ">
7
+ < h1 > Instance modification disabled</ h1 >
8
+ < p > This Hub instance doesn't allow modification, this is a < code > read-only hub instance</ code > .</ p >
9
+ < p > This is probably a mirror of a main instance, you should point to that one, or
10
+ this instance is a special serve-only instance.< p >
11
+ </ div >
12
+ </ div >
13
+ {% endblock %}
You can’t perform that action at this time.
0 commit comments