mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #5138 from scholtalbers/feature/auto_create_userfolder
Add option to auto create user_library_import_dir directories upon user login
This commit is contained in:
@@ -1050,6 +1050,11 @@ galaxy:
|
||||
# in their directory.
|
||||
#user_library_import_dir: null
|
||||
|
||||
# If user_library_import_dir is set, this option will auto create a
|
||||
# library import directory for every user (based on their email) upon
|
||||
# login.
|
||||
#user_library_import_dir_auto_creation: false
|
||||
|
||||
# For security reasons, users may not import any files that actually
|
||||
# lie outside of their `user_library_import_dir` (e.g. using symbolic
|
||||
# links). A list of directories can be allowed by setting the
|
||||
|
||||
@@ -2188,6 +2188,18 @@
|
||||
:Type: str
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
``user_library_import_dir_auto_creation``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
:Description:
|
||||
If user_library_import_dir is set, this option will auto create a
|
||||
library import directory for every user (based on their email)
|
||||
upon login.
|
||||
:Default: ``false``
|
||||
:Type: bool
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
``user_library_import_symlink_whitelist``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -431,6 +431,7 @@ class Configuration(object):
|
||||
self.user_library_import_dir = kwargs.get('user_library_import_dir', None)
|
||||
self.user_library_import_symlink_whitelist = listify(kwargs.get('user_library_import_symlink_whitelist', []), do_strip=True)
|
||||
self.user_library_import_check_permissions = string_as_bool(kwargs.get('user_library_import_check_permissions', False))
|
||||
self.user_library_import_dir_auto_creation = string_as_bool(kwargs.get('user_library_import_dir_auto_creation', False)) if self.user_library_import_dir else False
|
||||
# Searching data libraries
|
||||
self.ftp_upload_dir = kwargs.get('ftp_upload_dir', None)
|
||||
self.ftp_upload_dir_identifier = kwargs.get('ftp_upload_dir_identifier', 'email') # attribute on user - email, username, id, etc...
|
||||
|
||||
@@ -24,10 +24,11 @@ from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
from galaxy import util
|
||||
from galaxy.exceptions import MessageException
|
||||
from galaxy.exceptions import ConfigurationError, MessageException
|
||||
from galaxy.managers import context
|
||||
from galaxy.util import (
|
||||
asbool,
|
||||
safe_makedirs,
|
||||
safe_str_cmp
|
||||
)
|
||||
from galaxy.util.sanitize_html import sanitize_html
|
||||
@@ -630,16 +631,31 @@ class GalaxyWebTransaction(base.DefaultWebTransaction,
|
||||
self.set_cookie(self.security.encode_guid(self.galaxy_session.session_key),
|
||||
name=name, path=self.app.config.cookie_path)
|
||||
|
||||
def check_user_library_import_dir(self, user):
|
||||
if getattr(self.app.config, "user_library_import_dir_auto_creation", False):
|
||||
# try to create a user library import directory
|
||||
try:
|
||||
safe_makedirs(os.path.join(self.app.config.user_library_import_dir, user.email))
|
||||
except ConfigurationError as e:
|
||||
self.log_event(str(e))
|
||||
|
||||
def user_checks(self, user):
|
||||
"""
|
||||
This could contain more checks around a user upon login
|
||||
"""
|
||||
self.check_user_library_import_dir(user)
|
||||
|
||||
def handle_user_login(self, user):
|
||||
"""
|
||||
Login a new user (possibly newly created)
|
||||
|
||||
- do some 'system' checks (if any) for this user
|
||||
- create a new session
|
||||
- associate new session with user
|
||||
- if old session had a history and it was not associated with a user, associate it with the new session,
|
||||
otherwise associate the current session's history with the user
|
||||
- add the disk usage of the current session to the user's total disk usage
|
||||
"""
|
||||
self.user_checks(user)
|
||||
# Set the previous session
|
||||
prev_galaxy_session = self.galaxy_session
|
||||
prev_galaxy_session.is_valid = False
|
||||
|
||||
@@ -1629,6 +1629,14 @@ mapping:
|
||||
must contain sub-directories named the same as the non-admin user's Galaxy
|
||||
login ( email ). The non-admin user is restricted to uploading files or
|
||||
sub-directories of files contained in their directory.
|
||||
|
||||
user_library_import_dir_auto_creation:
|
||||
type: bool
|
||||
default: false
|
||||
required: false
|
||||
desc: |
|
||||
If user_library_import_dir is set, this option will auto create a library
|
||||
import directory for every user (based on their email) upon login.
|
||||
|
||||
user_library_import_symlink_whitelist:
|
||||
type: str
|
||||
|
||||
Reference in New Issue
Block a user