Login Pass Through

From FreeNATS Wiki
Jump to: navigation, search

You can directly call the login.php script remotely and pass login details and an optional FreeNATS URL in GET or POST format. This can be useful to link from views secured in an alternative fashion for example or to provide a custom login form.

Variables passed to the login.php script:

naun - FreeNATS username
napw - FreeNATS password (plain text)
url  - URL (can be relative) to load after authentication

If the url is unspecified the browser is directed to main.php.

If authentication fails then the browser is directed to the index.php file with the relevant error.


<a href=http://nms/login.php?naun=guest&napw=guest>Click to View</a>

Would display a link to directly login with the username guest.

It's a good idea to create a read-only user for this purpose even if you are intending to deploy it within a secured environment. For the most part you won't be making changes - just viewing latest status and can always log out and back in if required.

If the url is complex (for example goes directly to a node test period) then you will need to urlencode it.


Wouldn't work as the &s would split the line and it would be interpreted as:


URL encoding it would produce:


In truth you probably only need to encode & to %3F as most browsers/servers will parse the rest no problem.

The URL can also be absolute and loop back to your site if you want authentication to be available, for example so you can use graphs without needing to enable public graph access or so that native NATS links just work.

The session will remain active for as long as the system setting specifies (unless refreshed by something being requested from FreeNATS by the user).