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

add logout endpoint to server #4058

Merged
merged 2 commits into from Nov 25, 2020
Merged

Conversation

sjpadgett
Copy link
Sponsor Member

Provides a logout endpoint that will destroy the trusted users logged in session.

@sjpadgett
Copy link
Sponsor Member Author

not sure why travis is not running.

@bradymiller
Copy link
Sponsor Member

dang, looks like travis is joining the "open source pay up" choir along with dockerhub:
image

@bradymiller
Copy link
Sponsor Member

useful article regarding travis new billing model here:
https://www.jeffgeerling.com/blog/2020/travis-cis-new-pricing-plan-threw-wrench-my-open-source-works

@bradymiller
Copy link
Sponsor Member

neat stuff and couldn't find any escaping/translation issues :)

@sjpadgett
Copy link
Sponsor Member Author

thanks Brady,
I'm trying to see if I can't slip in fixing recall board thinking should be easy fix but nooo, a really strange issue.

@sjpadgett
Copy link
Sponsor Member Author

@bradymiller
I'm going to bring this in and do a separate PR for recall board. I fixed the one table for issue ken brought up but there are several others not formatted/converted from div tables so it's(recall board) going to need scrutiny on its own.

@sjpadgett sjpadgett merged commit 94762eb into openemr:master Nov 25, 2020
@sjpadgett sjpadgett deleted the logout-endpoint branch November 25, 2020 06:27
@@ -126,6 +126,19 @@
} elseif ($skipApiAuth) {
// For endpoints that do not require auth, such as the capability statement
} else {
// verify that user tokens haven't been revoked.
// this is done by verifying the user is trusted with active auth session.
$isTrusted = $gbl::isTrustedUser($attributes["oauth_client_id"], $attributes["oauth_user_id"]);
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@sjpadgett , Haven't been able to test this, but was just looking through this code and was unable to find the isTrustedUser() function in RestConfig. Am I missing something?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

nice catch sir. I forgot to include file in PR.
I do this alot of late.....

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@sjpadgett ,
tested it with most recent code (including your isTrustedUser function), and this breaks the password grant mechanism since that does not create an entry in oauth_trusted_user (it's too bad travis is dead or it would of actually picked it up on the automated api tests). To support both grant mechanisms, I think we just need to add an active column in oauth_trusted_user and then when logout, it makes it inactive (and when log back in (ie. re-authorize) would make it active). Then here could check for that active status only if there is an entry in oauth_trusted_user.
thoughts?

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

btw, I have a bit of extra time that I can work on this today if that would help; i'd also incorporate the global that allows/disallows password grants into this solution (it would give me a bit of a break from some tedious security related stuff i am working on :) ).

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

I thought I was creating a trusted user for password. guess not but I wanted to and got lost somewhere.
I also realized i'm using the nonce to verify trusted delete where nonce is optional. Still should work as empty=empty but really need a verification back to the token creation. Therefore i'll have to verify token signature against public key.
The logout is meant to wipe out the session. Same for client and any cookies it generates or session it maintains. Whether the trusted user is there or a flag is set really makes no difference. The issue boils down to the grant type and whether to test or not in dispatcher.

The persist flag I already have is for cases when the refresh token expires or client is not using a refresh then if persist is set, a new signin is not required. Thus the reason for the client to have the ability to log the user out.

I prefer to stay away from flags and keep custom conditionals in dispatch to a minimum. Too me it makes better sense to create a trusted user for any grant type and keep track of its session as well as its grant type. In this way we(site administrators) have the ability to revoke a user to force a new set of tokens.

We need to be thinking ahead for the server admin side of the project to give the practice a way to manage apps and access.

I have to rework the token validation for log out so I can fix this too. For some reason the password grant is an afterthought for me. I think setting it up with a trusted user helps secure it in the end. If anything gives us some control of what the grant is up to.

Sound reasonable to you?

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@sjpadgett , Sounds like a much better plan than mine :)

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.

None yet

2 participants