Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: show logout template after logging out #2913

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hugobarauna
Copy link
Member

When the user is logged in using an identity provider that supports logout (like OIDC), after clicking logout

CleanShot 2025-01-17 at 16 34 38

We want them to see the logout page:

CleanShot 2025-01-17 at 16 31 53

Before this PR, they were being redirected to the "auth via Teams" page:

CleanShot 2025-01-17 at 16 33 52

@hugobarauna hugobarauna requested a review from aleDsz January 17, 2025 19:37
lib/livebook/config.ex Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 17, 2025

Uffizzi Ephemeral Environment deployment-60021

☁️ https://app.uffizzi.com/github.com/livebook-dev/livebook/pull/2913

📄 View Application Logs etc.

What is Uffizzi? Learn more!

AuthHelpers.redirect_to(conn)
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of moving this to another controller? We now need to create a separate module to share functionality, causing more indirection. I'd prefer to keep them together without a AuthHelpers. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that in the first place. But they have different requirements.

AuthController's actions requires require_unauthenticated:

defp require_unauthenticated(conn, _opts) do
if AuthPlug.authenticated?(conn) do
AuthHelpers.redirect_to(conn)
else
conn
end
end

UserAuthContoller.logout does not.

After trying to battle that, I ended up with that solution: two different controllers.

I actually liked it because I have different concerns. AuthContoller is about "admin authentication". UserAuthController is about "instance/user-identity" based authentication.

We have a similar approach with two related plugs. We have AuthPlug that's more related to "admin authentication" and there's UserPlug that's more related to "instance/user-identity" based authentication.

Copy link
Contributor

@josevalim josevalim Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do action based plugs in Phoenix controllers, I believe it would be:

 plug :require_unauthenticated when action_name != :logout

Or something like that. :)

But I see your points about keeping them separate because they deal with different concerns, and I agree. Here are my suggestions:

  1. Rename it to UserController and UserHTML, in order to mirror the plugs (AuthPlug vs UserPlug)

  2. Don't use the redirect_to helper in logout, leave it only on AuthController. It is used for login because you want to redirect back to the page you were trying to enter, but that doesn't make sense for logout. The page you were at cannot be accessible anymore

I think the suggestions above keep your proposals for code organization and remove my concerns, wdyt?

Copy link
Member Author

@hugobarauna hugobarauna Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Done in e3ed654. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants