From 17f1da8d0a0098920ff21a06e3eb04ff138ed186 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 20 Mar 2019 17:14:15 +0000 Subject: [PATCH] add logout operation --- lib/App/Netdisco/Web/AuthN.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Web/AuthN.pm b/lib/App/Netdisco/Web/AuthN.pm index 715d8282..eee631ff 100644 --- a/lib/App/Netdisco/Web/AuthN.pm +++ b/lib/App/Netdisco/Web/AuthN.pm @@ -167,11 +167,12 @@ Dancer::Plugin::Swagger->instance->doc->{paths}->{'/api/login'} # we override the default login_handler, so logout has to be handled as well swagger_path { description => 'Destroy user API Key and session cookie', + path => '/api/logout', tags => ['General'], parameters => [], responses => { default => { examples => { 'application/json' => {} } } }, }, -get '/logout' => sub { +get qr{^/(?:api/)?logout$} => sub { my $mode = (request_is_api() ? 'API' : 'WebUI'); # clear out API token @@ -197,4 +198,9 @@ get '/logout' => sub { redirect uri_for('/inventory')->path; }; +# ugh, *puke*, but D::P::Swagger has no way to set this with swagger_path +# must be after the path is declared, above. +Dancer::Plugin::Swagger->instance->doc->{paths}->{'/api/logout'} + ->{get}->{security} = [ {}, {APIKeyHeader => []} ]; + true;