Re-enable secure random path for all local server calls
We'll need to use JSPs to enable this. We'll also need to set the "config" javascript object for the cometd calls to work correctly. Including this in Arendt since it pretty vital to protecting the security of that local server.
Will be something along these lines:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery-1.6.2.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/json2.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/org/cometd.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery.cometd.js"></script>
<script type="text/javascript" src="application.js"></script>
<%--
The reason to use a JSP is that it is very easy to obtain server-side configuration
information (such as the contextPath) and pass it to the JavaScript environment on the client.
--%>
<script type="text/javascript">
var config = {
contextPath: '${pageContext.request.contextPath}'
};
</script>
</head>
<body>
<div id="body"></div>
</body>
</html>
make random path and port selection happen at install time rather than on every run
support for this in lantern-ui landed in getlantern/lantern-ui@c7f7c0875c99978cc3d1c0c332c554e2d9af7841
I still need to move the random port to model generation time.
Also, I'm not sure this goes in the model, because if our theory is that the model might get corrupted, then really bad things could happen. On the other hand, I think the model ought to never get corrupted (outside of development, of course).
Actually, what's the story with setting the port on the command-line? Is that for a specific use case?
My inclination is to allow it only on first start-up, and then throw an error if it is used thereafter. Alternately, I could do some hackery to continue to support it as a per-run option (by keeping track of a current vs saved value)
Actually, what's the story with setting the port on the command-line? Is that for a specific use case? My inclination is to allow it only on first start-up, and then throw an error if it is used thereafter. Alternately, I could do some hackery to continue to support it as a per-run option (by keeping track of a current vs saved value)
The use case is Lantern currently chooses a random api port on every run, which is annoying for development, where you want to be able to point a browser at a predictable url. If we move to choosing the random port at install time instead of at runtime, it can just be implemented as a hardcoded constant at runtime, which stays constant across runs. And we can just always use a port of 9999 or something when running from source.
OK, then I'll just remove that code.
Awesome. So we're moving to calculating the random port once, at install time, rather than at runtime when the model is first generated? That would be preferable for when we also install a Chrome extension at install time in the future, which would also need to know any random port and path the API is mounted on.
I was actually doing it on first run rather than on install. But I guess for Chrome extension purposes, it might be better to do it on install.
On Thu, Mar 14, 2013 at 5:37 PM, skivvies [email protected] wrote:
Awesome. So we're moving to calculating the random port once, at install time, rather than at runtime when the model is first generated? That would be preferable for when we also install a Chrome extension at install time in the future, which would also need to know any random port and path the API is mounted on.
— Reply to this email directly or view it on GitHubhttps://github.com/getlantern/lantern/issues/72#issuecomment-14930892 .
Install4j is fighting back; waiting to see if someone on the list knows what's up.
Just noting we should back out getlantern/lantern-ui@161437bcdb65cdd6e3200dffbcb5f85b81242bfd when this is done.
@leahxschmidt So as of your changes on this Lantern no longer chooses a new random port on every run, but rather only on first run, is that right? How should this affect the ---api-port option; should it only be allowed on first run? Whatever we do let's document this in the readme so it doesn't get out of date.
The --api-port option no longer exists. I've fixed the README.