Skip to content

Add permissions check to block diagram API#61

Merged
hbradio merged 4 commits intorovercode:developmentfrom
cabarnes:bd-api-permissions
May 1, 2017
Merged

Add permissions check to block diagram API#61
hbradio merged 4 commits intorovercode:developmentfrom
cabarnes:bd-api-permissions

Conversation

@cabarnes
Copy link
Copy Markdown
Member

  • Requires the user to be logged in to access the block diagram API.
  • User can only access the user's block diagrams.
  • Any superuser accounts can access all block diagrams through the API.
  • Sets user to the logged in user that created the block diagram.

@cabarnes cabarnes requested a review from hbradio April 30, 2017 18:11
@cabarnes cabarnes added this to the Release 0.4 milestone Apr 30, 2017
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 730c8ba on cabarnes:bd-api-permissions into 897f2db on aninternetof:development.

@cabarnes cabarnes self-assigned this Apr 30, 2017
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 730c8ba on cabarnes:bd-api-permissions into 897f2db on aninternetof:development.

@hbradio
Copy link
Copy Markdown
Collaborator

hbradio commented Apr 30, 2017

What do you think of these tweaks?

  • Requires the user to be logged in to access the block diagram API.
  • Any user can read all users' block diagrams
  • User can write only his own block diagrams.
  • Any superuser accounts can read and write all block diagrams through the API.
  • Sets user to the logged in user that created the block diagram.

Being able to read all other users' block diagrams will make it easier for us in the future to make the "clone" function, where a user makes his own copy of somebody else's block diagram.

Thoughts?

Copy link
Copy Markdown
Collaborator

@hbradio hbradio left a comment

Choose a reason for hiding this comment

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

See previous question.

@cabarnes
Copy link
Copy Markdown
Member Author

@aninternetof So, would all block diagrams be publicly viewable or would the user have control over which are shared?

@hbradio
Copy link
Copy Markdown
Collaborator

hbradio commented Apr 30, 2017

I vote for all block diagrams being publicly viewable. I believe that's what Scratch does -- encourage (force) sharing.

@cabarnes
Copy link
Copy Markdown
Member Author

Then they can buy premium to have private block diagrams ;)

All users see all block diagrams. A user can only change the user's
block diagrams.
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 57e0b6c on cabarnes:bd-api-permissions into 897f2db on aninternetof:development.

user = self.request.user
serializer.save(user=user)

def perform_update(self, serializer):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this let a superuser update anyone's block diagram?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, it won't. I wasn't sure if there would really be a use for it. I could change the if statement to also check for superuser if so.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sounds good -- let's leave it out.

@hbradio hbradio merged commit dc42df2 into rovercode:development May 1, 2017
@cabarnes cabarnes deleted the bd-api-permissions branch May 1, 2017 00:16
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