mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-14 14:21:23 +00:00
Added FORCE_SERVER_CRYPTO option
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
from django.db import models
|
||||
|
||||
from seahub.base.fields import LowerCaseCharField
|
||||
from seahub.settings import FORCE_SERVER_CRYPTO
|
||||
|
||||
KEY_SERVER_CRYPTO = "server_crypto"
|
||||
VAL_SERVER_CRYPTO_ENABLED = "1"
|
||||
@@ -63,9 +64,15 @@ class UserOptionsManager(models.Manager):
|
||||
|
||||
Raise ``CryptoOptionNotSetError`` if this option is not set.
|
||||
|
||||
NOTE: Always return ``True`` if ``FORCE_SERVER_CRYPTO`` is set to
|
||||
``True``.
|
||||
|
||||
Arguments:
|
||||
- `username`:
|
||||
"""
|
||||
if FORCE_SERVER_CRYPTO is True:
|
||||
return True
|
||||
|
||||
try:
|
||||
user_option = super(UserOptionsManager, self).get(
|
||||
email=username, option_key=KEY_SERVER_CRYPTO)
|
||||
|
@@ -33,6 +33,7 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% if not force_server_crypto %}
|
||||
<div class="setting-item" id="enc-lib-setting">
|
||||
<h3>{% trans "Encrypted Libraries Setting" %}</h3>
|
||||
<form method="post" action="{% url 'options_save' %}">{% csrf_token %}
|
||||
@@ -46,6 +47,7 @@
|
||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="setting-item">
|
||||
<h3>{% trans "Sub-library Setting" %}</h3>
|
||||
|
@@ -71,6 +71,7 @@ def edit_profile(request):
|
||||
'form': form,
|
||||
'server_crypto': server_crypto,
|
||||
"sub_lib_enabled": sub_lib_enabled,
|
||||
'force_server_crypto': settings.FORCE_SERVER_CRYPTO,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
def user_profile(request, username_or_id):
|
||||
|
@@ -189,6 +189,9 @@ SHOW_REPO_DOWNLOAD_BUTTON = False
|
||||
# mininum length for password of encrypted library
|
||||
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_MAX_SIZE = 30 * 1024 * 1024
|
||||
OFFICE_PREVIEW_MAX_SIZE = 2 * 1024 * 1024
|
||||
|
@@ -14,8 +14,11 @@
|
||||
{% for error in form.errors.values %}
|
||||
{{ error|escape }}
|
||||
{% endfor %}
|
||||
|
||||
{% if not force_server_crypto %}
|
||||
{% 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>
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
{% 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, \
|
||||
get_httpserver_root, gen_dir_share_link, gen_shared_upload_link, \
|
||||
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
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -227,7 +227,8 @@ def render_repo(request, repo):
|
||||
return render_to_response('decrypt_repo_form.html', {
|
||||
'repo': repo,
|
||||
'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))
|
||||
|
||||
# query context args
|
||||
|
Reference in New Issue
Block a user