Seahub Settings

Note: You can also modify most of the config items via web interface. The config items are saved in database table (seahub-db/constance_config). They have a higher priority over the items in config files. If you want to disable settings via web interface, you can add ENABLE_SETTINGS_VIA_WEB = False to seahub_settings.py.

Sending Email Notifications on Seahub

Refer to email sending documentation.

Memcached

Seahub caches items(avatars, profiles, etc) on file system by default(/tmp/seahub_cache/). You can replace with Memcached.

Refer to “add memcached”.

Security settings

  1. # For security consideration, please set to match the host/domain of your site, e.g., ALLOWED_HOSTS = ['.example.com'].
  2. # Please refer https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts for details.
  3. ALLOWED_HOSTS = ['.myseafile.com']

User management options

The following options affect user registration, password and session.

  1. # Enalbe or disalbe registration on web. Default is `False`.
  2. ENABLE_SIGNUP = False
  3. # Activate or deactivate user when registration complete. Default is `True`.
  4. # If set to `False`, new users need to be activated by admin in admin panel.
  5. ACTIVATE_AFTER_REGISTRATION = False
  6. # Whether to send email when a system admin adding a new member. Default is `True`.
  7. SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
  8. # Whether to send email when a system admin resetting a user's password. Default is `True`.
  9. SEND_EMAIL_ON_RESETTING_USER_PASSWD = True
  10. # Send system admin notify email when user registration is complete. Default is `False`.
  11. NOTIFY_ADMIN_AFTER_REGISTRATION = True
  12. # Remember days for login. Default is 7
  13. LOGIN_REMEMBER_DAYS = 7
  14. # Attempt limit before showing a captcha when login.
  15. LOGIN_ATTEMPT_LIMIT = 3
  16. # deactivate user account when login attempts exceed limit
  17. # Since version 5.1.2 or pro 5.1.3
  18. FREEZE_USER_ON_LOGIN_FAILED = False
  19. # mininum length for user's password
  20. USER_PASSWORD_MIN_LENGTH = 6
  21. # LEVEL based on four types of input:
  22. # num, upper letter, lower letter, other symbols
  23. # '3' means password must have at least 3 types of the above.
  24. USER_PASSWORD_STRENGTH_LEVEL = 3
  25. # default False, only check USER_PASSWORD_MIN_LENGTH
  26. # when True, check password strength level, STRONG(or above) is allowed
  27. USER_STRONG_PASSWORD_REQUIRED = False
  28. # Force user to change password when admin add/reset a user.
  29. # Added in 5.1.1, deafults to True.
  30. FORCE_PASSWORD_CHANGE = True
  31. # Age of cookie, in seconds (default: 2 weeks).
  32. SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
  33. # Whether a user's session cookie expires when the Web browser is closed.
  34. SESSION_EXPIRE_AT_BROWSER_CLOSE = False
  35. # Whether to save the session data on every request. Default is `False`
  36. SESSION_SAVE_EVERY_REQUEST = False
  37. # Whether enable personal wiki and group wiki. Default is `False`
  38. # Since 6.1.0 CE
  39. ENABLE_WIKI = True

repo snapshot label feature

  1. # Turn on this option to let users to add a label to a library snapshot. Default is `False`
  2. ENABLE_REPO_SNAPSHOT_LABEL = False

Library options

Options for libraries:

  1. # mininum length for password of encrypted library
  2. REPO_PASSWORD_MIN_LENGTH = 8
  3. # mininum length for password for share link (since version 4.4)
  4. SHARE_LINK_PASSWORD_MIN_LENGTH = 8
  5. # Disable sync with any folder. Default is `False`
  6. # NOTE: since version 4.2.4
  7. DISABLE_SYNC_WITH_ANY_FOLDER = True
  8. # Enable or disable library history setting
  9. ENABLE_REPO_HISTORY_SETTING = True
  10. # Enable or disable normal user to create organization libraries
  11. # Since version 5.0.5
  12. ENABLE_USER_CREATE_ORG_REPO = True
  13. # Enable or disable user share library to any group
  14. # Since version 6.2.0
  15. ENABLE_SHARE_TO_ALL_GROUPS = True

Options for online file preview:

  1. # Whether to use pdf.js to view pdf files online. Default is `True`, you can turn it off.
  2. # NOTE: since version 1.4.
  3. USE_PDFJS = True
  4. # Online preview maximum file size, defaults to 30M.
  5. # Note, this option controls files that can be previewed online, like pictures, txt, pdf.
  6. # In pro edition, for preview doc/ppt/excel/pdf, there is another option `max-size`
  7. # in seafevents.conf that controls the limit of files that can be previewed.
  8. FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
  9. # Extensions of previewed text files.
  10. # NOTE: since version 6.1.1
  11. TEXT_PREVIEW_EXT = """ac, am, bat, c, cc, cmake, cpp, cs, css, diff, el, h, html,
  12. htm, java, js, json, less, make, org, php, pl, properties, py, rb,
  13. scala, script, sh, sql, txt, text, tex, vi, vim, xhtml, xml, log, csv,
  14. groovy, rst, patch, go"""
  15. # Enable or disable thumbnails
  16. # NOTE: since version 4.0.2
  17. ENABLE_THUMBNAIL = True
  18. # Seafile only generates thumbnails for images smaller than the following size.
  19. THUMBNAIL_IMAGE_SIZE_LIMIT = 30 # MB
  20. # Enable or disable thumbnail for video. ffmpeg and moviepy should be installed first.
  21. # For details, please refer to https://manual.seafile.com/deploy/video_thumbnails.html
  22. # NOTE: since version 6.1
  23. ENABLE_VIDEO_THUMBNAIL = False
  24. # Use the frame at 5 second as thumbnail
  25. THUMBNAIL_VIDEO_FRAME_TIME = 5
  26. # Absolute filesystem path to the directory that will hold thumbnail files.
  27. THUMBNAIL_ROOT = '/haiwen/seahub-data/thumbnail/thumb/'
  28. # Default size for picture preview. Enlarge this size can improve the preview quality.
  29. # NOTE: since version 6.1.1
  30. THUMBNAIL_SIZE_FOR_ORIGINAL = 1024

Cloud Mode

You should enable cloud mode if you use Seafile with an unknown user base. It disables the organization tab in Seahub’s website to ensure that users can’t access the user list. Cloud mode provides some nice features like sharing content with unregistered users and sending invitations to them. Therefore you also want to enable user registration. Through the global address book (since version 4.2.3) you can do a search for every user account. So you probably want to disable it.

  1. # Enable cloude mode and hide `Organization` tab.
  2. CLOUD_MODE = True
  3. # Disable global address book
  4. ENABLE_GLOBAL_ADDRESSBOOK = False

External authentication

  1. # Enable authentication with ADFS
  2. # Default is False
  3. # Since 6.0.9
  4. ENABLE_ADFS_LOGIN = True
  5. # Enable authentication wit Kerberos
  6. # Default is False
  7. ENABLE_KRB5_LOGIN = True
  8. # Enable authentication with Shibboleth
  9. # Default is False
  10. ENABLE_SHIBBOLETH_LOGIN = True

Other options

  1. # Disable settings via Web interface in system admin->settings
  2. # Default is True
  3. # Since 5.1.3
  4. ENABLE_SETTINGS_VIA_WEB = False
  5. # Choices can be found here:
  6. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  7. # although not all choices may be available on all operating systems.
  8. # If running in a Windows environment this must be set to the same as your
  9. # system time zone.
  10. TIME_ZONE = 'UTC'
  11. # Language code for this installation. All choices can be found here:
  12. # http://www.i18nguy.com/unicode/language-identifiers.html
  13. # Default language for sending emails.
  14. LANGUAGE_CODE = 'en'
  15. # Custom language code choice.
  16. LANGUAGES = (
  17. ('en', 'English'),
  18. ('zh-cn', '简体中文'),
  19. ('zh-tw', '繁體中文'),
  20. )
  21. # Set this to your website/company's name. This is contained in email notifications and welcome message when user login for the first time.
  22. SITE_NAME = 'Seafile'
  23. # Browser tab's title
  24. SITE_TITLE = 'Private Seafile'
  25. # If you don't want to run seahub website on your site's root path, set this option to your preferred path.
  26. # e.g. setting it to '/seahub/' would run seahub on http://example.com/seahub/.
  27. SITE_ROOT = '/'
  28. # Max number of files when user upload file/folder.
  29. # Since version 6.0.4
  30. MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD = 500
  31. # Control the language that send email. Default to user's current language.
  32. # Since version 6.1.1
  33. SHARE_LINK_EMAIL_LANGUAGE = ''
  34. # Interval for browser requests unread notifications
  35. # Since PRO 6.1.4 or CE 6.1.2
  36. UNREAD_NOTIFICATIONS_REQUEST_INTERVAL = 3 * 60 # seconds

Pro edition only options

  1. # Whether to show the used traffic in user's profile popup dialog. Default is True
  2. SHOW_TRAFFIC = True
  3. # Allow administrator to view user's file in UNENCRYPTED libraries
  4. # through Libraries page in System Admin. Default is False.
  5. ENABLE_SYS_ADMIN_VIEW_REPO = True
  6. # For un-login users, providing an email before downloading or uploading on shared link page.
  7. # Since version 5.1.4
  8. ENABLE_SHARE_LINK_AUDIT = True
  9. # Check virus after upload files to shared upload links. Defaults to `False`.
  10. # Since version 6.0
  11. ENABLE_UPLOAD_LINK_VIRUS_CHECK = True
  12. # Enable system admin add T&C, all users need to accept terms before using. Defaults to `False`.
  13. # Since version 6.0
  14. ENABLE_TERMS_AND_CONDITIONS = True
  15. # Enable two factor authentication for accounts. Defaults to `False`.
  16. # Since version 6.0
  17. ENABLE_TWO_FACTOR_AUTH = True
  18. # Enable user select a template when he/she creates library.
  19. # When user select a template, Seafile will create folders releated to the pattern automaticly.
  20. # Since version 6.0
  21. LIBRARY_TEMPLATES = {
  22. 'Technology': ['/Develop/Python', '/Test'],
  23. 'Finance': ['/Current assets', '/Fixed assets/Computer']
  24. }
  25. # Send email to these email addresses when a virus is detected.
  26. # This list can be any valid email address, not necessarily the emails of Seafile user.
  27. # Since version 6.0.8
  28. VIRUS_SCAN_NOTIFY_LIST = ['user_a@seafile.com', 'user_b@seafile.com']

RESTful API

  1. # API throttling related settings. Enlarger the rates if you got 429 response code during API calls.
  2. REST_FRAMEWORK = {
  3. 'DEFAULT_THROTTLE_RATES': {
  4. 'ping': '600/minute',
  5. 'anon': '5/minute',
  6. 'user': '300/minute',
  7. },
  8. 'UNICODE_JSON': False,
  9. }
  10. # Throtting whitelist used to disable throttle for certain IPs.
  11. # e.g. REST_FRAMEWORK_THROTTING_WHITELIST = ['127.0.0.1', '192.168.1.1']
  12. # Please make sure `REMOTE_ADDR` header is configured in Nginx conf according to https://manual.seafile.com/deploy/deploy_with_nginx.html.
  13. REST_FRAMEWORK_THROTTING_WHITELIST = []

Seahub Custom Functions

Since version 6.2, you can define a custom function to modify the result of user search function.

For example, if you want to limit user only search users in the same institution, you can define custom_search_user function in {seafile install path}/conf/seahub_custom_functions/__init__.py

Code example:

  1. import os
  2. import sys
  3. current_path = os.path.dirname(os.path.abspath(__file__))
  4. seahub_dir = os.path.join(current_path, \
  5. '../../seafile-server-latest/seahub/seahub')
  6. sys.path.append(seahub_dir)
  7. from seahub.profile.models import Profile
  8. def custom_search_user(request, emails):
  9. institution_name = ''
  10. username = request.user.username
  11. profile = Profile.objects.get_profile_by_user(username)
  12. if profile:
  13. institution_name = profile.institution
  14. inst_users = [p.user for p in
  15. Profile.objects.filter(institution=institution_name)]
  16. filtered_emails = []
  17. for email in emails:
  18. if email in inst_users:
  19. filtered_emails.append(email)
  20. return filtered_emails

NOTE, you should NOT change the name of custom_search_user and seahub_custom_functions/__init__.py

Since version 6.2.5 pro, if you enable the ENABLE_SHARE_TO_ALL_GROUPS feather on sysadmin settings page, you can also define a custom function to return the groups a user can share library to.

For example, if you want to let a user to share library to both its groups and the groups of user test@test.com, you can define a custom_get_groups function in {seafile install path}/conf/seahub_custom_functions/__init__.py

Code example:

  1. import os
  2. import sys
  3. current_path = os.path.dirname(os.path.abspath(__file__))
  4. seaserv_dir = os.path.join(current_path, \
  5. '../../seafile-server-latest/seafile/lib64/python2.7/site-packages')
  6. sys.path.append(seaserv_dir)
  7. def custom_get_groups(request):
  8. from seaserv import ccnet_api
  9. groups = []
  10. username = request.user.username
  11. # for current user
  12. groups += ccnet_api.get_groups(username)
  13. # for 'test@test.com' user
  14. groups += ccnet_api.get_groups('test@test.com')
  15. return groups

NOTE, you should NOT change the name of custom_get_groups and seahub_custom_functions/__init__.py

Note

  • You need to restart seahub so that your changes take effect.
  • If your changes don’t take effect, You may need to delete ‘seahub_setting.pyc’. (A cache file)
  1. ./seahub.sh restart