Redirect after APM completes to original uri

Greetings F5 Guru’s! I have a bit of a dilemma we would like to preserve the landinguri for users for a specific site, and after successful authentication redirect them to the original uri they requested. This seems like it would be easy but I have been working on it for days and cannot seem to get the right combination of events etc…

Any help / tips / ideas would be greatly welcomed and appreciated - here is the irule:

using ACCESS_SESSION_* events to keep it from firing more that once only want to control the initial redirect out of the policy Also tried ACCESS_SESSION_COMPLETED

when ACCESS_SESSION_STARTED {

`set landing_uri [ACCESS::session data get “session.server.landinguri”]

log local0. "iRULE REDIRECT STARTING"
store original server name
set landing_server [ACCESS::session data get "session.server.network.name"]
log local0. "Current host: $landing_server"
NOTE: if block was trying to use HTTP::host - not valid TCL errors
if { $landing_server equals "some.site.com" } {
ACCESS::session data set session.server.landinguri $landing_uri
NOTE: tried to use HTTP::redirect and also tried to set location
Cannot seem to use HTTP within this context
} else {
log local0. "iRULE REDIRECT DID NOTHING - No match for site"
}
}

Comments are left in for debug, I can see its trying to work, since I cannot seem to use HTTP options like redirect or uri - I cannot seem to get it done.

Any ideas? Thanks for your time and consideration!

Hi,

Sorry, I’m missing something. By design, APM redirect the user to the session.server.landinguri after APM policy completed.

Can you explain a little bit more your need ?

Bye

Yann

Hi,

Sorry, I’m missing something. By design, APM redirect the user to the session.server.landinguri after APM policy completed.

Can you explain a little bit more your need ?

Bye

Yann

Thanks for the interest firstly! I want to change the session.server.landinguri to the uri they originally landed on F5 with. So if a user hits the f5 with /documents/somedoc.pdf I would like to store it and then send them to it after authentication. I thought the landinguri was the var that stored that initial landing not where apm sent them.

So would it be as simple as creating a custom VAR in my policy that stores this initial value and then queue this irule to send them to there instead of the configured landinguri?

so that initial block would read

when ACCESS_SESSION_STARTED {
set landing_uri [ACCESS::session data get "session.user.customvaruri"]

So that would cause the set of the landing_uri later to successfully send them where they needed to go? Also should I use ACCESS_SESSION_COMPLETED instead of STARTED?

Many thanks!

Thanks for the interest firstly! I want to change the session.server.landinguri to the uri they originally landed on F5 with. So if a user hits the f5 with /documents/somedoc.pdf I would like to store it and then send them to it after authentication. I thought the landinguri was the var that stored that initial landing not where apm sent them.

So would it be as simple as creating a custom VAR in my policy that stores this initial value and then queue this irule to send them to there instead of the configured landinguri?

so that initial block would read

when ACCESS_SESSION_STARTED {
set landing_uri [ACCESS::session data get "session.user.customvaruri"]

So that would cause the set of the landing_uri later to successfully send them where they needed to go? Also should I use ACCESS_SESSION_COMPLETED instead of STARTED?

Many thanks!

Hi,

The session.server.landinguri is filled with the very first request the user do to your application. So, this var should be good for your need.

I used to modify session.server.landinguri to redirect users to a specific location after authentication complete. So, you can used it as well. The only exception is if you are using Multi-domain SSO configuration, it’s a little bit harder.

Yann

Hi,

The session.server.landinguri is filled with the very first request the user do to your application. So, this var should be good for your need.

I used to modify session.server.landinguri to redirect users to a specific location after authentication complete. So, you can used it as well. The only exception is if you are using Multi-domain SSO configuration, it’s a little bit harder.

Yann

So then setting the landinguri after the if block really does nothing. I should use another method like HTTP::redirect? except if I use that I get TCL runtime errors about not being having a valid context.

Given the above, how would you redirect after login?

Many thanks for your time!!

So then setting the landinguri after the if block really does nothing. I should use another method like HTTP::redirect? except if I use that I get TCL runtime errors about not being having a valid context.

Given the above, how would you redirect after login?

Many thanks for your time!!

I think I might have found the answer. DevCentral - An F5 Technical Community

ACCESS::respond 302 “Location” “$landing_uri” “Connection” “Close” <-- not sure here if this is right docs do not give much in the way of valid operations.

Also I found the irule editor on this site!! Very handy! DevCentral - An F5 Technical Community

I will be testing this and will post back if this solves it!

I think I might have found the answer. ACCESS::respond

 

ACCESS::respond 302 “Location” “$landing_uri” “Connection” “Close” <-- not sure here if this is right docs do not give much in the way of valid operations.

 

Also I found the irule editor on this site!! Very handy! https://devcentral.f5.com/s/articles/iRule-Editor-Download

 

I will be testing this and will post back if this solves it!

 

Hi,

Why not configuring a variable assign block and just replacing the session.server.landinguri value by your custom value. So that you don’t need to develop an irule for that.

Maybe I missed something.

Yann

Hi,

Why not configuring a variable assign block and just replacing the session.server.landinguri value by your custom value. So that you don’t need to develop an irule for that.

Maybe I missed something.

Yann

Hi,

instead of changing

session.server.landinguri

, you can provision

session.policy.result.start_uri

What I saw on different project is the APM redirect to following URI in this order:

  • session.policy.result.start_uri
    
  • session.server.landinguri
    
session.policy.result.start_uri

variable can be from:

  • SAML relay state included in IDP assertion
  • webtop URL (full, portal, ..)

As Yann previously said, you can set it in a variable assign in VPE instead of irule. If you want to do it in an irule, ACCESS_SESSION_COMPLETED is the best event before redirect.

If you do a redirect with

ACCESS::respond

, some APM tasks will be ignored (ex : session.user.sessiontype is not set which is used in active session to display session type LTM_APM, FULL or other)

Hi,

instead of changing

session.server.landinguri

, you can provision

session.policy.result.start_uri

What I saw on different project is the APM redirect to following URI in this order:

  • session.policy.result.start_uri
    
  • session.server.landinguri
    
session.policy.result.start_uri

variable can be from:

  • SAML relay state included in IDP assertion
  • webtop URL (full, portal, ..)

As Yann previously said, you can set it in a variable assign in VPE instead of irule. If you want to do it in an irule, ACCESS_SESSION_COMPLETED is the best event before redirect.

If you do a redirect with

ACCESS::respond

, some APM tasks will be ignored (ex : session.user.sessiontype is not set which is used in active session to display session type LTM_APM, FULL or other)