Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

One of our application will be run in an iframe, inside salesforce and I'm having troubles with accessing the referer. They'd like us to do some referer checks, to make sure the request is coming from salesforce and we've been given the IP addresses to check against.

My problem is that anytime I try to access the referer through either of the following two methods:



it returns me null.

Any ideas how could I get hold of the referer?

PS: I'm aware that you can spoof the referer, but it's part of the requirement.

1 Answer

0 votes
by (32.1k points)
edited by

If I understand the question correctly you have client sites that refer to your site by embedding IFrames in their webpages the point to your site. You wish to "ensure" that the requests are coming from host page which itself is part of a designated set of sites. The set of designated sites is described by a set of IP addresses. Does that cover it?

Tricky. First off lets assume you've got a referer. You will need to aquire the host name from it (easy enough using the Uri type). Then you need to resolve the IP address for the host name using DNS (again not too difficult with .NET framework).

Of course you need to get a referer and that is the trickiest bit. Browsers do not always place a referer header in the request. This is especially true when the referee address is not in the same domain as the referer, which is the case here. IOW, this is a showstopper.

A better approach to solving this problem (and is not prone to spoofing) is to use some hash based authentication. Doesn't have to be too sophisticated (if the original requirements felt the referer testing was sufficient anyway).

Enroll in this Salesforce Certification to start your journey today!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Oct 5, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.7k questions

32.8k answers


109k users

Browse Categories