Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Guest Access to Website

Tags:

security

php

I have a PHP project is essentially an order processing website for a company. Each user in the company has access to this website and is given certain credentials to the application that control access to pages and functionality throughout.

Now I have a request to allow a guest access to a single page. The complexity of this request is that the guest will be different each time as well as the page will be different. Basically it is a portal to allow customers, who don't have accounts within the system as there is no live ordering on this site, to be able to access and verify the order and shipping information.

My thought to accomplish this is to have a database table setup as a guest relationship table that will be used to store UIDs, MD5 Hash Keys and the destination page that the record is referring to. Also included would be a visit counter and expiration date. When the user receives an email they would have a link provided in the email to somewhere like http://website.com/verify/?HASH-KEY.

When this link is clicked I expect that the verify index.php page takes in the HASH, verifies it in the database and displays the page reference in the database within this location instead of redirecting into the application. This would allow guest access to the single page without the need to expose the structure of the website or a rework of the user authorization already setup.

  1. Am I approaching this solution in the proper manner?
  2. How do I grab the contents of one page and display it in another?
like image 233
Jeff Avatar asked Feb 29 '12 19:02

Jeff


2 Answers

1. Am I approaching this solution in the proper manner?

Yep, more or less.

Some pointers:

  • Make sure you seed hash generation randomly. For example, DON'T simply MD5 a customer ID or some other small/sequential number, as that would make it easy for a malicious use to hunt down other pages.
  • Expire the hashed links after a set time out.

2. How do I grab the contents of one page and display it in another?

If you want people to "access and verify the order and shipping information" you should probably create a page specifically for it, instead of trying to pass through normally secure pages to insecure guests. Ie, a 'shipping confirmation page' that populates details according the data keyed by the supplied hash.

like image 78
Hamish Avatar answered Nov 08 '22 08:11

Hamish


I'm trying to a follow this as well as I can.

It seems to be you should use your hash method, and just have a stand alone page that will generate the content you want, totally separate from the rest of the system. Just put enough data in your hash URL to determine what is needed.

Something else to do is use a timestamp in your hash string URL and have that timestamp part of the random bits that you generate your hash on. This will allow you to make a URL essentially "expire" after a certain point.

Example: url.com/in/123456789865/hash-here

You can compare "123456789865" in this example to the current server time and determine if its expired. Of course you need to make "123456789865" part of your hash encryption to still validate

like image 21
Josh Marthaller Avatar answered Nov 08 '22 09:11

Josh Marthaller