Make disabled auth mode explicit in code (#1114)

This commit is contained in:
José Valim 2022-04-14 18:39:30 +02:00 committed by GitHub
parent 5acbd2efad
commit d3ebf42b32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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