Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Starting a new DBMan SQL session from another application - without Authenication

Quote Reply
Starting a new DBMan SQL session from another application - without Authenication
Here is what I need help with.

I have an authenicated user is another non DBMan SQL ( App1) web application/website with the same username as in DBMan SQL application (App2). That is the user already exists in the DBMan SQL user tables with all the details. What it really means that the user has the same username and password in both applications --- or the user tables are sync-ed.

What I need that a user who is using App1 (Non DBMan SQL app) is authenticated & from there I want to invoke DBMan SQL App2.

I need help with Perl code to start the App2 session without asking the user to login by giving Username and Password ---- a single signon.

So in Perl lets say $username variable contains the username of the user, which exist in the user table of App2. I think if you look at db.cgi and home.pm files, what I am trying to do should be possible. This kind of feature might be required by many & may lead to many interesting possibilities like logging in already logged in Facebook users etc.

The main subs in home.pm that we need is the sub called login(). I think login() can be leveraged to create a session and start the DBMan SQL app2 or some code from it can be taken & modified to achieve it.

If you tell me - how to make a call to login() to start this session it will great help. What all information is required besides $username to create the session? if any other user details like passowrd is required it can bepulled from the user table.

Here is the sub login() from home.pm. I know we need to call this login sub, but I can not figure out what information is being passed to it, that is required for starting the session.

Another big question is --- do we need to do any other steps in preparation to setup any configuration details etc before calling login().

If anyone can help me with how to call this sub, and what all to pass. Any ideas or help in making this work will be greatly appreciated.

If you want any further info or clarification, let me know.

sub login {
# Login users, if login failure display login_failure else display home page
my $self = shift;

if ( !$self->{cgi}->{Username} or !$self->{cgi}->{Password} ) {
return $self->login_form($self->_language('AUTH_FAILURE'));
# Check that the user exists, and that the password is valid.
$self->{user} = $self->_authenticate();
if ( !$self->{user} ) {
$self->auth_logging ("$self->{cgi}->{Username} failed to logon") if ($self->{cfg}->{log_file});
return $self->login_form($self->_language('AUTH_FAILURE'));

return $self->login_form($self->_language('AUTH_FAIL_VAL')) if ($self->{user}->{Status} eq 'Not Validated');
my $msg = ($self->_check_pers())? $self->_language('MSG_LOGGED',$self->{cgi}->{db}): $self->_language('PER_FAILURE',$self->{cgi}->{db});
# Create session
my $results = Dbsql::Authenticate::auth('create_session', {Table => $self->{cfg}->{'user_table_use'}, Username => $self->{user}->{Username}}) or return $self->error("Unable to create session!");
$self->{cgi}->{use_cookie} = $results->{use_cookie};
$self->{cgi}->{session_id} = $results->{session_id};
$self->auth_logging('log on ') if ( $self->{cfg}->{log_file} );
return ('home.html', {
header => $self->_language('HEA_HOME'),
msg => $msg