Skip to content

Commit

Permalink
Try to fix Livebook auth
Browse files Browse the repository at this point in the history
  • Loading branch information
mbklein committed Jul 23, 2024
1 parent 340134a commit f5e0678
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions livebook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ghcr.io/livebook-dev/livebook
FROM ghcr.io/livebook-dev/livebook:latest
ENV LIVEBOOK_AWS_CREDENTIALS=true
ENV LIVEBOOK_IDENTITY_PROVIDER=custom:MeadowLivebookAuth
ENV LIVEBOOK_DISTRIBUTION=sname
ENV LIVEBOOK_DISTRIBUTION=name
ENV LIVEBOOK_IP=0.0.0.0
ENV LIVEBOOK_DATA_PATH=/data
ENV LIVEBOOK_HOME=${LIVEBOOK_DATA_PATH}/books
Expand Down
19 changes: 16 additions & 3 deletions livebook/meadow_livebook_auth.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,22 @@ defmodule MeadowLivebookAuth do
@spec authenticate(GenServer.server(), Plug.Conn.t(), keyword()) ::
{Plug.Conn.t(), map() | nil}
def authenticate(server, conn, _) do
with url <- get_meadow_url() do
set_state(server, :auth_url, url)
{conn, meadow_auth(url, conn)}
with url <- find_meadow_url(server),
user <- meadow_auth(url, conn) do
{conn, user}
end
end

defp find_meadow_url(server) do
case get_state(server) do
%{auth_url: auth_url} ->
auth_url

_ ->
with url <- get_meadow_url() do
set_state(server, :auth_url, url)
url
end
end
end

Expand Down

0 comments on commit f5e0678

Please sign in to comment.