README.md in signed_form-0.0.1 vs README.md in signed_form-0.1.0

- old
+ new

@@ -28,11 +28,11 @@ <%= f.submit %> <% end %> ``` ``` ruby -UserController < ApplicationController +UsersController < ApplicationController def create @user = User.find params[:id] @user.update_attributes params[:user] end end @@ -42,40 +42,35 @@ `signed_form_for` works just like the standard `form_for`. Of course, you're free to continue using the standard `form_for`. `SignedForm` is strictly opt-in. It won't change the way you use standard forms. -## Alpha Quality Software - -This software should not be considered production ready. At this time it is only suitable for experimentation. - -Now that I've made that disclaimer, you should know that SignedForm is functional. - ## Requirements SignedForm requires: * Ruby 1.9 or later -* Ruby on Rails 4 or 3 ([strong_parameters](https://github.com/rails/strong_parameters) gem required for Rails 3) +* Ruby on Rails 4 or Rails 3 (3.0 not supported) ([strong_parameters](https://github.com/rails/strong_parameters) gem + required for Rails 3) ## Installation Add this line to your application's Gemfile: - gem 'signed_form', '~> 0.0.1' + gem 'signed_form' And then execute: $ bundle If you're using Rails 3, you'll also need to install the [strong_parameters](https://github.com/rails/strong_parameters) gem. Please set it up as instructed on the linked GitHub repo. If you're using Rails 4, it works out of the box. -You'll need to include `SignedForm::ActionController::PermitSignedParams` in the controller(s) you want to use SignedForm with. This can -be done application wide by adding the `include` to your ApplicationController. +You'll need to include `SignedForm::ActionController::PermitSignedParams` in the controller(s) you want to use +SignedForm with. This can be done application wide by adding the `include` to your ApplicationController. ``` ruby ApplicationController < ActionController::Base include SignedForm::ActionController::PermitSignedParams @@ -105,9 +100,29 @@ that secret key, a malicious user could still access the field with the old signature. So you'll probably want to choose a new secret in the event you remove access to an attribute in a form. My above initializer example errs on the side of caution, generating a new secret key every time the app starts up. Only you can decide what is right for you with respect to the secret key. + +### Multiple Access Points + +Take for example the case where you have an administrative backend. You might have `/admin/users/edit`. Users can also +change some information about themselves though, so there's `/users/edit` as well. Now you have an admin that gets +demoted, but still has a user account. If that admin were to retain a form signature from `/admin/users/edit` they could +use that signature to modify the same fields from `/users/edit`. As a means of preventing such access SignedForm provides +the `sign_destination` option to `signed_form_for`. Example: + +``` erb +<%= signed_form_for(@user, sign_destination: true) do |f| %> + <%= f.text_field :name %> + <!-- ... --> +<% end %> +``` + +With `sign_destination` enabled, a form generated with a destination of `/admin/users/5` for example will only be +accepted at that end point. The form would not be accepted at `/users/5`. So in the event you would like to use +SignedForm on forms for the same resource, but different access levels, you have protection against the form being used +elsewhere. ### Caching Another consideration to be aware of is caching. If you cache a form, and then change the secret key that form will perpetually submit parameters that fail verification. So if you want to cache the form you should tie the cache key to