From d3ebf42b32d60035974facd50c863049fee53cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 14 Apr 2022 18:39:30 +0200 Subject: [PATCH] Make disabled auth mode explicit in code (#1114) --- lib/livebook_web/plugs/auth_plug.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/livebook_web/plugs/auth_plug.ex b/lib/livebook_web/plugs/auth_plug.ex index 6536cf7ab..74e05f9cb 100644 --- a/lib/livebook_web/plugs/auth_plug.ex +++ b/lib/livebook_web/plugs/auth_plug.ex @@ -41,15 +41,15 @@ defmodule LivebookWeb.AuthPlug do @spec authenticated?(map(), non_neg_integer(), Livebook.Config.auth_mode()) :: boolean() def authenticated?(session, port, mode) + def authenticated?(_session, _port, :disabled) do + true + end + def authenticated?(session, port, mode) when mode in [:token, :password] do secret = session[key(port, mode)] is_binary(secret) and Plug.Crypto.secure_compare(secret, expected(mode)) end - def authenticated?(_session, _port, _mode) do - true - end - defp authenticate(conn, :password) do redirect_to_authenticate(conn) end