Skip to content

Instantly share code, notes, and snippets.

@katiekeel
Last active July 19, 2017 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katiekeel/416349c9424cbf6f71deeb34dc22af0f to your computer and use it in GitHub Desktop.
Save katiekeel/416349c9424cbf6f71deeb34dc22af0f to your computer and use it in GitHub Desktop.
Answering authorization questions from lecture
* What’s the difference between Authentication and Authorization?
Authentication is how the server confirms you are who you say you are; authorization is making sure you only see what you have permission to see
* Why are both necessary for securing our applications?
You wouldn't want users to be able to edit other users' accounts (authorization), and you can't have authorization without authentication
* What’s a before_action filter in Rails?
It asks the controller to meet some condition or find some information before certain routes are taken
* How can we scope a filter down to only work with specific actions?
You can specify which actions you want with only or except, just like in your routes file
* What’s an enum attribute in ActiveRecord? Why would we ever want to use this?
They're attributes that map to integers but can be called by name. Usually there's a set of two, and one corresponds to 0 while the other corresponds to 1. Logically they are opposites of one another and when you call one attribute with an exclamation, it switches that attribute "on." Then, when you call it with a question mark, it should return true. Finally, you can switch it off by calling the opposite attribute with an exclamation point.
* When thinking about Authorization, why might we want to namespace a resource?
Prevents non-admins from accessing admin pages, for example
* What does allow_any_instance_of in RSpec do?
Allows us to DRY up tests by, for example, asking ApplicationController to be set to admin path by default for the duration of the test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment