From eb2dc516bd0e0d741b8dab4a5cba9d948bb8b98b Mon Sep 17 00:00:00 2001 From: Roman Pertl Date: Tue, 21 Apr 2026 09:47:03 +0200 Subject: [PATCH] fix: during oauth login restore action from url --- lib/RT/Authen/OAuth2.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/RT/Authen/OAuth2.pm b/lib/RT/Authen/OAuth2.pm index c1643c3..1ebc310 100644 --- a/lib/RT/Authen/OAuth2.pm +++ b/lib/RT/Authen/OAuth2.pm @@ -123,7 +123,16 @@ sub RequestAuthorization { # my $idp_conf = RT->Config->Get('OAuthIDPs')->{$idp}; my $idp_conf = _GetIDPConf($idp); - $idp_conf->{state} = $args->{next} || ''; + $RT::Logger->debug( 'OAuth2: args: ' . Dumper($args) + + # Reconstruct the full 'next' URL by including Action and other query params + my $next = $args->{next} || ''; + if ($args->{Action}) { + $next .= ($next =~ /\?/ ? '&' : '?') . 'Action=' . $args->{Action}; + } + + RT::Logger->debug("OAuth2: redirect to: " . $next); + $idp_conf->{state} = uri_escape($next) || ''; $idp_conf->{client_id} = RT->Config->Get('OAuthIDPSecrets')->{$idp}->{client_id}; $idp_conf->{client_secret} = RT->Config->Get('OAuthIDPSecrets')->{$idp}->{client_secret}; @@ -460,7 +469,7 @@ sub LogUserIn { } } - return (1, "ok", $args->{state}); + return (1, "ok", uri_unescape($args->{state})); }