Commit 6b0bb4bb authored by Cage, Gregory's avatar Cage, Gregory
Browse files

Generalize external login redirect cookie

parent b8bd6b58
Loading
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -4169,16 +4169,10 @@ mapping:
          queries while browsing a file sources. Longer times will result in fewer requests to file sources but
          outdated contents might be displayed to the user. Currently only affects s3fs file sources.

      ornl_nova_redirect_url:
      external_login_redirect_cookie:
        type: str
        default: https://nova-test.ornl.gov
        default: "galaxy-external-login-redirect"
        required: false
        desc: |
          ORNL Only. The url to return to when logging in through Galaxy via NOVA.

      ornl_nova_login_origin_cookie:
        type: str
        default: galaxy-nova-login
        required: false
        desc: |
          ORNL Only. The name of the cookie to check whether the user was sent from NOVA to log in.
 No newline at end of file
          The name of a cookie to check after Galaxy has been logged into via an external third party. If present, Galaxy
          will redirect to the url contained in the cookie.
 No newline at end of file
+1 −2
Original line number Diff line number Diff line
@@ -233,8 +233,7 @@ class ConfigSerializer(base.ModelSerializer):
            "enable_help_forum_tool_panel_integration": _use_config,
            "disable_batch_input": _use_config,
            "llm_api_configured": lambda item, key, **context: bool(item.openai_api_key),
            "ornl_nova_redirect_url": _defaults_to("https://nova-test.ornl.gov"),
            "ornl_nova_login_origin_cookie": _defaults_to("galaxy-nova-login")
            "external_login_redirect_cookie": _defaults_to("galaxy-external-login-redirect")
        }


+5 −5
Original line number Diff line number Diff line
@@ -93,8 +93,8 @@ class OIDC(JSAppLauncher):
        if success:

            # ORNL ONLY logic
            nova_login = trans.get_cookie(trans.app.config.ornl_nova_login_origin_cookie)
            if nova_login == "true":
            external_login = trans.get_cookie(trans.app.config.external_login_redirect_cookie)
            if external_login:
                return trans.response.send_redirect(url_for(redirect_uri))

            return {"redirect_uri": redirect_uri}
@@ -157,9 +157,9 @@ class OIDC(JSAppLauncher):
        trans.set_cookie(value="/", name=LOGIN_NEXT_COOKIE_NAME)

        # ORNL ONLY logic
        nova_login = trans.get_cookie(trans.app.config.ornl_nova_login_origin_cookie)
        if nova_login == "true":
            return trans.response.send_redirect(url_for(trans.app.config.ornl_nova_redirect_url))
        external_login = trans.get_cookie(trans.app.config.external_login_redirect_cookie)
        if external_login and (external_login.find("https://") == 0 or external_login.find("http://") == 0):
            return trans.response.send_redirect(url_for(external_login))
        return trans.response.send_redirect(url_for(redirect_url))

    @web.expose