Commit 14babb50 authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

only run refresh on first web worker

parent b4ed0fc8
Loading
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -796,7 +796,7 @@ class UniverseApplication(StructuredApp, GalaxyManagerApplication):
            self.authnz_manager = managers.AuthnzManager(
                self, self.config.oidc_config_file, self.config.oidc_backends_config_file
            )

            if self.is_webapp:
                self.refresh_oidc_tokens_task = IntervalTask(
                    func=lambda: self.authnz_manager.refresh_expiring_oidc_tokens(self.model.session),
                    name="RefreshOIDCTokensTask",
+3 −0
Original line number Diff line number Diff line
@@ -355,6 +355,7 @@ class AuthnzManager:
        return qres

    def refresh_expiring_oidc_tokens_for_provider(self, sa_session, auth):
        self.app.config.server_name
        try:
            success, message, backend = self._get_authnz_backend(auth.provider)
            if success is False:
@@ -368,6 +369,8 @@ class AuthnzManager:
            return False

    def refresh_expiring_oidc_tokens(self, sa_session):
            if (self.app.config.server_name != self.app.config.base_server_name and self.app.config.server_name != f"{self.app.config}.1"):
                return
            user_filter = datetime.now() - timedelta(days=30)
            all_users = sa_session.scalars(select(model.User)).all()
            for user in all_users:
+0 −1
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ class FastAPIJobTokens:
        trans: ProvidesAppContext = DependsOnTrans,
    ) -> str:
        job = self.__authorize_job_access(trans, job_id, job_key)
        trans.app.authnz_manager.refresh_expiring_oidc_tokens(trans, job.user)  # type: ignore[attr-defined]
        tokens = job.user.get_oidc_tokens(provider_name_to_backend(provider))
        return tokens["id"]