Skip to content

Commit

Permalink
1.1.0 changes: support newer Devise, drop support for older Devise, f…
Browse files Browse the repository at this point in the history
…ix routes (closes #11)
  • Loading branch information
nbudin committed Dec 8, 2011
1 parent 1080b21 commit f79af8c
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 141 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rdoc
@@ -1,3 +1,11 @@
== 1.1.0
* Drop support for Rails 2
* Fix routing issues on Devise > 1.3.5 (fixes #11)
* Convert to Bundler-style gem

== 1.0.0
* No changes

== 1.0.0.beta2
* Fix a typo that was breaking all apps using create_from_identity_url.

Expand Down
19 changes: 3 additions & 16 deletions Gemfile
@@ -1,21 +1,8 @@
source "http://rubygems.org"
source 'https://rubygems.org'

gem "rack-openid", ">= 1.2.0"
gem "devise", ">= 1.0.6"
# Specify your gem's dependencies in devise_openid_authenticatable.gemspec
gemspec

group :test do
gem 'rails', '3.0.0'
gem "rspec", "~> 2.3"
gem "rspec-rails", "~> 2.3"
gem "mocha"
gem "sqlite3-ruby"
gem "rots", :git => "http://github.com/roman/rots.git"
gem "sham_rack"
gem "webrat"

if RUBY_VERSION.start_with? '1.9'
gem "ruby-debug19"
else
gem "ruby-debug"
end
end
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
Copyright (c) 2011 Nat Budin

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE 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.
21 changes: 3 additions & 18 deletions Rakefile
@@ -1,5 +1,5 @@
require 'rake'
require 'rake/rdoctask'
require 'bundler/gem_tasks'
require 'rdoc/task'
require 'rspec/mocks/version'
require 'rspec/core/rake_task'

Expand All @@ -15,19 +15,4 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end

begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.name = "devise_openid_authenticatable"
gemspec.summary = "OpenID authentication module for Devise"
gemspec.description = "OpenID authentication module for Devise using Rack::OpenID"
gemspec.email = "natbudin@gmail.com"
gemspec.homepage = "http://github.com/nbudin/devise_openid_authenticatable"
gemspec.authors = ["Nat Budin"]
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end
end
118 changes: 23 additions & 95 deletions devise_openid_authenticatable.gemspec
@@ -1,100 +1,28 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/devise_openid_authenticatable/version', __FILE__)

Gem::Specification.new do |s|
s.name = %q{devise_openid_authenticatable}
s.version = "1.0.0"
Gem::Specification.new do |gem|
gem.authors = ["Nat Budin"]
gem.email = ["natbudin@gmail.com"]
gem.description = %q{OpenID authentication module for Devise using Rack::OpenID}
gem.summary = %q{OpenID authentication for Devise}
gem.homepage = "https://github.com/nbudin/devise_openid_authenticatable"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nat Budin"]
s.date = %q{2011-05-31}
s.description = %q{OpenID authentication module for Devise using Rack::OpenID}
s.email = %q{natbudin@gmail.com}
s.extra_rdoc_files = [
"README.md"
]
s.files = [
"CHANGELOG.rdoc",
"Gemfile",
"README.md",
"Rakefile",
"VERSION",
"devise_openid_authenticatable.gemspec",
"lib/devise_openid_authenticatable.rb",
"lib/devise_openid_authenticatable/model.rb",
"lib/devise_openid_authenticatable/routes.rb",
"lib/devise_openid_authenticatable/schema.rb",
"lib/devise_openid_authenticatable/strategy.rb",
"rails/init.rb",
"spec/model_spec.rb",
"spec/scenario/app/controllers/application_controller.rb",
"spec/scenario/app/controllers/home_controller.rb",
"spec/scenario/app/controllers/sessions_controller.rb",
"spec/scenario/app/models/database_user.rb",
"spec/scenario/app/models/legacy_user.rb",
"spec/scenario/app/models/user.rb",
"spec/scenario/app/views/layouts/application.html.erb",
"spec/scenario/app/views/sessions/new.html.erb",
"spec/scenario/config.ru",
"spec/scenario/config/application.rb",
"spec/scenario/config/boot.rb",
"spec/scenario/config/database.yml",
"spec/scenario/config/environment.rb",
"spec/scenario/config/environments/development.rb",
"spec/scenario/config/environments/test.rb",
"spec/scenario/config/initializers/backtrace_silencers.rb",
"spec/scenario/config/initializers/inflections.rb",
"spec/scenario/config/initializers/secret_token.rb",
"spec/scenario/config/routes.rb",
"spec/scenario/db/migrate/20100401102949_create_tables.rb",
"spec/scenario/db/schema.rb",
"spec/spec_helper.rb",
"spec/strategy_spec.rb",
"spec/support/migrations.rb"
]
s.homepage = %q{http://github.com/nbudin/devise_openid_authenticatable}
s.require_paths = ["lib"]
s.rubygems_version = %q{1.5.0}
s.summary = %q{OpenID authentication module for Devise}
s.test_files = [
"spec/model_spec.rb",
"spec/scenario/app/controllers/application_controller.rb",
"spec/scenario/app/controllers/home_controller.rb",
"spec/scenario/app/controllers/sessions_controller.rb",
"spec/scenario/app/models/database_user.rb",
"spec/scenario/app/models/legacy_user.rb",
"spec/scenario/app/models/user.rb",
"spec/scenario/config/application.rb",
"spec/scenario/config/boot.rb",
"spec/scenario/config/environment.rb",
"spec/scenario/config/environments/development.rb",
"spec/scenario/config/environments/test.rb",
"spec/scenario/config/initializers/backtrace_silencers.rb",
"spec/scenario/config/initializers/inflections.rb",
"spec/scenario/config/initializers/secret_token.rb",
"spec/scenario/config/routes.rb",
"spec/scenario/db/migrate/20100401102949_create_tables.rb",
"spec/scenario/db/schema.rb",
"spec/spec_helper.rb",
"spec/strategy_spec.rb",
"spec/support/migrations.rb"
]
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = "devise_openid_authenticatable"
gem.require_paths = ["lib"]
gem.version = DeviseOpenidAuthenticatable::VERSION

gem.add_dependency "rack-openid", ">= 1.2.0"
gem.add_dependency "devise", "~> 1.3"

if s.respond_to? :specification_version then
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rack-openid>, [">= 1.2.0"])
s.add_runtime_dependency(%q<devise>, [">= 1.0.6"])
else
s.add_dependency(%q<rack-openid>, [">= 1.2.0"])
s.add_dependency(%q<devise>, [">= 1.0.6"])
end
else
s.add_dependency(%q<rack-openid>, [">= 1.2.0"])
s.add_dependency(%q<devise>, [">= 1.0.6"])
end
gem.add_development_dependency 'rails', '~> 3.0.0'
gem.add_development_dependency "rspec", "~> 2.3"
gem.add_development_dependency "rspec-rails", "~> 2.3"
gem.add_development_dependency "mocha"
gem.add_development_dependency "sqlite3-ruby"
gem.add_development_dependency "sham_rack"
gem.add_development_dependency "webrat"
end

100 changes: 100 additions & 0 deletions devise_openid_authenticatable.gemspec.bak
@@ -0,0 +1,100 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{devise_openid_authenticatable}
s.version = "1.0.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nat Budin"]
s.date = %q{2011-05-31}
s.description = %q{OpenID authentication module for Devise using Rack::OpenID}
s.email = %q{natbudin@gmail.com}
s.extra_rdoc_files = [
"README.md"
]
s.files = [
"CHANGELOG.rdoc",
"Gemfile",
"README.md",
"Rakefile",
"VERSION",
"devise_openid_authenticatable.gemspec",
"lib/devise_openid_authenticatable.rb",
"lib/devise_openid_authenticatable/model.rb",
"lib/devise_openid_authenticatable/routes.rb",
"lib/devise_openid_authenticatable/schema.rb",
"lib/devise_openid_authenticatable/strategy.rb",
"rails/init.rb",
"spec/model_spec.rb",
"spec/scenario/app/controllers/application_controller.rb",
"spec/scenario/app/controllers/home_controller.rb",
"spec/scenario/app/controllers/sessions_controller.rb",
"spec/scenario/app/models/database_user.rb",
"spec/scenario/app/models/legacy_user.rb",
"spec/scenario/app/models/user.rb",
"spec/scenario/app/views/layouts/application.html.erb",
"spec/scenario/app/views/sessions/new.html.erb",
"spec/scenario/config.ru",
"spec/scenario/config/application.rb",
"spec/scenario/config/boot.rb",
"spec/scenario/config/database.yml",
"spec/scenario/config/environment.rb",
"spec/scenario/config/environments/development.rb",
"spec/scenario/config/environments/test.rb",
"spec/scenario/config/initializers/backtrace_silencers.rb",
"spec/scenario/config/initializers/inflections.rb",
"spec/scenario/config/initializers/secret_token.rb",
"spec/scenario/config/routes.rb",
"spec/scenario/db/migrate/20100401102949_create_tables.rb",
"spec/scenario/db/schema.rb",
"spec/spec_helper.rb",
"spec/strategy_spec.rb",
"spec/support/migrations.rb"
]
s.homepage = %q{http://github.com/nbudin/devise_openid_authenticatable}
s.require_paths = ["lib"]
s.rubygems_version = %q{1.5.0}
s.summary = %q{OpenID authentication module for Devise}
s.test_files = [
"spec/model_spec.rb",
"spec/scenario/app/controllers/application_controller.rb",
"spec/scenario/app/controllers/home_controller.rb",
"spec/scenario/app/controllers/sessions_controller.rb",
"spec/scenario/app/models/database_user.rb",
"spec/scenario/app/models/legacy_user.rb",
"spec/scenario/app/models/user.rb",
"spec/scenario/config/application.rb",
"spec/scenario/config/boot.rb",
"spec/scenario/config/environment.rb",
"spec/scenario/config/environments/development.rb",
"spec/scenario/config/environments/test.rb",
"spec/scenario/config/initializers/backtrace_silencers.rb",
"spec/scenario/config/initializers/inflections.rb",
"spec/scenario/config/initializers/secret_token.rb",
"spec/scenario/config/routes.rb",
"spec/scenario/db/migrate/20100401102949_create_tables.rb",
"spec/scenario/db/schema.rb",
"spec/spec_helper.rb",
"spec/strategy_spec.rb",
"spec/support/migrations.rb"
]

if s.respond_to? :specification_version then
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rack-openid>, [">= 1.2.0"])
s.add_runtime_dependency(%q<devise>, [">= 1.0.6"])
else
s.add_dependency(%q<rack-openid>, [">= 1.2.0"])
s.add_dependency(%q<devise>, [">= 1.0.6"])
end
else
s.add_dependency(%q<rack-openid>, [">= 1.2.0"])
s.add_dependency(%q<devise>, [">= 1.0.6"])
end
end

2 changes: 1 addition & 1 deletion lib/devise_openid_authenticatable.rb
Expand Up @@ -8,4 +8,4 @@
:strategy => true,
:model => 'devise_openid_authenticatable/model',
:controller => :sessions,
:route => :openid
:route => :session
5 changes: 5 additions & 0 deletions lib/devise_openid_authenticatable/model.rb
Expand Up @@ -10,6 +10,11 @@ def find_by_identity_url(identity_url)
find(:first, :conditions => {:identity_url => identity_url})
end
end

module InstanceMethods
def valid_for_authentication?
end
end
end
end
end
13 changes: 3 additions & 10 deletions lib/devise_openid_authenticatable/strategy.rb
@@ -1,14 +1,7 @@
require 'devise/strategies/base'
require 'rack/openid'

base_class = begin
Devise::Strategies::Authenticatable
rescue
Devise::Strategies::Base
end

class Devise::Strategies::OpenidAuthenticatable < base_class

class Devise::Strategies::OpenidAuthenticatable < Devise::Strategies::Authenticatable
def valid?
valid_mapping? && ( provider_response? || identity_param? )
end
Expand All @@ -32,12 +25,12 @@ def authenticate!
# Handles incoming provider response
def handle_response!
logger.debug "Attempting OpenID auth: #{provider_response.inspect}"

case provider_response.status
when :success
resource = find_resource || build_resource || create_resource

if resource
if resource && validate(resource)
begin
update_resource!(resource)
rescue
Expand Down
3 changes: 3 additions & 0 deletions lib/devise_openid_authenticatable/version.rb
@@ -0,0 +1,3 @@
module DeviseOpenidAuthenticatable
VERSION = "1.1.0"
end
2 changes: 1 addition & 1 deletion spec/strategy_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'

describe Devise::Strategies::OpenidAuthenticatable do
include Rspec::Rails::RequestExampleGroup
include RSpec::Rails::RequestExampleGroup

def openid_params
{
Expand Down

0 comments on commit f79af8c

Please sign in to comment.