473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Set auththentication header via script?

I have a situation where I'm currently using Basic authentication (the
server issues a 401, the client pops up its window, etc., etc.).

Instead of having the server send out a 401, I would like to send out
my own page that would create the proper header field for all
subsequent requests from that client. Can such be done with JS? Can
someone point me to an example?

I do not need encoding. This is on an intranet and the authentication
is being used mainly to return different information to different
users as opposed to trying to keep out the "bad guys".

Thanks.
Jul 23 '05 #1
6 5792
Hi,
I have the same problem.

Have you found an example or anything else?

thanks.

Giuliano
"Martin" <ma**********@comcast.net> wrote in message
news:bu********************************@4ax.com...
I have a situation where I'm currently using Basic authentication (the
server issues a 401, the client pops up its window, etc., etc.).

Instead of having the server send out a 401, I would like to send out
my own page that would create the proper header field for all
subsequent requests from that client. Can such be done with JS? Can
someone point me to an example?

I do not need encoding. This is on an intranet and the authentication
is being used mainly to return different information to different
users as opposed to trying to keep out the "bad guys".

Thanks.

Jul 23 '05 #2
What I have found is that, apparently, it can't be done.

I exchanged some e-mails with someone, talked with a couple of people
and have Googled extensively. It appears that trying to set the
contents of the headers simply is not possible with javascript.

I wish there was a way - this method of authentication is exactly what
I want to do. I've reviewed several other ways of doing it and they
are all relatively difficult to implement. In fact, I will probably be
posting some questions somewhere now asking about ways to do this.

In my case, all I want to do is provide a custom interface for the
user to key in his userid and password. :(

Martin

On Tue, 19 Oct 2004 11:55:34 +0200, "Giuliano" <pa*****@palosco.eu>
wrote:
Hi,
I have the same problem.

Have you found an example or anything else?

thanks.

Giuliano
"Martin" <ma**********@comcast.net> wrote in message
news:bu********************************@4ax.com.. .
I have a situation where I'm currently using Basic authentication (the
server issues a 401, the client pops up its window, etc., etc.).

Instead of having the server send out a 401, I would like to send out
my own page that would create the proper header field for all
subsequent requests from that client. Can such be done with JS? Can
someone point me to an example?

I do not need encoding. This is on an intranet and the authentication
is being used mainly to return different information to different
users as opposed to trying to keep out the "bad guys".

Thanks.


Jul 23 '05 #3
Martin wrote:
In my case, all I want to do is provide a custom interface for the
user to key in his userid and password. :(


Perhaps you could have said that before...

<FORM action=""
onsubmit="location.href='http://' +
this.n.value + ':' + this.pw.value +
'@www.yourdomain.com/protectedfolder/';
return false;">
<LABEL>Name: <INPUT type="text" name="n"></LABEL><BR>
<LABEL>Password: <INPUT type="password" name="pw"></LABEL><BR>
<INPUT type="submit" value="Submit">
</FORM>

Obviously this won't work in browsers where Javascript is unavailable.
What's wrong with the standard interface?

Phil

--
Philip Ronan
ph***********@virgin.net
(Please remove the "z"s if replying by email)
Jul 23 '05 #4
I don't see where your code does anything to authenticate the user
(ie: create the "authorization" header that gets sent to the server).

As I said in my original post, when the server receives an
un-authenticated "post" or "get", it issues a code 401 response. This
causes the browser to pop up its built-in prompt for userid and
password. When that is returned to the server, the server can accept
or reject. If it accepts, then through some mechanism that I don't
fully understand, all further exchanges with that client will contain
a valid "authorization" header. I have my server-side scripting set up
to check this header on every "post" and every "get" to control what
that particular user sees.

I was hoping that I could serve my own page (instead of sending a code
401) that would accomplish the same thing - apparently I can't. Any
other approach I take (including what you suggested) means that I have
to keep track of the user's session manually in some manner so that he
doesn't have to log in for every different page he wants to look at.

As to what's "wrong" with the standard pop up prompt: nothing really -
I just wanted to have a unique page that visually matched the rest of
the pages. Also, I have some thoughts of using a "PIN" number to
control access instead of the traditional userid and password.
On Tue, 19 Oct 2004 14:45:32 +0100, Philip Ronan
<ph***********@virgin.net> wrote:
Martin wrote:
In my case, all I want to do is provide a custom interface for the
user to key in his userid and password. :(


Perhaps you could have said that before...

<FORM action=""
onsubmit="location.href='http://' +
this.n.value + ':' + this.pw.value +
'@www.yourdomain.com/protectedfolder/';
return false;">
<LABEL>Name: <INPUT type="text" name="n"></LABEL><BR>
<LABEL>Password: <INPUT type="password" name="pw"></LABEL><BR>
<INPUT type="submit" value="Submit">
</FORM>

Obviously this won't work in browsers where Javascript is unavailable.
What's wrong with the standard interface?

Phil


Jul 23 '05 #5
Martin wrote:
I don't see where your code does anything to authenticate the user
(ie: create the "authorization" header that gets sent to the server).


Sorry. for a moment there I thought I understood what you were going on
about.

A URL of the form http://username:pa******@domain.com/protectedfolder/ will
bypass the usual authentication procedure. I thought that was what you were
after.

Apparently not. :-(

--
Philip Ronan
ph***********@virgin.net
(Please remove the "z"s if replying by email)
Jul 23 '05 #6
Philip Ronan wrote:
A URL of the form http://username:pa******@domain.com/protectedfolder/
will bypass the usual authentication procedure. [...]


Only in borken UAs. HTTP does not allow such URLs.
PointedEars
--
I find your lack of faith disturbing! ::starts choking::
Jul 23 '05 #7

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

Similar topics

10
by: Margaret MacDonald | last post by:
I'm seeing a problem that has me flummoxed. The only thing I can think of is that I'm violating some rule I don't know about. I have some code that does some processing and then does a...
10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
1
by: Patrick Gibbons | last post by:
What I would like to do is create header and footer information for my webpages which are created by calling from a referenced .js page . . . for example in Header.js: <script...
2
by: . . | last post by:
Hi I need some help with java script . I have a ASPX page that is pulling a user message heading from the table on the page . The user message header has message body which suppose to dispay...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
3
by: jonathan184 | last post by:
script is printing output correct but not the actual output. Basically what the script is doing it taking a 1 flat file then it is splits the file into smaller files in 1000 record increments ...
1
by: Shalako | last post by:
I check my error log and see these entries: malformed header from script. Bad header= Missing gauge reports are ind: padata.pl /perl/pema/padata.pl did not send an HTTP header malformed...
2
by: Raffi | last post by:
I have a php script which generates a zip file that contains an ASCII text file. The script then prompts the user to save/open the zip file. The script is on a server that is behind an Apache proxy...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.