Tagged: absolute url, OpenAM13, XUI
This topic has 1 reply, 1 voice, and was last updated 2 years, 5 months ago by l.scorcia.
-
AuthorPosts
-
February 11, 2020 at 2:30 am #27580
l.scorcia
ParticipantHello everyone,
I am trying to customize the UI of our OpenAM 13 setup by editing DataStore1.html and some other html template and I need to build an absolute url to OpenAM (i.e. current URI is https://login.domain.com:8080/openam/XUI/#login, I need to get https://login.domain.com:8080/openam), in order to pass it to the RelayState parameter of spSSOInit.jsp .Now, this is not impossible to get using the various window.location properties, but I was trying to keep it independent of the actual deployment, so I was wondering if there is a direct way to get the current protocol+host+port+contextPath from some property available to the UI via Handlebars or global variables or something else. If it were a JSP I would just use ‘${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}’, but here we’re in a static html template and I don’t know if there is some way to get the required pieces, especially the contextPath. Do you have any suggestions?
Thanks in advance,
LucaFebruary 20, 2020 at 8:40 pm #27670l.scorcia
ParticipantWell, in case anyone else need this in the future, I haven’t been able to get it using Handlebars’ data but it turns out it can actually be done in javascript using the XUI scripts!
require(["org/forgerock/commons/ui/common/util/Constants"], function (constants) { console.log(constants.context); });
This returns the application context, i.e. for
https :// login.domain.com:8080/openam/XUI/#login
(spaces added for antispam filter) this returnsopenam
.
The scheme/host/port can also be retrieved using a similar snippet:require(["Router"], function (router) { console.log(router.getCurrentUrlBasePart()); });
returns
http :// login.domain.com:8080
(spaces added for antispam filter).Have a nice day,
Luca -
AuthorPosts
You must be logged in to reply to this topic.