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

issue 488 send to login screen on session expiration #518

Open
wants to merge 1 commit into
base: issue-365-logout-backend
Choose a base branch
from

Conversation

vkorir
Copy link
Contributor

@vkorir vkorir commented Mar 31, 2023

  • Set a timeout that will redirect the user to the login page once the access token expires

To test it, change this line to date.setTime(date.getTime() + 5 * 1000);

Closes #488

@vkorir vkorir force-pushed the issue-488-expiration_redirect branch from 0aa6a74 to 62803e6 Compare March 31, 2023 05:41
@vkorir vkorir marked this pull request as draft April 5, 2023 06:32
@vkorir vkorir marked this pull request as ready for review April 5, 2023 15:48
@JoelWiebe
Copy link
Contributor

JoelWiebe commented Apr 7, 2023

@vkorir Great work! I just tested this out. As our production server uses SCORE SSO, we should probably try getting the SCORE SSO cases working before merging these changes into develop. The current draft PR has the following effect:

  1. For standalone CK Board, everything looks good (redirected to the login page when session expires)
  2. With SCORE SSO, the user is not redirected to login again when the session expires but is still prompted to login when navigating between "pages" once the session is expired (i.e., from project dashboard to board dashboard), however:
    a. if the SCORE session is still active when the CK board session expires, then the CK Board will simply be routed to the project dashboard (the user does not need to login again)
    b. if the SCORE session has ended when the CK board session expires (e.g., user logged out of SCORE) then CK Board will be redirect to the SCORE SSO page

Suggestions:

  • Are you up for trying to get CK Board to route the user to the login page when the session expires while using SCORE SSO?
  • If SCORE is still active and the CK Board session has expired, is it possible for the user to not be redirected back to the project dashboard during renewal of the session but be redirected to stay at the current URL with existing parameters? This becomes important if we are embedding URLs to particular CK Board canvases in SCORE (Return user to same URL after refreshing session #527)

@vkorir
Copy link
Contributor Author

vkorir commented Apr 10, 2023

I was looking at SCORE authentication flow, and seems like we use HttpOnly cookies. This means it's inaccessible by JavaScript and there's not really a way to poll until when the session expires to redirect users. @geoffreykwan, can you confirm this?

@geoffreykwan
Copy link
Contributor

Yea we have HttpOnly cookies set to true for security purposes. Are you trying to handle the scenario where CK Board wants to check if the SCORE session is still alive?

I just re-read through the comments in this PR #412 and I think we were able to get the SCORE session token string sent to CK Board and saved for later use. This way when a user logs out of CK Board, CK Board can also send a logout request to SCORE to tell SCORE to log out. I think you should be able to use this same process to have CK Board make a request to SCORE to check if the SCORE session is still alive.

See the function here

export const logoutSCORE = async (req: Request) => {
const scoreAddress = process.env.SCORE_SERVER_ADDRESS || 'http://localhost';
return await axios.get(
`${scoreAddress + process.env.SCORE_LOGOUT_ENDPOINT}`,
{
headers: { Cookie: `SESSION=${req.cookies['SESSION']};` },
}
);
};

You can check if a user is still logged into SCORE by making a request to https://score.oise.utoronto.ca/api/user/info

If the SCORE user is logged in, you will get a response that looks like this
{"schoolLevel":"COLLEGE","lastName":"kwan","isPreviousAdmin":false,"country":"USA","role":"teacher","isGoogleUser":false,"city":"New York","displayName":"geoffrey kwan","language":"en","firstName":"geoffrey","id":1181,"state":"New York","schoolName":"University of California Berkeley","email":"","username":"geoffreykwan"}

If the SCORE user is logged out, you will get a response that looks like this
{"username":null}

@vkorir vkorir force-pushed the issue-488-expiration_redirect branch from 62803e6 to 81b992d Compare April 21, 2023 02:56
@vkorir vkorir force-pushed the issue-488-expiration_redirect branch from 81b992d to 0522bcb Compare April 21, 2023 03:01
@vkorir vkorir requested a review from JoelWiebe April 21, 2023 03:03
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.

3 participants