#1036 redux allow use of /login even when authN is delegated

This commit is contained in:
Oliver Gorwits
2023-06-22 13:19:42 +01:00
parent 3da92a9ab5
commit a7cd5603cb
3 changed files with 104 additions and 95 deletions

View File

@@ -392,10 +392,6 @@ hook 'after' => sub {
}
};
my $api_requires_key =
(setting('trust_remote_user') or setting('trust_x_remote_user') or setting('no_auth'))
eq '1' ? false : true;
# setup for swagger API
my $swagger = Dancer::Plugin::Swagger->instance;
my $swagger_doc = $swagger->doc;
@@ -403,8 +399,8 @@ my $swagger_doc = $swagger->doc;
$swagger_doc->{consumes} = 'application/json';
$swagger_doc->{produces} = 'application/json';
$swagger_doc->{tags} = [
($api_requires_key ?
({name => 'General', description => 'Log in and Log out'}) : ()),
{name => 'General',
description => 'Log in and Log out'},
{name => 'Search',
description => 'Search Operations'},
{name => 'Objects',
@@ -415,15 +411,13 @@ $swagger_doc->{tags} = [
description => 'Operations on the Job Queue'},
];
if ($api_requires_key) {
$swagger_doc->{securityDefinitions} = {
APIKeyHeader =>
{ type => 'apiKey', name => 'Authorization', in => 'header' },
BasicAuth =>
{ type => 'basic' },
};
$swagger_doc->{security} = [ { APIKeyHeader => [] } ];
}
$swagger_doc->{securityDefinitions} = {
APIKeyHeader =>
{ type => 'apiKey', name => 'Authorization', in => 'header' },
BasicAuth =>
{ type => 'basic' },
};
$swagger_doc->{security} = [ { APIKeyHeader => [] } ];
if (setting('trust_x_remote_user')) {
foreach my $path (keys %{ $swagger_doc->{paths} }) {