473,463 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Authentication before redirection

Hi,

I'm hoping someone on this forum can help me.
I was wondering if it was possible to add/modify the authentication in the
headers before redirecting the client to a new url.

For example if you sent out these headers:
header('WWW-Authenticate: Basic realm="SomeRealm"');
header('HTTP/1.0 401 Unauthorized');

and then if the correct authorization was returned in

$_SERVER['PHP_AUTH_USER']
$_SERVER['PHP_AUTH_PW']

could you then modify those authentication values in the headers and then
redirect to a different url?

--
Larry Gillstrom

Jul 17 '05 #1
7 1867
Try this:

header("Location: http://username:pa******@somewhere.net/page.php");

Don't know if it still works in IE6.

Uzytkownik "Larry Gillstrom" <lg********@dccnet.com> napisal w wiadomosci
news:10*************@corp.supernews.com...
Hi,

I'm hoping someone on this forum can help me.
I was wondering if it was possible to add/modify the authentication in the
headers before redirecting the client to a new url.

For example if you sent out these headers:
header('WWW-Authenticate: Basic realm="SomeRealm"');
header('HTTP/1.0 401 Unauthorized');

and then if the correct authorization was returned in

$_SERVER['PHP_AUTH_USER']
$_SERVER['PHP_AUTH_PW']

could you then modify those authentication values in the headers and then
redirect to a different url?

--
Larry Gillstrom


Jul 17 '05 #2
Chung Leong wrote upsidedown:
header("Location: http://username:pa******@somewhere.net/page.php");
Not only is that form of URL disallowed for http URLs (not that much
of anything pays attention to that) -- meaning your Location field
value violates RFC2616, which requires an absolute URL (and not many
browsers bother about that either) -- but, more importantly, sending
authentication details in URLs is a potential security risk.
Don't know if it still works in IE6.


Neither do I, and to be honest I'm not really interested. But going
by the user-contributed notes in the Manual's section on HTTP
authentication, "IE stopped supporting URLs in that format", whatever
that means.

--
Jock
Jul 17 '05 #3
John Dunlop <jo*********@johndunlop.info> wrote in message news:<MP************************@News.Individual.N ET>...
Chung Leong wrote upsidedown:
header("Location: http://username:pa******@somewhere.net/page.php");
Not only is that form of URL disallowed for http URLs (not that much
of anything pays attention to that) -- meaning your Location field
value violates RFC2616, which requires an absolute URL (and not many
browsers bother about that either) -- but, more importantly, sending
authentication details in URLs is a potential security risk.


When I want to do a redirect like that I use output buffering. For
example:

<?php

// Start output buffering
ob_start();

// Do some stuff
if ($_SESSION['authStatus'])
{
header("Location: /login.php");
}

// Explicit flushing of the buffer
ob_end_flush();

?>

The down side to this approach is that nothing will be sent to the
browser until all of the processing is complete. However, you do not
need to worry about the error message concerning sending text before
sending the new header.
Don't know if it still works in IE6.


Neither do I, and to be honest I'm not really interested. But going
by the user-contributed notes in the Manual's section on HTTP
authentication, "IE stopped supporting URLs in that format", whatever
that means.


Due to the number of security incidents with flase URIs, Microsoft has
said that they will stop supporting that format in IE. People would
create a link something along the lines of
"ww**************@www.realsite.ru/login.php" where you would actually
go to the second portion of the link, when people thought they were
going to the first portion.

/s/ WP
Jul 17 '05 #4

Uzytkownik "John Dunlop" <jo*********@johndunlop.info> napisal w wiadomosci
news:MP************************@News.Individual.NE T...
Chung Leong wrote upsidedown:
header("Location: http://username:pa******@somewhere.net/page.php");


Not only is that form of URL disallowed for http URLs (not that much
of anything pays attention to that) -- meaning your Location field
value violates RFC2616, which requires an absolute URL (and not many
browsers bother about that either) -- but, more importantly, sending
authentication details in URLs is a potential security risk.


[scratch head]

How's that not an absolute URL?
Jul 17 '05 #5

Uzytkownik "Wayne Pierce" <wa***@mishre.com> napisal w wiadomosci
news:2a**************************@posting.google.c om...
Due to the number of security incidents with flase URIs, Microsoft has
said that they will stop supporting that format in IE. People would
create a link something along the lines of
"ww**************@www.realsite.ru/login.php" where you would actually
go to the second portion of the link, when people thought they were
going to the first portion.


The big question is whether they will just disallow the dot in the
username/password, or if the entire format is disabled all together. If
ftp://us**@somewhere.net is disabled too, that would create massive
disruption. On the other hand, it'd be pretty pointless if they stop only
the HTTP one.
Jul 17 '05 #6
Chung Leong wrote:
Chung Leong wrote upsidedown:

header("Location: http://username:pa******@somewhere.net/page.php");


How's that not an absolute URL?


Because it does not conform to the syntax of http URLs.

RFC2396 defines the *generic* syntax of URIs; the syntax and
semantics of http URLs are defined in RFC2616, section 3.2.2 (and
formerly in RFC1738, section 3.3). There, we're given:

http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]

RFC2616, in a previous section, delegates RFC2396 to define the
components host, port and abs_path. The relevant excerpts from
RFC2396, then, are (not in original order):

host = hostname | IPv4address
hostname = *( domainlabel "." ) toplabel [ "." ]
domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
toplabel = alpha | alpha *( alphanum | "-" ) alphanum
IPv4address = 1*digit "." 1*digit "." 1*digit "." 1*digit
port = *digit

alphanum = alpha | digit
alpha = lowalpha | upalpha
lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
"j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
"s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
upalpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
"J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
"S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
"8" | "9"

The only characters allowed in the host component of an http URL,
therefore, are alphanumerics, periods and hyphens, with further
constraints on what can appear where. Although RFC2396 allows the
format user:password@hostport in URIs, it is forbidden in http URLs;
it was *expressly* prohibited by RFC1738 -- "No user name or password
is allowed." -- so relying on it being allowed would be unwise.

--
Jock
Jul 17 '05 #7
"Chung Leong" <ch***********@hotmail.com> schrieb:
The big question is whether they will just disallow the dot in the
username/password, or if the entire format is disabled all together. If
ftp://us**@somewhere.net is disabled too, that would create massive
disruption. On the other hand, it'd be pretty pointless if they stop only
the HTTP one.


http://user:pa******@example.com is no valid URI according to the RFCs.

ftp://user:pa******@example.com is a valid URI according to the RFCs.

Regards,
Matthias
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hugh McLaughlin | last post by:
Hello Everyone and thanks for your help in advance. I recently installed Visual Studio 2003 and .Net 1.1. I then converted one of my applications to 2003. However, I am running into a probelm...
2
by: Kian Goh | last post by:
Hi there, I am trying to use an entry level security for my resources website. I followed the procedures in the MS published Self-Paced Training Kit, everything seems working as expected....
2
by: VR | last post by:
Hi, I am using Forms type of authentication, but having problems redirecting users to default page after they get authenticated. My default page is default.aspx, but it's in 'public'...
9
by: Hermit Dave | last post by:
Hi, I am making a web application (rather two applications) one which is host and used by customers when they are just browsing through products. The second application resides on a secure...
1
by: www.MSmobiles.com | last post by:
Hi! I am using something like this in web.config : <authentication mode="Forms"> <forms name=".MSMOBILES_COM___COOKIE" loginUrl="login.aspx" protection="All" timeout="30" path="/">
2
by: Grzegorz Kaczor | last post by:
Hello, I have an ASP.NET application in my website in virtual folder A. This folder contains the application itself. I also have a data virtual directory B which contains data that can be seen...
7
by: Trollpower | last post by:
Hello NG, i need to know how i can pass parameters to the loginpage if i use authentication mode Forms. I need to pass different paramaters, such as a different redirection url, strings and...
1
by: graphicsxp | last post by:
Hi, I'm using FormsAuthentication.redirectFromLoginPage() in order to to user authentication. The problem is that I'm redirected to the last page visited before the session expired (or the...
1
by: Paul Aspinall | last post by:
Hi I want to have most of my website available to users without any authentication (ie. they can freely browse). However, if they go to a restricted part, they should be redirected to a login...
2
by: Tosco | last post by:
I used to use WebBrowser in VB6, and now I want to learn how to use WebRequest in vb.net, but I'm having 2 problems. 1) Is it normal that the automatic redirection doesn't work when the page...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.