Forum Discussion

FranzG's avatar
FranzG
Genius
8 years ago

Page Init on /plugins/common/feature/*

Hopefully this is a quick question to answer...

 

Does the Page Initialization script run on all server requests or just requests to certain paths/pages?

 

Context:

I'm trying to run some logic prior to the Lithium SSO page redirecting to our SSO.   Use case is that I want to be able to detect if the community needs to redirect the client to the standard SSO or a separate employee SSO.  Both SSOs are already integrated but when a user attempts to access a restricted section of the community that requires login, they are always being directed to the customer SSO.

 

Here's my page init code:

<#-- Start Employee SSO redirect logic -->
<#assign empCookie = http.request.cookies.name.emp />
<#assign requesturl = http.request.url />
<#if requesturl?contains(".com/plugins/common/feature/oauth2sso/sso_login_redirect") && empCookie == "true" >
    <#assign redirectreason = http.request.parameters.name.get("redirectreason", "none") />
    <#if redirectreason == "permissiondenied">
        <#assign referer = http.request.parameters.name.get("dest_url", "none")?url />
        <#if referer != "none">
            <#assign empredirect = "/plugins/common/feature/saml/doauth/post?referer=" + referer />
            ${http.response.setRedirectUrl(empredirect)}
        </#if>
    </#if>
</#if>

<#-- End Employee SSO redirect logic -->

 

My current theory is that requests to the Lithium built SSO pages run the page code first or don't execute page init at all.  Hopefully I'm wrong. :)

  • Unfortunately, you are correct -- the SSO page logic runs before the page init logic, so anything you add to your page init script will not have a chance to run before the redirect.

     

    Do you think you could fashion an apache rewrite rule to do the same redirect? (I think it should be possible) If so, then you could probably file a support case to have support add the rule for you. Otherwise, I think this would be something you would have to engage with Services to build in.

     

    -Doug

  • DougS's avatar
    DougS
    Khoros Oracle

    Unfortunately, you are correct -- the SSO page logic runs before the page init logic, so anything you add to your page init script will not have a chance to run before the redirect.

     

    Do you think you could fashion an apache rewrite rule to do the same redirect? (I think it should be possible) If so, then you could probably file a support case to have support add the rule for you. Otherwise, I think this would be something you would have to engage with Services to build in.

     

    -Doug

    • FranzG's avatar
      FranzG
      Genius
      Thanks Doug! We'll have to add this to our To-Do list for services.
      - Franz