Project

General

Profile

« Previous | Next » 

Revision 9536

Added by Chris Jones over 8 years ago

Change getUsername() to also support adding usernames into an EML access element from the authentication token's 'sub' claim.
Also, add a bit of debugging output for tracing the flow of the XML generation.

refs https://github.nceas.ucsb.edu/KNB/arctic-data/issues/42

View differences:

src/perl/register-dataset.cgi
1537 1537
#
1538 1538
################################################################################
1539 1539
sub createXMLDocument {
1540
    if ( $debug_enabled ) {
1541
        debug("createXMLDocument() called.");
1542
        
1543
    }
1544
    
1540 1545

  
1541 1546
	#FIXME placeholder for $FORM element, should be determined by config
1542 1547

  
......
1578 1583
}
1579 1584

  
1580 1585
sub createDatasetDocument {
1581
	my $doc = EMLStart();
1586
	
1587
    if ( $debug_enabled ) {
1588
        debug("createDatasetDocument() called.");
1589
        
1590
    }
1591
    
1592
    my $doc = EMLStart();
1582 1593
	$doc .= accessElement();
1583 1594
	$doc .= datasetStart();
1584 1595
	$doc .= titleElement();
......
2394 2405
}
2395 2406

  
2396 2407
sub accessElement {
2397
	my $public = shift;
2408
	
2409
    if ( $debug_enabled ) {
2410
        debug('accessElement() called.');
2411
    }
2412
    
2413
    my $public = shift;
2398 2414
	if ( !$public ) {
2399 2415
		$public = $config->{'publicReadable'};
2400 2416
	}
......
2435 2451
}
2436 2452

  
2437 2453
sub getUsername() {
2454
    
2455
    if ( $debug_enabled ) {
2456
        debug('getUsername() called.');
2457
        
2458
    }
2459
    
2438 2460
	my $username = '';
2439 2461
	my $authBase = $properties->getProperty("auth.base");
2440 2462

  
2463
    # Support authentication token usernames
2464
    my $token_info = getTokenInfo();
2465
    
2466
    if ( $token_info->{'isValid'} ) {
2467
        $username = $token_info->{'sub'};
2468
        debug("Username: $username");
2469
        return $token_info->{'sub'};
2470
        
2471
    }
2472
    
2473
    # Support CGI session usernames
2441 2474
	if ( $FORM::username ne '' ) {
2442 2475
		$username =
2443 2476
		  "uid=$FORM::username,o=$FORM::organization,$authBase";

Also available in: Unified diff