From f4c662940e8b3b7f69afe7ee3599558d6cd522c0 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 25 Jan 2021 12:28:27 +0100 Subject: [PATCH] Authentication: remove unused argument --- routes/component-configuration/config_test.go | 2 +- routes/dashboard/dashboard_test.go | 2 +- routes/file/file_test.go | 2 +- routes/infrastructure-component/ic_test.go | 2 +- routes/register.go | 2 +- routes/result/result_test.go | 2 +- routes/scenario/scenario_test.go | 2 +- routes/signal/signal_test.go | 2 +- routes/user/user_middleware.go | 6 ++---- routes/user/user_test.go | 2 +- routes/widget/widget_test.go | 2 +- 11 files changed, 12 insertions(+), 14 deletions(-) diff --git a/routes/component-configuration/config_test.go b/routes/component-configuration/config_test.go index 794cca7..2ce0de8 100644 --- a/routes/component-configuration/config_test.go +++ b/routes/component-configuration/config_test.go @@ -158,7 +158,7 @@ func TestMain(m *testing.M) { api := router.Group("/api") user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) + api.Use(user.Authentication()) RegisterComponentConfigurationEndpoints(api.Group("/configs")) // scenario endpoints required here to first add a scenario to the DB // that can be associated with a new component configuration diff --git a/routes/dashboard/dashboard_test.go b/routes/dashboard/dashboard_test.go index cb530a6..1ac8a5d 100644 --- a/routes/dashboard/dashboard_test.go +++ b/routes/dashboard/dashboard_test.go @@ -97,7 +97,7 @@ func TestMain(m *testing.M) { api := router.Group("/api") user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) + api.Use(user.Authentication()) RegisterDashboardEndpoints(api.Group("/dashboards")) // scenario endpoints required here to first add a scenario to the DB // that can be associated with a new dashboard diff --git a/routes/file/file_test.go b/routes/file/file_test.go index 2fe3b62..d6b78b0 100644 --- a/routes/file/file_test.go +++ b/routes/file/file_test.go @@ -95,7 +95,7 @@ func TestMain(m *testing.M) { api := router.Group("/api") user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) + api.Use(user.Authentication()) // scenario endpoints required here to first add a scenario to the DB scenario.RegisterScenarioEndpoints(api.Group("/scenarios")) diff --git a/routes/infrastructure-component/ic_test.go b/routes/infrastructure-component/ic_test.go index 34af078..85ee7b2 100644 --- a/routes/infrastructure-component/ic_test.go +++ b/routes/infrastructure-component/ic_test.go @@ -134,7 +134,7 @@ func TestMain(m *testing.M) { api = router.Group("/api") user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) + api.Use(user.Authentication()) RegisterICEndpoints(api.Group("/ic")) // component configuration endpoints required to associate an IC with a component config component_configuration.RegisterComponentConfigurationEndpoints(api.Group("/configs")) diff --git a/routes/register.go b/routes/register.go index 7884397..4499691 100644 --- a/routes/register.go +++ b/routes/register.go @@ -84,7 +84,7 @@ func RegisterEndpoints(router *gin.Engine, api *gin.RouterGroup) { // login (POST /authenticate) user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) + api.Use(user.Authentication()) scenario.RegisterScenarioEndpoints(api.Group("/scenarios")) component_configuration.RegisterComponentConfigurationEndpoints(api.Group("/configs")) diff --git a/routes/result/result_test.go b/routes/result/result_test.go index da70924..e9902e7 100644 --- a/routes/result/result_test.go +++ b/routes/result/result_test.go @@ -113,7 +113,7 @@ func TestMain(m *testing.M) { api := router.Group("/api") user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) + api.Use(user.Authentication()) // scenario endpoints required here to first add a scenario to the DB scenario.RegisterScenarioEndpoints(api.Group("/scenarios")) // file endpoints required to download result file diff --git a/routes/scenario/scenario_test.go b/routes/scenario/scenario_test.go index 15304a9..99e6b32 100644 --- a/routes/scenario/scenario_test.go +++ b/routes/scenario/scenario_test.go @@ -80,7 +80,7 @@ func TestMain(m *testing.M) { api := router.Group("/api") user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) + api.Use(user.Authentication()) // user endpoints required to set user to inactive user.RegisterUserEndpoints(api.Group("/users")) diff --git a/routes/signal/signal_test.go b/routes/signal/signal_test.go index 7f89a6c..fec1d6c 100644 --- a/routes/signal/signal_test.go +++ b/routes/signal/signal_test.go @@ -165,7 +165,7 @@ func TestMain(m *testing.M) { api := router.Group("/api") user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) + api.Use(user.Authentication()) // component-configuration endpoints required here to first add a component config to the DB // that can be associated with a new signal component_configuration.RegisterComponentConfigurationEndpoints(api.Group("/configs")) diff --git a/routes/user/user_middleware.go b/routes/user/user_middleware.go index cc83006..18aec20 100644 --- a/routes/user/user_middleware.go +++ b/routes/user/user_middleware.go @@ -46,7 +46,7 @@ func userToContext(ctx *gin.Context, user_id uint) { ctx.Set(database.UserIDCtx, user_id) } -func Authentication(unauthorized bool) gin.HandlerFunc { +func Authentication() gin.HandlerFunc { return func(ctx *gin.Context) { @@ -74,9 +74,7 @@ func Authentication(unauthorized bool) gin.HandlerFunc { // If the authentication extraction fails return HTTP CODE 401 if err != nil { - if unauthorized { - helper.UnauthorizedAbort(ctx, "Authentication failed (claims extraction)") - } + helper.UnauthorizedAbort(ctx, "Authentication failed (claims extraction)") return } diff --git a/routes/user/user_test.go b/routes/user/user_test.go index b90b0ce..2b1563a 100644 --- a/routes/user/user_test.go +++ b/routes/user/user_test.go @@ -66,7 +66,7 @@ func TestMain(m *testing.M) { api := router.Group("/api") RegisterAuthenticate(api.Group("/authenticate")) - api.Use(Authentication(true)) + api.Use(Authentication()) RegisterUserEndpoints(api.Group("/users")) os.Exit(m.Run()) diff --git a/routes/widget/widget_test.go b/routes/widget/widget_test.go index e0cb164..aad29c0 100644 --- a/routes/widget/widget_test.go +++ b/routes/widget/widget_test.go @@ -132,7 +132,7 @@ func TestMain(m *testing.M) { api := router.Group("/api") user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) + api.Use(user.Authentication()) RegisterWidgetEndpoints(api.Group("/widgets")) // scenario endpoints required here to first add a scenario to the DB // that can be associated with a new dashboard