Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/MGRAST/cgi/api.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ else {

# check for authentication
my $user;
if ($cgi->http('HTTP_AUTH') || $cgi->param('auth') || $cgi->http('HTTP_AUTHORIZATION') || $cgi->param('authorization')) {
if ($cgi->http('HTTP_AUTH') || $cgi->param('auth') || $cgi->http('HTTP_Authorization') || $cgi->param('authorization')) {
eval {
require Auth;
Auth->import();
my $message;
($user, $message) = Auth::authenticate($cgi->http('HTTP_AUTH') || $cgi->param('auth') || $cgi->http('HTTP_AUTHORIZATION') || $cgi->param('authorization'));
($user, $message) = Auth::authenticate($cgi->http('HTTP_AUTH') || $cgi->param('auth') || $cgi->http('HTTP_Authorization') || $cgi->param('authorization'));
unless($user) {
unless ($message eq "valid kbase user") {
print $cgi->header( -type => 'application/json',
Expand Down
5 changes: 5 additions & 0 deletions src/MGRAST/lib/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ sub authenticate {
}
}
}

# check for MG-RAST default auth header
if ($auth_value =~ /^mgrast /) {
$auth_value =~ s/^mgrast //;
}

# check for the preference setting for the defined authentication source and value
my $preference = $master->Preferences->get_objects( { name => $auth_source, value => $auth_value } );
Expand Down
16 changes: 8 additions & 8 deletions src/MGRAST/lib/resources/inbox.pm
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ sub file_info {

# get info / update node
my $stats_info = {
type => $file_type,
suffix => $file_suffix,
file_type => $file_format,
file_name => $node->{file}{name},
file_size => $node->{file}{size},
checksum => $node->{file}{checksum}{md5}
};
type => $file_type,
suffix => $file_suffix,
file_type => $file_format,
file_name => $node->{file}{name},
file_size => $node->{file}{size},
checksum => $node->{file}{checksum}{md5}
};
my $new_attr = $node->{attributes};
if (exists $new_attr->{stats_info}) {
map { $new_attr->{stats_info}{$_} = $stats_info->{$_} } keys %$stats_info;
Expand Down Expand Up @@ -548,8 +548,8 @@ sub view_inbox {
my ($self) = @_;

my $files = [];
my $user_id = 'mgu'.$self->user->_id;
# all in inbox
my $user_id = 'mgu'.$self->user->_id;
my $inbox = $self->get_shock_query({'type' => 'inbox', 'id' => $user_id}, $self->token, $self->{user_auth});
# all in inbox viewable by mgrast
my %mgview = map {$_->{id}, $_} @{$self->get_shock_query({'type' => 'inbox', 'id' => $user_id}, $self->mgrast_token, "OAuth")};
Expand Down
3 changes: 2 additions & 1 deletion src/MGRAST/lib/resources/user.pm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ sub instance {
$self->return_data( { "login" => $self->user->{login},
"firstname" => $self->user->{firstname},
"lastname" => $self->user->{lastname},
"email" => $self->user->{email} }, 200 );
"email" => $self->user->{email},
"id" => 'mgu'.$self->user->{_id} }, 200 );
} else {
$self->return_data( {"ERROR" => "insufficient permissions for user call"}, 401 );
}
Expand Down