Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the dependency for protected_attributes #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ if RUBY_VERSION >= '1.9'
appraise 'activerecord_4_0' do
gem 'activerecord', '~> 4.0.0'
gem 'mysql', '~> 2.9.0' if ENV['DB'] == 'mysql'
gem 'protected_attributes', '~> 1.0.0'
end

appraise 'activerecord_4_1' do
gem 'activerecord', '~> 4.1.0'
gem 'mysql', '~> 2.9.0' if ENV['DB'] == 'mysql'
gem 'protected_attributes', '~> 1.0.0'
end
end
8 changes: 7 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ you should show its details to the user registering the client: its
<tt>client_secret</tt> is not stored in plain text so you can only read it when
you initially create the client object.

==== Note on protecting Client attributes

It is important to make sure to protect the <tt>Client</tt> model attributes from mass-assigning. Either using
<tt>protected attributes</tt> (Rails < 4) or <tt>strong parameters</tt> (Rails >= 4).

Do not allow the attributes <tt>client_id</tt> and <tt>client_secret</tt> to be mass-assigned. Usually, you'll only allow
the attributes <tt>name</tt> and <tt>redirect_uri</tt> to be mass-assigned.

=== OAuth request endpoint

Expand Down Expand Up @@ -401,4 +408,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

3 changes: 1 addition & 2 deletions gemfiles/activerecord_4_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ source "https://rubygems.org"

gem "activerecord", "~> 4.0.0"
gem "mysql", "~> 2.9.0"
gem "protected_attributes", "~> 1.0.0"

gemspec :path=>"../"
gemspec :path=>"../"
3 changes: 1 addition & 2 deletions gemfiles/activerecord_4_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ source "https://rubygems.org"

gem "activerecord", "~> 4.1.0"
gem "mysql", "~> 2.9.0"
gem "protected_attributes", "~> 1.0.0"

gemspec :path=>"../"
gemspec :path=>"../"
3 changes: 0 additions & 3 deletions lib/songkick/oauth2/model/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Authorization < ActiveRecord::Base
validates_uniqueness_of :refresh_token_hash, :scope => :client_id, :allow_nil => true
validates_uniqueness_of :access_token_hash, :allow_nil => true

attr_accessible nil

class << self
private :create, :new
end
Expand Down Expand Up @@ -134,4 +132,3 @@ def scopes
end
end
end

3 changes: 0 additions & 3 deletions lib/songkick/oauth2/model/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class Client < ActiveRecord::Base
validates_presence_of :name, :redirect_uri
validate :check_format_of_redirect_uri

attr_accessible :name, :redirect_uri

before_create :generate_credentials

def self.create_client_id
Expand Down Expand Up @@ -56,4 +54,3 @@ def generate_credentials
end
end
end

11 changes: 0 additions & 11 deletions spec/songkick/oauth2/model/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@
@client.should_not be_valid
end

it "cannot mass-assign client_id" do
@client.update_attributes(:client_id => 'foo')
@client.client_id.should_not == 'foo'
end

it "cannot mass-assign client_secret" do
@client.update_attributes(:client_secret => 'foo')
@client.client_secret.should_not == 'foo'
end

it "has client_id and client_secret filled in" do
@client.client_id.should_not be_nil
@client.client_secret.should_not be_nil
Expand All @@ -52,4 +42,3 @@
Songkick::OAuth2::Model::Authorization.count.should be_zero
end
end

2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'bundler/setup'

require 'active_record'
require 'protected_attributes' if defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::MAJOR > 3

require 'songkick/oauth2/provider'

Expand Down Expand Up @@ -79,4 +78,3 @@ def create_authorization(params)
end
end
end