Changeset 4902
- Timestamp:
- 03/02/09 12:55:39 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/perl/NDG/Security/Client.pm
r3780 r4902 62 62 -salt=>1); 63 63 64 # Supply encoded form of return to URL ready to be passed to SSO Service for user login 64 # Supply encoded form of return to URL ready to be passed to SSO Service 65 # for user login 65 66 $self->{b64encReturnToURL} = ''; 66 67 … … 93 94 if ($self->{cgi}->param('h')) 94 95 { 95 # 'h' argument is present in query indicating a GET call from a Single Sign On 96 # Service in response to a login 97 98 # Set a cookie based on the query args supplied from the SSO Service response 96 # 'h' argument is present in query indicating a GET call from a Single 97 # Sign On Service in response to a login 98 99 # Set a cookie based on the query args supplied from the SSO Service 100 # response 99 101 my $cookie = $self->_setSessionFromSSOResp(); 100 102 … … 104 106 my $returnToURL = "http://" . $virtualHostName . $urlPath . $query; 105 107 106 $log->info("Generating redirection header for redirect to ".$returnToURL."..."); 108 $log->info("Generating redirection header for redirect to " 109 .$returnToURL."..."); 107 110 108 111 # nph flag crashes with Apache - intended for MS IIS? 109 112 return $self->{cgi}->redirect(-uri=>$returnToURL, -cookie=>$cookie); 110 113 } 114 elsif ($self->{cgi}->param('logout')) 115 { 116 # Service in response to a logout - strip logout query arg 117 my $query = $self->_stripSecurityQueryArgs(); 118 119 my $returnToURL = "http://" . $virtualHostName . $urlPath . $query; 120 $log->info("Generating redirection header following logout for ". 121 "redirect to ".$returnToURL."..."); 122 123 return $self->{cgi}->redirect(-uri=>$returnToURL); 124 } 111 125 elsif (! $self->_getSessionFromCookie()) 112 126 { 113 127 $self->_makeHttpsReturnToURL(); 114 128 my $wayfURI = $self->{wayfURI}."?r=".$self->{b64encReturnToURL}; 115 $log->info("User not logged in - Generating redirection header for WAYF:".116 129 $log->info("User not logged in - Generating redirection header for ". 130 "WAYF: ".$wayfURI."..."); 117 131 118 132 return $self->{cgi}->redirect(-uri=>$wayfURI); … … 120 134 else 121 135 { 122 # No Call to the Single Sign On Service has been made - prepare return to URL 123 # for such a call - encode it ready to be incorporated into a login request to # the Single Sign On Service 136 # No Call to the Single Sign On Service has been made - prepare return 137 # to URL for such a call - encode it ready to be incorporated into a 138 # login request to # the Single Sign On Service 124 139 # 125 # URL is set to https to ensure encrypted channel for SSO service -> to THIS126 # SSO client transfer140 # URL is set to https to ensure encrypted channel for SSO service -> to 141 # THIS SSO client transfer 127 142 $self->_makeHttpsReturnToURL(); 128 143 return ''; … … 144 159 } 145 160 146 $log->info("Generating return to URL with SSL transport ".$returnToURL."..."); 161 $log->info("Generating return to URL with SSL transport ". 162 $returnToURL."..."); 147 163 148 164 $self->{b64encReturnToURL} = pyUrlSafeB64Encode($returnToURL); … … 157 173 my $val; 158 174 159 # Iterate through the keys adding to the query string only if they are non-security160 # related and they are a genuine URL parameter175 # Iterate through the keys adding to the query string only if they are 176 # non-security related and they are a genuine URL parameter 161 177 while (($key, $val) = each %arg) 162 178 { … … 251 267 252 268 253 # Policy enforcement Point - provide access control decision given resource constraints254 # and user attributes269 # Policy enforcement Point - provide access control decision given resource 270 # constraints and user attributes 255 271 sub pep 256 272 { … … 261 277 my $session = $self->_getSessionFromCookie(); 262 278 263 my $msg = "resource ".$resrcFilePath." for user ".$session->{u}." with session ID = ". 264 $session->{sid}; 279 my $msg = "resource ".$resrcFilePath." for user ".$session->{u}. 280 " with session ID = ". 281 $session->{sid}; 265 282 266 283 # Gather access constraint information for resource … … 268 285 if ($accessInfo[0]) 269 286 { 270 # Access may be granted if read permission is set to public or if the file271 # is previously cached287 # Access may be granted if read permission is set to public or if the 288 # file is previously cached 272 289 $log->info("Access granted for ".$msg.": ".$accessInfo[1]->{msg}); 273 290 return 1; … … 293 310 sub getFTPAccessFileReadPermissionsInfo 294 311 { 295 # Adapted from FTPaccess::read_access for use with NDG Security - changed so that 296 # all access info is returned and now username or user group info is checked. The 297 # latter needs to be done by python code checking the user's NDG Attribute Certificate 298 299 # Returns flag indicating if the user is allowed to read the directory containing 300 # the given file. Also returns hash giving information about how the result was 301 # arrived at. 312 # Adapted from FTPaccess::read_access for use with NDG Security - changed 313 # so that all access info is returned and now username or user group info 314 # is checked. The latter needs to be done by python code checking the 315 # user's NDG Attribute Certificate 316 317 # Returns flag indicating if the user is allowed to read the directory 318 # containing 319 # the given file. Also returns hash giving information about how the result 320 # was arrived at. 302 321 my $filePath = shift; # File or directory name to check access for 303 322 my %info; 304 323 305 my $ftpaccess_file =BADC::FTPaccess::find_nearest_ftpaccess_file($filePath);324 my $ftpaccess_file=BADC::FTPaccess::find_nearest_ftpaccess_file($filePath); 306 325 my $ftpaccess = BADC::FTPaccess->new($ftpaccess_file); 307 326 308 327 $info{filePath} = $ftpaccess_file; 309 328 310 # Check that we do actually have an ftpaccess file to interogate. If not then grant311 # read access329 # Check that we do actually have an ftpaccess file to interogate. If not 330 # then grant read access 312 331 if (not $ftpaccess) 313 332 { … … 337 356 $info{allowedUsers} = \@allowedUsers; 338 357 339 $info{msg} = 340 "username and/or group information is needed to determineaccess permissions";358 $info{msg} = "username and/or group information is needed to determine ". 359 "access permissions"; 341 360 return (0, \%info); 342 361 }
Note: See TracChangeset
for help on using the changeset viewer.