Skip to content

Conversation

@scefali
Copy link
Contributor

@scefali scefali commented Mar 8, 2021

This PR adds functionality to log a user into the demo automatically if they land on an organization page in the demo. The purpose of this is to allow users to share links with other people when trying out the demo. While this would be a security vulnerability in SaaS, this should be totally fine in the demo instance for a few reasons. First, one would have to guess an org slug to get access which wouldn't be easy because we auto-generate them using petname. Secondly, we only give member access meaning that a user who guesses a slug would have limited abilities to take destructive action on someone else's demo.

@scefali scefali requested a review from markstory March 8, 2021 23:29
Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

Would be good to have some tests around member selection and fail safes.

# on organization pages
def process_view(self, request, view_func, view_args, view_kwargs):
if not settings.DEMO_MODE:
return
Copy link
Member

Choose a reason for hiding this comment

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

I would raise an exception here so that the application fails to start as an additional precaution.

return

# if authed, no action required
if request.user.is_authenticated() and request.user.is_active:
Copy link
Member

Choose a reason for hiding this comment

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

If the user is logged in but not part of the demo org would they hit errors viewing the demo org data? You might want to coerce their session into the demo org they are looking at.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@markstory good point. It's sort of an edge case but it's possible someone could be logged in for on demo but receive a link for another org's demo. In that case, we should switch the user.

@scefali scefali merged commit 072bb3d into master Mar 15, 2021
@scefali scefali deleted the feat/demo-middleware branch March 15, 2021 16:10
@scefali scefali mentioned this pull request Mar 15, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants