mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-15 06:44:16 +00:00
Added FORCE_SERVER_CRYPTO option
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from seahub.base.fields import LowerCaseCharField
|
from seahub.base.fields import LowerCaseCharField
|
||||||
|
from seahub.settings import FORCE_SERVER_CRYPTO
|
||||||
|
|
||||||
KEY_SERVER_CRYPTO = "server_crypto"
|
KEY_SERVER_CRYPTO = "server_crypto"
|
||||||
VAL_SERVER_CRYPTO_ENABLED = "1"
|
VAL_SERVER_CRYPTO_ENABLED = "1"
|
||||||
@@ -62,10 +63,16 @@ class UserOptionsManager(models.Manager):
|
|||||||
server crypto is enabled, otherwise ``False``.
|
server crypto is enabled, otherwise ``False``.
|
||||||
|
|
||||||
Raise ``CryptoOptionNotSetError`` if this option is not set.
|
Raise ``CryptoOptionNotSetError`` if this option is not set.
|
||||||
|
|
||||||
|
NOTE: Always return ``True`` if ``FORCE_SERVER_CRYPTO`` is set to
|
||||||
|
``True``.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- `username`:
|
- `username`:
|
||||||
"""
|
"""
|
||||||
|
if FORCE_SERVER_CRYPTO is True:
|
||||||
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_option = super(UserOptionsManager, self).get(
|
user_option = super(UserOptionsManager, self).get(
|
||||||
email=username, option_key=KEY_SERVER_CRYPTO)
|
email=username, option_key=KEY_SERVER_CRYPTO)
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if not force_server_crypto %}
|
||||||
<div class="setting-item" id="enc-lib-setting">
|
<div class="setting-item" id="enc-lib-setting">
|
||||||
<h3>{% trans "Encrypted Libraries Setting" %}</h3>
|
<h3>{% trans "Encrypted Libraries Setting" %}</h3>
|
||||||
<form method="post" action="{% url 'options_save' %}">{% csrf_token %}
|
<form method="post" action="{% url 'options_save' %}">{% csrf_token %}
|
||||||
@@ -46,6 +47,7 @@
|
|||||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="setting-item">
|
<div class="setting-item">
|
||||||
<h3>{% trans "Sub-library Setting" %}</h3>
|
<h3>{% trans "Sub-library Setting" %}</h3>
|
||||||
|
@@ -71,6 +71,7 @@ def edit_profile(request):
|
|||||||
'form': form,
|
'form': form,
|
||||||
'server_crypto': server_crypto,
|
'server_crypto': server_crypto,
|
||||||
"sub_lib_enabled": sub_lib_enabled,
|
"sub_lib_enabled": sub_lib_enabled,
|
||||||
|
'force_server_crypto': settings.FORCE_SERVER_CRYPTO,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
def user_profile(request, username_or_id):
|
def user_profile(request, username_or_id):
|
||||||
|
@@ -189,6 +189,9 @@ SHOW_REPO_DOWNLOAD_BUTTON = False
|
|||||||
# mininum length for password of encrypted library
|
# mininum length for password of encrypted library
|
||||||
REPO_PASSWORD_MIN_LENGTH = 6
|
REPO_PASSWORD_MIN_LENGTH = 6
|
||||||
|
|
||||||
|
# Using server side crypto by default, otherwise, let user choose crypto method.
|
||||||
|
FORCE_SERVER_CRYPTO = True
|
||||||
|
|
||||||
# File preview
|
# File preview
|
||||||
FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
|
FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
|
||||||
OFFICE_PREVIEW_MAX_SIZE = 2 * 1024 * 1024
|
OFFICE_PREVIEW_MAX_SIZE = 2 * 1024 * 1024
|
||||||
|
@@ -14,8 +14,11 @@
|
|||||||
{% for error in form.errors.values %}
|
{% for error in form.errors.values %}
|
||||||
{{ error|escape }}
|
{{ error|escape }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if not force_server_crypto %}
|
||||||
{% url 'edit_profile' as profile_edit_url %}
|
{% url 'edit_profile' as profile_edit_url %}
|
||||||
<p class="tip" style="margin-top:3em;">{% blocktrans %}You can change how to view encrypted libraries online <a class="normal" href="{{ profile_edit_url }}#enc-lib-setting">here</a>.{% endblocktrans %}</p>
|
<p class="tip" style="margin-top:3em;">{% blocktrans %}You can change how to view encrypted libraries online <a class="normal" href="{{ profile_edit_url }}#enc-lib-setting">here</a>.{% endblocktrans %}</p>
|
||||||
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -22,7 +22,7 @@ from seahub.views import gen_path_link, get_user_permission, get_repo_dirents, \
|
|||||||
from seahub.utils import get_ccnetapplet_root, gen_file_upload_url, \
|
from seahub.utils import get_ccnetapplet_root, gen_file_upload_url, \
|
||||||
get_httpserver_root, gen_dir_share_link, gen_shared_upload_link, \
|
get_httpserver_root, gen_dir_share_link, gen_shared_upload_link, \
|
||||||
get_max_upload_file_size
|
get_max_upload_file_size
|
||||||
from seahub.settings import ENABLE_SUB_LIBRARY
|
from seahub.settings import ENABLE_SUB_LIBRARY, FORCE_SERVER_CRYPTO
|
||||||
|
|
||||||
# Get an instance of a logger
|
# Get an instance of a logger
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -227,7 +227,8 @@ def render_repo(request, repo):
|
|||||||
return render_to_response('decrypt_repo_form.html', {
|
return render_to_response('decrypt_repo_form.html', {
|
||||||
'repo': repo,
|
'repo': repo,
|
||||||
'next': get_next_url_from_request(request) or \
|
'next': get_next_url_from_request(request) or \
|
||||||
reverse('repo', args=[repo.id])
|
reverse('repo', args=[repo.id]),
|
||||||
|
'force_server_crypto': FORCE_SERVER_CRYPTO,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
# query context args
|
# query context args
|
||||||
|
Reference in New Issue
Block a user