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

logout endpoint auth_plug_example App issue #15 #16

Merged
merged 8 commits into from
Nov 30, 2021

Conversation

nelsonic
Copy link
Member

@nelsonic nelsonic commented Nov 4, 2021

@nelsonic nelsonic self-assigned this Nov 4, 2021
@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #16 (c380bfe) into main (109462f) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main       #16   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           12        14    +2     
=========================================
+ Hits            12        14    +2     
Impacted Files Coverage Δ
lib/app_web/controllers/page_controller.ex 100.00% <100.00%> (ø)
lib/app_web/router.ex 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 109462f...c380bfe. Read the comment docs.

@nelsonic
Copy link
Member Author

nelsonic commented Nov 4, 2021

Ahh ...
image

Need tests ... 🙄
Added them to auth_plug dwyl/auth_plug#36
but need them here too ... ⏳

@nelsonic
Copy link
Member Author

nelsonic commented Nov 4, 2021

Good thing testing in Elixir/Phoenix is so easy. 😉
Less than a minute later, back up to 100% coverage. 💯

This was referenced Nov 4, 2021
@nelsonic nelsonic changed the title Implement logout endpoint issue #15 logout endpoint auth_plug_example App issue #15 Nov 5, 2021
@nelsonic
Copy link
Member Author

nelsonic commented Nov 6, 2021

The code I've added to this PR should be "enough" to logout in both the "consumer" (auth_plug_example) and the auth App. Once AuthPlug.logout/1 is finished, this PR should "just work". 💭

@nelsonic
Copy link
Member Author

@SimonLab hopefully this PR is clear.
The idea is that we can easily add the /logout endpoint to any App using auth_plug.
The handler will invoke the AuthPlug.logout/1 function implemented in dwyl/auth_plug#36
Which in turn will make an HTTP Request to auth_url/end_session see: dwyl/auth#159

Once the person has auth_plug working, the /logout functionality should be very simple to implement. 💭
Let me know if you agree. 🤞
Feedback/improvement very much welcome!


def logout(conn, _params) do
conn
|> AuthPlug.logout()
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the interesting part. 💡
With this single invocation of AuthPlug.logout/1 all "logout" action is handled transparently.

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering if the logout function could failed before rendering the loggedout.html page.
I've created an issue on auth_plug: dwyl/auth_plug#38

Copy link
Member Author

Choose a reason for hiding this comment

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

Excellent idea to check for errors. Thanks.

Copy link
Member

@SimonLab SimonLab left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@SimonLab SimonLab merged commit 6d04bf4 into main Nov 30, 2021
@SimonLab SimonLab deleted the implement-logout-endpoint-issue-#15 branch November 30, 2021 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants