Hi,
I use LWP::UserAgent to automate windows login process. I set the credentials using $ua->credentials("h ost:port","real m","id","passwo rd"); but it fetches only the current page requested. It fails for subsequent requests and pops up the windows form again to supply the credentials. I have created a cookie jar too but this doesnt help as the authentication is not sticking. Any help on this is highly appreciated.
The code is as follows. -
# Module: authenticate.pl
-
# @author Kiran Kamath
-
-
#flush the buffer
-
$|=1;
-
use CGI;
-
use CGI::Request;
-
-
use LWP::UserAgent;
-
use HTTP::Request;
-
use LWP::ConnCache;
-
use HTTP::Cookies;
-
use LWP::DebugFile;
-
-
# Configurations required for the script
-
require "authvar.ph";
-
use POSIX qw(strftime);
-
-
# Set up Alert log
-
-
open(ALERTS,"$AUTH_LOG") or warn "Cannot open alert log file:$!";
-
$AlertDate=`date $AUTH_DATE_FORMAT`;
-
chomp($AlertDate);
-
-
print ALERTS "$AlertDate authenticate-module entry\n\n" if($AUTH_DEBUG);
-
-
#Get username and password from POST message
-
-
$req = GetRequest($pkg);
-
$uid=$req->param('uid');
-
$passwd=$req->param('passwd');
-
my $timeout=10;
-
$uid=some id ;
-
$passwd=some passwd ;
-
-
if(defined($uid) && defined($passwd))
-
{
-
chomp($uid); chomp($passwd);
-
print ALERTS "$AlertDate [ UID=$uid , PASSWD=$passwd ]\n";
-
-
-
my($res,$request);
-
-
# LWP::UserAgent is a class implementing a web user agent used to dispatch web requests.
-
$ua = LWP::UserAgent->new();
-
$ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727)');
-
-
#Set the timeout so that requests is aborted if no activity on the connection to the server is observed for timeout seconds.
-
$ua->timeout($timeout);
-
-
-
# Set the credentials for a realm
-
$ua->credentials("$AUTH_DOMAIN:$AUTH_PORT","$AUTH_NAME","$uid","$passwd");
-
-
# LWP::ConCache is used for the browser to support HTTP Keep-Alive
-
# This is required so that after the request is performed connection is not lost and is persistent.
-
-
$cache=$ua->conn_cache(LWP::ConnCache->new());
-
-
# Cache all the connections
-
$ua->conn_cache->total_capacity(undef);
-
-
$cookie_jar=HTTP::Cookies->new();
-
$cookie_jar->set_cookie("1","nortelid","axptnrtl","/","naxptsts.intec.telcordia.com","4443",1,1,3600,0);
-
-
# Give the browser an in-memory empty cookie jar
-
$ua->cookie_jar($cookie_jar);
-
$ua->default_header('Accept-Language'=>'en-us');
-
$ua->default_header('Accept-Encoding'=>'gzip, deflate');
-
#$ua->default_header('Accept'=>'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*');
-
$ua->default_header('Accept'=>'*/*');
-
-
-
$request = new HTTP::Request('GET', $AUTH_URI);
-
-
$cookie_jar->add_cookie_header($request);
-
-
$res=$ua->request($request);
-
-
$cookie_jar->extract_cookies($res);
-
-
my $status = $res->code;
-
print ALERTS "$AlertDate Return Status for $AUTH_URI was $status\n";
-
-
if($res->is_success){
-
$status_message=$res->as_string;
-
#print ALERTS "$AlertDate [DEBUG STATUS MESSAGE=$status_message]\n\n";
-
print $res->content;
-
print ALERTS "$AlertDate [Success Redirecting]\n\n";
-
}
-
else
-
{
-
print ALERTS "$AlertDate [Authenticate Header= " . $res->header('WWW-Authenticate') . "]\n";
-
print ALERTS "$AlertDate [ERROR STATUS: " .$res->status_line. "]\n\n";
-
}
-
}
-
-
print ALERTS "$AlertDate authenticate-module exit\n\n" if($AUTH_DEBUG);
-
close(ALERTS);
-
Thanks
Kiran
4 4232
Hi,
I got the script working when i use webserver url (http). However it doesnt work when going through a proxy server (https). After displaying the initial page it prompts for credentials. This doesnt happen with http. I set env proxy in the script. It handles subsequent requests too. In case of https (proxy server), it doesnt maintaain the credentials for a particular realm.
Any help on this is appreciated.
Thanks
Kiran Kamath
numberwhun 3,509
Recognized Expert Moderator Specialist
Hi,
I got the script working when i use webserver url (http). However it doesnt work when going through a proxy server (https). After displaying the initial page it prompts for credentials. This doesnt happen with http. I set env proxy in the script. It handles subsequent requests too. In case of https (proxy server), it doesnt maintaain the credentials for a particular realm.
Any help on this is appreciated.
Thanks
Kiran Kamath
The reason that doesn't happen for HTTP is because HTTP is not an authenticated, secure session. HTTPS denotes an SSL session that is authenticated and secure. If you are using it, then you should setup to handle it. I haven't played with LWP yet, but I am sure that the documentation would go over this.
Regards,
Jeff
The reason that doesn't happen for HTTP is because HTTP is not an authenticated, secure session. HTTPS denotes an SSL session that is authenticated and secure. If you are using it, then you should setup to handle it. I haven't played with LWP yet, but I am sure that the documentation would go over this.
Regards,
Jeff
The documentation doesnt describe anything on this. Can the ACL's on the proxy server be configured to get this working?
Thanks
Kiran
Hi,
How to make authentication stick to subsequent pages using LWP . I tried creating cookies after authentication against a realm. but subsequent requests asks for credentials. Anyone knows how to accomplish this? Any help is highly appreciated.
Thanks
Kiran
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mark H |
last post by:
Hey all--
I'm building a database and I basically need to keep out people who
aren't authorized, but it's not like I need top security here. I'm just
doing basic user/pass of a SQL database, and when a user authenticates
I start a session for him.
My question is, is there any way for a hacker to easily start a session
without having logged in? For instance, if I save the user name and IP
address in the session will it be relatively...
|
by: Jp Calderone |
last post by:
I've been trying to implement support for this authentication scheme for a
little while now, and in the last couple days I've been completely stumped.
I know about the digest authentication code in urllib2, and while I'd like
to use it directly, it is too closely tied to HTTP for my needs.
I have taken hints from the code, but I am still stuck with something that
doesn't recognize correct challenge responses as correct.
I've reduced...
|
by: Michael Foord |
last post by:
#!/usr/bin/python -u
# 15-09-04
# v1.0.0
# auth_example.py
# A simple script manually demonstrating basic authentication.
# Copyright Michael Foord
# Free to use, modify and relicense.
# No warranty express or implied for the accuracy, fitness to purpose
|
by: Bob Everland |
last post by:
I have an application that is ISAPI and the only way to
secure it is through NT permissions. I need to have a way
to login to windows authentication so that when I get to
the ISAPI application no boxes come up. I want an ASP page
to sit between the user and the ISAPI application. The
rest of my application is using authentication that is
database driven and wouldn't want the users to know the
userid and password. Is this possible? If so...
|
by: Billy Jacobs |
last post by:
I have a website which has both secure and non-secure
pages. I want to uses forms authentication. How do I
accomplish this?
Originally I had my web.config file in the root with Forms
Authentication set up and it worked just fine. Then I
realized that I needed to have some pages unsecure.
I then created 2 directories. One named Secure and the
other named Public. I placed my web.config file in my
| |
by: Tom B |
last post by:
In my web.config file I've specified Windows for the authentication, in IIS
I've set it to Integrated Authentication.
But my SQL connection is still showing Anonymous.
Is there somewhere else I need to check?
Thanks
Win 2003, SQL Server 2000
|
by: Anonieko Ramos |
last post by:
ASP.NET Forms Authentication Best Practices
Dr. Dobb's Journal February 2004
Protecting user information is critical
By Douglas Reilly
Douglas is the author of Designing Microsoft ASP.NET Applications and
owner of Access Microsystems. Doug can be reached at
doug@accessmicrosystems.com.
--------------------------------------------------------------------------------
|
by: Rippo |
last post by:
Hi
I am using role base forms authentication in asp.net and have come
across a problem that I would like advice on.
On a successful login a session variable is set to identify a user.
This is all good as this session variable is used to retrieve data for
that user etc. However if I restart the webserver then the users
session is lost but the ticket is still active. Therefore the user is
not redirected back to the login page.
|
by: Frank Swarbrick |
last post by:
I am trying to understand "client authentication" works. My environment is
DB2/UDB LUW 8.2 on zSeries SLES9 as the database server and DB2 for VSE 7.4
as the client. We currently have DB2/LUW set up as follows:
Client Userid-Password Plugin (CLNT_PW_PLUGIN) =
Client Kerberos Plugin (CLNT_KRB_PLUGIN) =
Group Plugin (GROUP_PLUGIN) =
GSS Plugin for Local Authorization ...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |