not save the addresses accessed in browser history, ruby on rails - ruby-on-rails

I need to configure a rails app in a way that it does not leave the browser to save the historic addresses accessed my app. Can anyone help me?

You can't. There's no protocol, let alone one implemented by all popular browsers, that would allow such insecure behavior.
Users can choose things like Chrome's "Incognito Mode" or Safari's "Private Browsing" but you can't (and shouldn't be allowed to) force such a mode on the user.

Related

Disabling a redirect from a url

So basically I want to disable url redirects. I want to stay in the same url. Is there a code to ensure this? I'm researching Mac Terminal Webbrowsers and the tab element inspect element on google chrome, but to no success. Anyone know of a way to disable redirects from pretty much all of my future searches using the console tab in inspect element, or mac terminal? Any other ways I'd be down to learn because I am a complete beginner, so let me know if you need clarification.
You can't. Browser's don't let users control that and no software on your computer will let that happen. You'd have to custom build a proxy that detects redirects and simply kill them and serve a custom page.
There is no protocol for what should happen if a page is redirected and the user "doesn't want it". Essentially, users don't know what they want but the server should know where to get what they ask for. If it moved to another location, just move without annoying the user. Redirects are a foundation of the web and are heavily relied on. Even making https://example.com go to https://example.com/ for the homepage is a redirect.

Verifying Googlebot in Rails

I am looking to implement First Click Free in my rails application. Google has this information on how to verify a if a googlebot is viewing your site here.
I have been searching to see if there is anything existing for Rails to do this but I have been unable to find anything. So firstly, does anyone know of anything? If not, could anyone point me in the right direction of how to go about implementing what they have suggested in that page about how to verify?
Also, in that solution, it has to do a lookup every time to try and detect google, that seems like its going to be a big performance hit if I have to do it every page load? I could cache the IP if it has been verified in the past but Google have stated that their IP's change so at some point it may no longer belong to them. Although it probably doesn't happen regularly so it may not be that big of an issue.
Many thanks!!
Check out the browser gem: https://github.com/fnando/browser
What I'd do is use the
browser.bot?
method to check if your site is being accessed by a bot or not. If you care about the Googlebot specifically, you could check if
browser.name
includes googlebot. Keep in mind that this gem just checks the user agent sent by the client's browser, which could of course be spoofed. Sounds like that isn't a huge concern for your purposes.
I've built a Ruby gem for that recently, it's called "legitbot".
You may learn if a Web request comes from a supported bot using
bot = Legitbot.bot(userAgent, ip)
"legitbot" does this looking into User-agent and searching for a bot signature, i.e. how bots identify themselves. This doesn't guarantee that the Web request IP really comes from e.g. Googlebot. To make sure it is, call
bot.detected_as # => "Google"
bot.valid? # => true
bot.fake? # => false
Supported bots are Googlebot, Yandex bots, Bing, Baidu, DuckDuckGo.

GWT real vs redirected URL

I have an OVH hosted application on http://ovhserver/myapp/
This application is also accessible via http://anyUser.domain.com. I did this by redirecting *.domain.com to http://ovhserver/myapp/
The browser displays the http://[anyUser].domain.com. But when I try to read it using GWT, I'm only getting the real adress (http://ovhserver/myapp/).
[anyUser] is a reference to the active account; If you create an account X, my application would be accessible via http://X.domain.com.
I tryed, in vain, using GWT.getHostPageBaseURL(), Window.Location.getHref() and Window.Location.getPath().
I want to read the "displayed" URL in the browser. How can I do it?
Thank you.
This is not redirection, most likely anyUser.domain.com loads ovhserver/myapp in a frame. You can try using $wnd.top.location.href in a JSNI method though I'm not sure you'll be given access to it (as it's a cross-origin access).
You should really try setting up a true domain/hosting, it doesn't cost much, and would save you many headaches that framing will doubtlessly create.

taking a screenshot of user's current page in ruby on rails

this is fo debugging purpose, please take into account the following:
the user logs in to his/her account so manually fetching a url will not work - the screenshot must happen together when the user access his admin pages.
would love to receive guidelines specific for ruby on rails and heroku (i guess heroku is not much an issue i just dump the screenshot to s3).
so ideally like i mentioned in #1, when a user access a page, my app also takes a screenshot of the entire page and dumps it in a tmp folder.
can anyone point me how to handle that?
In order to get a screenshot of what the user is currently seeing, you have to have some code on the user's machine that uses the underlying operating system API to take the screenshot. The API calls involved are different for Windows, Mac OS X and Linux.
Ruby on Rails executes on the remote server and generates HTML and JavaScript etc. that is sent to the user's web browser. The HTML is rendered by the browser and the JavaScript executes within the browser's sandbox, where it has no direct access to the operating system API. The important point is that there is no direct interaction between the server-side code and the OS running on the user's computer. If this were possible then it would be a massive security hole.
Therefore it's not possible to do what you want programmatically unless you can first install a client-side program on the user's computer that can talk to your server-side code. It cannot be done using Ruby on Rails alone because it's a server-side web framework.
You can't do this without a user sending a screenshot themselves.

How can I detect when user browses certain url?

I'm writing an application, which becomes "useful" once user is browsing certain url.
I want to add feature to my application, that it will be automatically launched once user browses this url, I was thinking of writing some sort of watchdog to trigger it.
My question is, whether there is a generic way to get notified when user browses to urls, I want to support at least IE and FireFox, chrome and safari is nice to have.
I read about DDE and WWW_RegisterURLEcho, but from what I understand it's not supported by FireFox, and also little sample I wrote didn't work with IE as well.
Thank you in advance
some more questions **
Do Url Monikers and Asynchronous Pluggable Protocols help me here ? Is it supported by FireFox ?
If you have control over the website, you could have it write a cookie to the computer. Then have your application monitor for that cookie.
You can implement this in many ways and at many different layers.
At the highest level, you could implement a browser plugin. There is no cross-browser solution at this layer that will let you write the code once and work for every browser. On the easy end of the spectrum, Firefox, you could implement it entirely as a Javascript + XUL plugin and use built-in XPCom interfaces (nsIProcess) for launching your helper process. For IE you would need to write a COM, C++ and win32 BHO that handles DWebBrowserEvents2::BeforeNavigate2. This is the hardest thing to do. There are mechanisms for Safari, Chrome and other webbrowsers that you could use to achieve this same behavior, with varying degrees of difficulty.
At the next level you could implement an HTTP proxy, similar to Fiddler2, that redirects all HTTP traffic through your local proxy first. Each browser has a different way of configuring its proxy settings, but they're all basically registry settings or config files.
At the most basic level you could just snif all IP traffic going out of the machine, similar to the way Wireshark does it, and just look for http requests to your URL. This is probably more difficult to code, but would work for all browsers without any special per-browser configuration stuff going on. You may need to write a driver. I dunno, I've never done work at this level in the stack.

Resources