OKDP / okdp-spark-auth-filter

Oauth2/OIDC Authentication filter for Apache Spark Apps/History UIs
https://okdp.io
Apache License 2.0
3 stars 3 forks source link

Serving Spark UI behind proxy #26

Closed luiscinfo closed 2 months ago

luiscinfo commented 2 months ago

Hi,

We have tested this authentication filter and it meets most of our requirements. There is a feature that we would like this filter to have and it is the capability of serving the Spark UI in a subpath behind a proxy.

Currently, it is harcoded that after the login, the filter redirects to the /home page of Spark UI. https://github.com/OKDP/okdp-spark-auth-filter/blob/83687e742dfb29627acc1ee3954c21d3b49938ea/src/main/java/io/okdp/spark/authc/OidcAuthFilter.java#L297

We serve the Spark application behind a proxy, in the path /spark. The filter authenticates correctly, but after login, it redirects to /home, and as a consecuence the redirection does not bring you to the Spark UI. We have locally tested to change the line previously referenced:

image

image

This works as spected, it allows the Spark UI to be served in a subpath behind a proxy.

idirze commented 2 months ago

Hello @luiscinfo,

Yes, in fact, the home page was hardcoded and hence not works behind a reverse proxy.

If you are interested by the contribution you can push us a pull request by modifying the line OidcAuthFilter.java with the following:

      servletResponse
          .getWriter()
          .print(
              String.format(
                  "<script type=\"text/javascript\">window.location.href = '%s'</script>",
                  ((HttpServletRequest) servletRequest).getRequestURI()));

Apply the checkstyle before build/push:

mvn spotless:apply

The commit message should respect conventional commits pattern

Ex:

git commit -m"fix: Fix serving behind reverse proxy"

Let me know if you are interested or i push the change.

idirze commented 2 months ago

I close the issue. Fixed by v1.2.2.