Search code examples
javascriptcasyui2

Preserving URL fragment through CAS sign-on


I maintain a single-page application that uses the YUI 2.8 history module to retain local options in the URL fragment. I've recently put it behind CAS authentication, and I'm finding that the fragment gets lost during CAS authentication. It is retained in the signon URL, but not when redirected back to the application page. This is also true after session timeouts, so users get bumped back to the default options after re-authentication.

Any suggested strategies for hanging on to the fragment (or the underlying javascript state) though a CAS roundtrip?


Solution

  • You can store it in a cookie, sessionStorage, or simply as the value of window.name if there are no security implications:

    //Cookie
    document.cookie = "fragID=" + window.location.hash + ";path=/";
    //Session Storage
    window.sessionStorage.setItem("fragID",window.location.hash);
    //Window
    window.name = window.location.hash
    

    References