Пример #1
0
 def gcs_https_scope(self):
     remote_ep = self.remote_config["FLOWS"][self.service_instance]["cfde_ep_id"]
     if not remote_ep:
         logger.error(f"Remote Config on {self.service_instance} did not set 'cfde_ep_id'! "
                      f"Dataset submissions cannot be run!")
         raise exc.SubmissionsUnavailable("The remote data server is currently unavailable")
     return f"https://auth.globus.org/scopes/{remote_ep}/https"
Пример #2
0
 def flow_scope(self):
     flow_id = self.remote_config["FLOWS"][self.service_instance]["flow_id"]
     if not flow_id:
         logger.error(f"Remote Config on {self.service_instance} did not set 'flow_id'! "
                      f"Dataset submissions cannot be run!")
         raise exc.SubmissionsUnavailable("Submissions have temporarily been disabled, "
                                          "please check with your Administrator.")
     return f"https://auth.globus.org/scopes/{flow_id}/flow_{flow_id.replace('-', '_')}_user"
Пример #3
0
    def check(self, raise_exception=True):
        if self.ready:
            return True
        try:
            if not self.tokens:
                logger.debug('No tokens for client, attempting load...')
                self.tokens = self.__native_client.load_tokens_by_scope()
            # Verify client version is compatible with service
            if parse_version(self.remote_config["MIN_VERSION"]) > parse_version(VERSION):
                raise exc.OutdatedVersion(
                    "This CFDE Client is not up to date and can no longer make "
                    "submissions. Please update the client and try again."
                )

            if not self.remote_config["FLOWS"][self.service_instance]["flow_id"]:
                logger.critical(f"Service {self.service_instance} has no flow ID! "
                                f"Submissions will be disabled until that is set!")
                raise exc.SubmissionsUnavailable(
                    "Submissions to nih-cfde.org are temporarily offline. Please check "
                    "with out administrators for further details.")

            # Verify user has permission to view Flow
            try:
                flow_info = self.remote_config["FLOWS"][self.service_instance]
                self.get_flow_retry_500s(flow_info["flow_id"])
            except (globus_sdk.GlobusAPIError, globus_sdk.exc.GlobusAPIError) as e:
                logger.exception(e)
                if e.http_status not in [404, 405]:
                    raise
                error_message = ("Permission denied. Please use the 'Onboarding to the Submission "
                                 "System' page at https://github.com/nih-cfde/published-documentati"
                                 "on/wiki/Onboarding-to-the-CFDE-Portal-Submission-System to "
                                 "change your permissions. Only users with the Submitter role can "
                                 "push data to the submission system. If you have already "
                                 "sent in a request for Submitter status, but are getting this "
                                 "error, be sure that you fully accepted the Globus invitation to "
                                 "your Submitter group. You will need to click the 'Click here to "
                                 "apply for membership' text in the invitation message and follow "
                                 "instructions there before doing a submission.")
                raise exc.PermissionDenied(error_message)

            self.ready = True
            logger.info('Check PASSED, client is ready use flows.')
        except Exception:
            logger.info('Check FAILED, client lacks permissions or is not logged in.')
            self.ready = False
            if raise_exception is True:
                raise
Пример #4
0
    def check(self, raise_exception=True):
        if self.ready:
            return True
        try:
            if not self.tokens:
                logger.debug('No tokens for client, attempting load...')
                self.tokens = self.__native_client.load_tokens_by_scope()
            # Verify client version is compatible with service
            if parse_version(self.remote_config["MIN_VERSION"]
                             ) > parse_version(VERSION):
                raise exc.OutdatedVersion(
                    "This CFDE Client is not up to date and can no longer make "
                    "submissions. Please update the client and try again.")

            if not self.remote_config["FLOWS"][
                    self.service_instance]["flow_id"]:
                logger.critical(
                    f"Service {self.service_instance} has no flow ID! "
                    f"Submissions will be disabled until that is set!")
                raise exc.SubmissionsUnavailable(
                    "Submissions to nih-cfde.org are temporarily offline. Please check "
                    "with out administrators for further details.")
            # Verify user has permission to view Flow
            try:
                flow_info = self.remote_config["FLOWS"][self.service_instance]
                self.flow_client.get_flow(flow_info["flow_id"])
            except globus_sdk.GlobusAPIError as e:
                logger.debug(str(e))
                if e.http_status == 405:
                    raise exc.PermissionDenied(
                        "Unable to view ingest Flow. Are you in the CFDE DERIVA "
                        "Demo Globus Group? Check your membership or apply for access "
                        "here: \nhttps://app.globus.org/groups/a437abe3-c9a4-11e9-b441-"
                        "0efb3ba9a670/about")
                else:
                    raise
            self.ready = True
            logger.info('Check PASSED, client is ready use flows.')
        except Exception:
            logger.info(
                'Check FAILED, client lacks permissions or is not logged in.')
            self.ready = False
            if raise_exception is True:
                raise