-
-
Notifications
You must be signed in to change notification settings - Fork 382
Description
When an anonymous user visits an instance, they are redirected to the last visited page.
- If that is a publicly shared page, they are stuck there.
It is still possible to manually call the/loginroute for creating a valid session through logging in. - If it is a private page, they are redirected and asked to
/login.
It would be expected that knowledge of the last_visit state is restricted to logged in users only, and not leaked to the public.
This runtime value is mutated when a logged in user does call loadNoteById:
| const loadNoteById = useCallback( |
And is set to the id for all cases, in which no new ID is opened:
notea/components/container/edit-container.tsx
Lines 71 to 75 in d5f8113
| if (!isNew && id !== 'new') { | |
| await mutateSettings({ | |
| last_visit: `/${id}`, | |
| }); | |
| } |
This also allows to set a temporary home page of a Notea instance, by carefully choosing the page last navigated to in a Notea tab before closing it.
Further down the road, somehow a similar "feature", combining a targeted redirect and a publicly shared page, could allow for a nice and simple "home page" of an instance. This would seemingly require an additional (runtime) setting, such as last_visit, but set and named differently.
Remediation would probably center around these pieces of the code base, where the lastVisit is patched into the request, if a user isLoggedIn:
Lines 57 to 66 in d5f8113
| const lastVisit = ctx.req.props?.settings?.last_visit; | |
| if (lastVisit && ctx.req.session.get('user')?.isLoggedIn) { | |
| return { | |
| redirect: { | |
| destination: lastVisit, | |
| permanent: false, | |
| }, | |
| }; | |
| } |
This is always true, if the auth.type equals to none.
notea/libs/server/middlewares/auth.ts
Lines 23 to 25 in d5f8113
| if (cfg.auth.type === 'none') { | |
| return true; | |
| } |
Which always seems to be the case:
Line 143 in d5f8113
| let auth: AuthConfiguration = { type: 'none' }; |