Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - Page redirection is broken with SSO #618

Open
cisoun opened this issue Nov 8, 2024 · 3 comments
Open

Bug - Page redirection is broken with SSO #618

cisoun opened this issue Nov 8, 2024 · 3 comments
Assignees
Labels
4 - clarification The issue or pull requests needs more information.

Comments

@cisoun
Copy link

cisoun commented Nov 8, 2024

Hi! This issue is related to a Znuny setup with Apache Mellon as SSO authentication method.

To make it short: when SSO is enabled and an unauthenticated agent wants to access a ticket through its direct link, Znuny redirects to the IDP for the login, then redirects to the homepage instead of the wished ticket.

Here's the breakdown of my situation: https://community.znuny.org/viewtopic.php?t=44275

I've found a solution that I've written at the end.

Environment

  • Server OS: Debian GNU/Linux 12 (bookworm)
  • Web server: Apache/2.4.62
  • Browser: all
  • Znuny version: 6.5.11 LTS

Expected behavior

  • Agent is unauthenticated and wants to access a ticket (through AgentTicketZoom).
  • Znuny redirects the agent to the IDP for the login.
  • Agent performs the login successfully.
  • Znuny redirects the agent to the ticket page.

Actual behavior

  • Znuny rewrites the login URL.
  • IDP cannot parse the whole login URL and loses the original RequestedURL parameter that contains the AgentTicketZoom parameter.
  • Znuny redirects to the homepage instead.

How to reproduce

Steps to reproduce the behavior:

  • Setup SSO with Apache Mellon with the configuration provided on my post mentionned above.
  • Try to access a ticket from a direct link to it while being unauthenticated.

Possible solution

I've fixed our setup by changing Kernel/System/Web/InterfaceAgent.pm#L284 by

-                        . "?Reason=LoginFailed&RequestedURL=$Param{RequestedURL}",
+                        . $LayoutObject->LinkEncode("?Reason=LoginFailed&RequestedURL=$Param{RequestedURL}"),

My guess is, if your LoginURL is, let's say, /sso/login?RedirectTo=/otrs/index.pl
and this part adds ?Reason=LoginFailed&RequestedURL=$Param{RequestedURL},
you end up with something like /sso/login?RedirectTo=/otrs/index.pl?Reason=LoginFailed&RequestedURL=ActionTicketZoom&TicketID=10000000 which is not really a valid query.

Instead, the SSO redirection to the SP will return /sso/login?RedirectTo=/otrs/index.pl?Reason=LoginFailed and redirect the agent to the homepage.

So by reencoding the query, we end up with /sso/login?RedirectTo=/otrs/index.pl%3FReason%3DLoginFailed%26RequestedURL%3DActionTicketZoom%26TicketID%3D10000000, then the agent will be redirected to the right page.

@rkaldung
Copy link
Member

@cisoun I just tried verifying it with our own setup, and it's working. What is your IdP?

@rkaldung rkaldung added the 4 - clarification The issue or pull requests needs more information. label Nov 11, 2024
@rkaldung rkaldung self-assigned this Nov 11, 2024
@cisoun
Copy link
Author

cisoun commented Nov 11, 2024

Hello Roy, thanks for responding. We use Keycloak.

@rkaldung
Copy link
Member

Hello Roy, thanks for responding. We use Keycloak.

Same here.
That's our configuration where the redirect is working:

<Location />
    MellonEnable info
    MellonEndpointPath /mellon/
    MellonSPMetadataFile /etc/httpd/xxx.xml
    MellonSPPrivateKeyFile /etc/httpd/xxx.key
    MellonSPCertFile /etc/httpd/xxx.cert
    MellonIdPMetadataFile /etc/httpd/yyy.xml
    MellonMergeEnvVars On
    MellonRedirectDomains [self] *.internal.example.tld *.example.tld
    ErrorDocument 404 /znuny/customer.pl
</Location>
# This is a location that will trigger authentication when requested.
<Location /znuny/index.pl>
    AuthType Mellon
    MellonEnable auth
    Require valid-user
</Location>

Do you have MellonRedirectDomains also configured?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - clarification The issue or pull requests needs more information.
Development

No branches or pull requests

2 participants