You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Self Service emails do not retain the goto or locale parameter #272
Describe the bug
The Self Service registration and password recovery can be configured to send an email verification link to the user, however in the outgoing email the return link is generated from a template that only takes into account the realm parameter, ignoring other parameters like the locale or the goto querystring value.
This is especially problematic when directing the user to the self-registration page, because after a successful registration the user will be redirected to his OpenAM console instead of the application he intended to register to.
To Reproduce
Steps to reproduce the behavior:
Enable the User Self Service service, the User Registration feature and activate Email Verification
Visit the User registration page including a goto parameter in the url (i.e. http://login.domain.com:8080/openam/XUI/?realm=/public&goto=https://www.google.com#register/ )
Enter your Email address and continue. Note that the "Return to the login page" link still has the correct goto parameter value
See error: Check the link in the email you received, notice that the goto parameter is missing
Manually add the goto parameter to the link, open it in a browser and complete the registration process. After logging in you will be correctly redirected to the Google homepage, so the redirect is working, it's just the link that's not generated correctly.
Expected behavior
After a successful user registration, or any other self-service sequence, the user should be redirected to the value of the goto parameter, if present.
Additional context
The issue does not seem to be too complex, I will try to work on it.
This is far more complex than I imagined. The problem here is that the XUI never passes those querystring parameters to the self-service stages. The locale parameter can be inferred, because the Accept-Language http headers are set according to the user preferred locale, but for the goto parameter it's a whole another story, and thinking about it there's a bunch of other parameters which might be useful to preserve, i.e. service, module, etc.
The easiest way might be to create a custom self service stage to capture the querystring parameters in a hidden field via JS and autosubmit the form immediately. The parameters could then be loaded into the stage context and be available for the email verification stage, however I'd hate to add yet-another-DOM-refresh to the process. Maybe I could incorporate this JS in the initial self service stages?
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[ERROR] Tests run: 98, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 0.997 s <<< FAILURE! - in TestSuite
[ERROR] testAdvanceCallbackSendMail(org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest) Time elapsed: 0.013 s <<< FAILURE!
java.lang.NullPointerException
at org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest.testAdvanceCallbackSendMail(VerifyEmailAccountStageTest.java:180)
[ERROR] testAdvanceInitialStage(org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest) Time elapsed: 0.001 s <<< FAILURE!
java.lang.NullPointerException
at org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest.testAdvanceInitialStage(VerifyEmailAccountStageTest.java:127)
[ERROR] testGatherInitialRequirementsWithEmailInContext(org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest) Time elapsed: 0.004 s <<< FAILURE!
java.lang.AssertionError:
Expecting empty but was:<{"$schema"="http://json-schema.org/draft-04/schema#", "description"="Verify your email address", "properties"={"querystringParams"={"description"="Querystring params", "type"="hidden"}}, "type"="object"}>
at org.forgerock.selfservice.stages.email.VerifyEmailAccountStageTest.testGatherInitialRequirementsWithEmailInContext(VerifyEmailAccountStageTest.java:104)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] VerifyEmailAccountStageTest.testAdvanceCallbackSendMail:180 » NullPointer
[ERROR] VerifyEmailAccountStageTest.testAdvanceInitialStage:127 » NullPointer
[ERROR] VerifyEmailAccountStageTest.testGatherInitialRequirementsWithEmailInContext:104
Expecting empty but was:<{"$schema"="http://json-schema.org/draft-04/schema#", "description"="Verify your email address", "properties"={"querystringParams"={"description"="Querystring params", "type"="hidden"}}, "type"="object"}>
[INFO]
[ERROR] Tests run: 98, Failures: 3, Errors: 0, Skipped: 0
Activity
lscorcia commentedon Mar 31, 2020
This is far more complex than I imagined. The problem here is that the XUI never passes those querystring parameters to the self-service stages. The
localeparameter can be inferred, because theAccept-Languagehttp headers are set according to the user preferred locale, but for thegotoparameter it's a whole another story, and thinking about it there's a bunch of other parameters which might be useful to preserve, i.e.service,module, etc.The easiest way might be to create a custom self service stage to capture the querystring parameters in a hidden field via JS and autosubmit the form immediately. The parameters could then be loaded into the stage context and be available for the email verification stage, however I'd hate to add yet-another-DOM-refresh to the process. Maybe I could incorporate this JS in the initial self service stages?
I have found https://bugster.forgerock.org/jira/browse/OPENAM-9125 which seems to imply that this feature isn't implemented even in the most recent ForgeRock AM release (isn't that a bit crazy? It has been open for years and to me this seems an extremely important feature!).
Anyway, this was just an update. I will keep trying...
Fix #272 - Save querystring parameters in Self Service verification e…
OpenIdentityPlatform/OpenAM#272 Save querystring parameters for self …
lscorcia commentedon Apr 7, 2020
Thank you @vharseko ! Could you please update submodules?
vharseko commentedon Apr 7, 2020
lscorcia commentedon Apr 7, 2020
I'm so sorry! I'll take a look at it immediately.