Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between HTTP Authorization header and Query string parameters

While I was reading about interaction with Amazon S3, I came to know that request authentication with Amazon AWS is done in 2 ways

  1. HTTP Authorization: Using the HTTP Authorization header is the most common method of providing authentication information
  2. Query string parameters: Using query parameters to authenticate requests is useful when you want to express a request entirely in a URL. This method is also referred as presigning a URL.

The question is in which situation should I prefer one method over the other. Do these two authentication methods have their own advantages and disadvantages? As a developer, by using query string parameters method I can presign the URL which enables the end users to temporarily access the Amazon S3 resources by entering the presigned URL in the web browser. Can I use HTTP Authorization method to achieve the same thing? If so which method is better to use and what are their respective limitations?

like image 941
Prudhvi Avatar asked May 15 '15 23:05

Prudhvi


People also ask

What is the difference between header and query parameters?

From the security point of view, there's no difference on using HTTP Header vs Query Param since both are encrypted when using TLS/SSL. But query params can be more fragile since it can be easily visible in browsers, are logged across the board by default (browser history, web servers access logs and etc).

What is the difference between URL parameters and query strings?

URL parameters are commonly used to sort content on a page, making it easier for users to navigate products in an online store. These query strings allow users to order a page according to specific filters and to view only a set amount of items per page.

What is HTTP Authorization header?

The HTTP Authorization request header can be used to provide credentials that authenticate a user agent with a server, allowing access to a protected resource. The Authorization header is usually, but not always, sent after the user agent first attempts to request a protected resource without credentials.

What is difference between query and parameter?

Parameters are key-value pairs that can appear inside URL path, and start with a semicolon character ( ; ). Query string appears after the path (if any) and starts with a question mark character ( ? ). Both parameters and query string contain key-value pairs.


2 Answers

Can I use HTTP Authorization method to achieve the same thing?

Sometimes. The key difference is that, as a developer, you don't always have enough control over the user agent to inject a header. The most obvious example of this is a simple GET request launched by a web browser in response to the user clicking a link. In that situation, you don't have the a ability to inject an Authorization: header for the browser to send ... so pre-signing the URL is all you can do.

Importantly, there's no information in a signed URL that is considered sensitive, so there's no particularly strong motivation to use the header instead of a signed URL. Your AWS Access Key ID is not secret, and your AWS Secret can't be derived from the other elements and the signature in a computationally-feasible time frame, particularly if you use Signature Version 4, which you should. Signature Version 2 is not officially deprecated in older regions, but newer S3 never supported it and likely never will.

When you do control the user agent, such as in back-end server code, adding the header may be preferable, because you don't need to do any manipulation of the URL string you already have in-hand.

like image 133
Michael - sqlbot Avatar answered Sep 30 '22 15:09

Michael - sqlbot


The overview in the first AWS page says what the difference is:

Except for POST requests and requests that are signed by using query parameters, all Amazon S3 bucket operations and object operations use the Authorization request header to provide authentication information.

Basically a POST is used for HTML forms (discussed at length in the Mozilla page). You would use forms whenever the request involves passing data to the remote server, versus just checking status. As noted in HTML method Attribute (W3Schools),

Never use GET to send sensitive data! (will be visible in the URL)

as distinguished from POST:

Appends form-data inside the body of the HTTP request (data is not shown is in URL)

like image 40
Thomas Dickey Avatar answered Sep 30 '22 17:09

Thomas Dickey