source: TI12-security/trunk/perl/ndgaccess.pl @ 3780

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/perl/ndgaccess.pl@3780
Revision 3780, 1.0 KB checked in by pjkersha, 12 years ago (diff)

Working version of NDG Security Perl client - acts as a client to Single
Sign On and Gatekeeper.

  • Property svn:executable set to *
RevLine 
[3780]1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5use CGI;
6
7# TODO: remove for production - this is for debug only
8use CGI::Carp qw/fatalsToBrowser/;
9
10use NDG::Security::Client;
11
12my $cgi = CGI->new();
13#my $session = ndgsecurity::ssoclient->new($cgi);
14my $cfgFilePath = "/var/www/cgi-bin/NDG/Security/conf/ndg-security-client.cfg";
15my $session = eval {new NDG::Security::Client($cfgFilePath, $cgi)};
16
17# Call Single Sign On handler
18my $redirectHdr = $session->ssoHandler();
19if ($redirectHdr)
20{
21    # A redirect header has been created indicating
22    # 1) the handler has received a response from a Single Sign Service
23    # or
24    # 2) User is not logged in - redirecting to WAYF
25    print $redirectHdr;
26}
27else
28{
29    # Check access for this page
30    my $dir = "/var/www/cgi-bin/";
31    my $msg;
32   
33    my $accessDecision = $session->pep($dir);
34   
35    print $cgi->header('text/html');
36    print $cgi->start_html('NDG Secured Resource'),
37    $cgi->h1('NDG Secured Resource'),
38    $accessDecision->{msg}, $cgi->p,
39    $cgi->hr;
40   
41    print $cgi->end_html;
42}
43   
Note: See TracBrowser for help on using the repository browser.