Skip to content

Commit f6773b9

Browse files
committed
fix(backend): remove authentication bypass configuration
- Remove 'DISABLE_TENANT_AUTHENTICATION' and 'DISABLE_ADMIN_AUTHENTICATION' support - Hardens authentication by removing runtime checks that could bypass auth pipelines - Removes associated configuration definitions in Edgehog.Config Signed-off-by: Davide Briani <davide.briani@secomind.com>
1 parent 9541909 commit f6773b9

3 files changed

Lines changed: 6 additions & 41 deletions

File tree

backend/lib/edgehog/config.ex

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ defmodule Edgehog.Config do
3030
alias Edgehog.Geolocation
3131
alias Edgehog.Geolocation.Providers.GoogleGeocoding
3232

33-
@envdoc """
34-
Disables admin authentication. CHANGING IT TO TRUE IS GENERALLY A REALLY BAD IDEA IN A PRODUCTION ENVIRONMENT, IF YOU DON'T KNOW WHAT YOU ARE DOING.
35-
"""
36-
app_env :disable_admin_authentication, :edgehog, :disable_admin_authentication,
37-
os_env: "DISABLE_ADMIN_AUTHENTICATION",
38-
type: :boolean,
39-
default: false
40-
4133
@envdoc "The Admin API JWT public key."
4234
app_env :admin_jwk, :edgehog, :admin_jwk,
4335
os_env: "ADMIN_JWT_PUBLIC_KEY_PATH",
@@ -67,14 +59,6 @@ defmodule Edgehog.Config do
6759
type: :boolean,
6860
default: false
6961

70-
@envdoc """
71-
Disables tenant authentication. CHANGING IT TO TRUE IS GENERALLY A REALLY BAD IDEA IN A PRODUCTION ENVIRONMENT, IF YOU DON'T KNOW WHAT YOU ARE DOING.
72-
"""
73-
app_env :disable_tenant_authentication, :edgehog, :disable_tenant_authentication,
74-
os_env: "DISABLE_TENANT_AUTHENTICATION",
75-
type: :boolean,
76-
default: false
77-
7862
@envdoc "The API key for the ipbase.com geolocation provider."
7963
app_env :ipbase_api_key, :edgehog, :ipbase_api_key,
8064
os_env: "IPBASE_API_KEY",
@@ -112,11 +96,7 @@ defmodule Edgehog.Config do
11296
type: GeocodingProviders,
11397
default: [GoogleGeocoding]
11498

115-
@doc """
116-
Returns true if admin authentication is disabled.
117-
"""
118-
@spec admin_authentication_disabled?() :: boolean()
119-
def admin_authentication_disabled?, do: disable_admin_authentication!()
99+
120100

121101
@doc """
122102
Returns true if edgehog should use an ssl connection with the database.
@@ -179,11 +159,7 @@ defmodule Edgehog.Config do
179159
else: false
180160
end
181161

182-
@doc """
183-
Returns true if tenant authentication is disabled.
184-
"""
185-
@spec tenant_authentication_disabled?() :: boolean()
186-
def tenant_authentication_disabled?, do: disable_tenant_authentication!()
162+
187163

188164
@doc """
189165
Returns the list of geolocation modules to use.
@@ -215,11 +191,7 @@ defmodule Edgehog.Config do
215191
"""
216192
@spec validate_admin_authentication!() :: :ok | no_return()
217193
def validate_admin_authentication! do
218-
if admin_authentication_disabled?() do
219-
:ok
220-
else
221-
admin_jwk!()
222-
:ok
223-
end
194+
admin_jwk!()
195+
:ok
224196
end
225197
end

backend/lib/edgehog_web/admin_api/auth/auth.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ defmodule EdgehogWeb.AdminAPI.Auth do
2828
end
2929

3030
def call(conn, opts) do
31-
if Config.admin_authentication_disabled?() ||
32-
conn.path_info == ["admin-api", "v1", "open_api"] do
31+
if conn.path_info == ["admin-api", "v1", "open_api"] do
3332
conn
3433
else
3534
Pipeline.call(conn, opts)

backend/lib/edgehog_web/auth.ex

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ defmodule EdgehogWeb.Auth do
2828
end
2929

3030
def call(conn, opts) do
31-
if Config.tenant_authentication_disabled?() do
32-
# TODO: when we add Authz this path will probably have to
33-
# put some type of all-access Authz in the GraphQL context
34-
conn
35-
else
36-
Pipeline.call(conn, opts)
37-
end
31+
Pipeline.call(conn, opts)
3832
end
3933
end

0 commit comments

Comments
 (0)