First stage of moving to gem family route, still need to add gemspecs and gem building methods.
This commit is contained in:
Родитель
46dc888671
Коммит
0cdc080b59
|
@ -0,0 +1,18 @@
|
|||
# OmniAuth
|
||||
|
||||
I know what you're thinking: yes, it's yet **another** authentication solution for Rack applications. But we're going to do things a little bit differently this time. OmniAuth is built from the ground up on the philosophy that **authentication is not the same as identity**. OmniAuth is based on two observations:
|
||||
|
||||
1. The traditional 'sign up using a login and password' model is becoming the exception, not the rule. Modern web applications offer external authentication via OpenID, Facebook, and OAuth.
|
||||
2. The interconnectable web is no longer a dream, it is a necessity. It is not unreasonable to expect that one application may need to be able to connect to one, three, or twelve other services. Modern authentication systems should a user's identity to be associated with many authentications.
|
||||
|
||||
## Theoretical Framework
|
||||
|
||||
OmniAuth works on the principle that every authentication system can essentially be boiled down into two "phases".
|
||||
|
||||
### The Request Phase
|
||||
|
||||
In the Request Phase, we *request* information from the user that is necessary to complete authentication. This information may be **POST**ed to a URL or performed externally through an authentication process such as OpenID.
|
||||
|
||||
### The Callback Phase
|
||||
|
||||
In the Callback Phase, we receive an authenticated **unique identifier** that can differentiate this user from other users of the same authentication system. Additionally, we may provide **user information** that can be automatically harvested by the application to fill in the details of the authenticating user.
|
59
Rakefile
59
Rakefile
|
@ -1,51 +1,18 @@
|
|||
require 'rubygems'
|
||||
require 'rake'
|
||||
require 'term/ansicolor'
|
||||
|
||||
begin
|
||||
require 'jeweler'
|
||||
Jeweler::Tasks.new do |gem|
|
||||
gem.name = "omni_auth"
|
||||
gem.summary = %Q{Auth from anywhere.}
|
||||
gem.description = %Q{Auth from anywhere.}
|
||||
gem.email = "michael@intridea.com"
|
||||
gem.homepage = "http://github.com/intridea/omni_auth"
|
||||
gem.authors = ["Michael Bleigh"]
|
||||
gem.add_dependency 'rack'
|
||||
gem.add_dependency 'rest-client'
|
||||
gem.add_dependency 'oauth'
|
||||
gem.add_dependency 'nokogiri'
|
||||
gem.add_dependency 'json'
|
||||
gem.add_dependency 'rack-openid'
|
||||
gem.add_development_dependency "rspec", ">= 1.2.9"
|
||||
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
||||
include Term::ANSIColor
|
||||
|
||||
OMNIAUTH_GEMS = %w(oa-core oa-basic oa-oauth oa-openid)
|
||||
|
||||
desc 'Run specs for all of the gems.'
|
||||
task :spec do
|
||||
OMNIAUTH_GEMS.each_with_index do |dir, i|
|
||||
Dir.chdir(dir) do
|
||||
print blue, "\n\n== ", cyan, dir, blue, " specs are running...", clear, "\n\n"
|
||||
system('rake spec')
|
||||
end
|
||||
end
|
||||
Jeweler::GemcutterTasks.new
|
||||
rescue LoadError
|
||||
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
||||
end
|
||||
|
||||
require 'spec/rake/spectask'
|
||||
Spec::Rake::SpecTask.new(:spec) do |spec|
|
||||
spec.libs << 'lib' << 'spec'
|
||||
spec.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
||||
|
||||
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
||||
spec.libs << 'lib' << 'spec'
|
||||
spec.pattern = 'spec/**/*_spec.rb'
|
||||
spec.rcov = true
|
||||
end
|
||||
|
||||
task :spec => :check_dependencies
|
||||
|
||||
task :default => :spec
|
||||
|
||||
require 'rake/rdoctask'
|
||||
Rake::RDocTask.new do |rdoc|
|
||||
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
||||
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = "rack-oauthable #{version}"
|
||||
rdoc.rdoc_files.include('README*')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
end
|
||||
|
1
VERSION
1
VERSION
|
@ -1 +0,0 @@
|
|||
0.0.1
|
|
@ -0,0 +1,10 @@
|
|||
require 'rubygems'
|
||||
require 'rake'
|
||||
|
||||
require 'spec/rake/spectask'
|
||||
Spec::Rake::SpecTask.new(:spec) do |spec|
|
||||
spec.libs << '../oa-core/lib' << 'lib' << 'spec'
|
||||
spec.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
||||
|
||||
task :default => :spec
|
|
@ -0,0 +1,2 @@
|
|||
require 'omniauth/core'
|
||||
require 'omniauth/strategies/http_basic'
|
|
@ -25,7 +25,7 @@ module OmniAuth
|
|||
end
|
||||
|
||||
def callback_phase
|
||||
[401, {}, 'Unauthorized']
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
require 'rubygems'
|
||||
require 'rake'
|
||||
|
||||
require 'spec/rake/spectask'
|
||||
Spec::Rake::SpecTask.new(:spec) do |spec|
|
||||
spec.libs << 'lib' << 'spec'
|
||||
spec.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
||||
|
||||
task :default => :spec
|
|
@ -24,10 +24,6 @@ module OmniAuth
|
|||
attr_accessor :path_prefix
|
||||
end
|
||||
|
||||
def self.build(stack, &block)
|
||||
OmniAuth::Builder.new(stack, &block)
|
||||
end
|
||||
|
||||
def self.config
|
||||
Configuration.instance
|
||||
end
|
||||
|
@ -67,8 +63,5 @@ module OmniAuth
|
|||
end
|
||||
end
|
||||
|
||||
require 'omni_auth/strategy'
|
||||
%w(oauth http_basic linked_in gowalla twitter open_id password).each do |s|
|
||||
require "omni_auth/strategies/#{s}"
|
||||
end
|
||||
require 'omni_auth/builder'
|
||||
require 'omniauth/builder'
|
||||
require 'omniauth/strategy'
|
|
@ -0,0 +1,2 @@
|
|||
require 'omniauth/core'
|
||||
require 'omniauth/strategies/password'
|
|
@ -0,0 +1,58 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe OmniAuth do
|
||||
context 'configuration' do
|
||||
it 'should be callable from .configure' do
|
||||
OmniAuth.configure do |c|
|
||||
c.should be_kind_of(OmniAuth::Configuration)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should be able to set the path' do
|
||||
OmniAuth.configure do |config|
|
||||
config.path_prefix = '/awesome'
|
||||
end
|
||||
|
||||
OmniAuth.config.path_prefix.should == '/awesome'
|
||||
end
|
||||
|
||||
it 'should be able to set the on_failure rack app' do
|
||||
OmniAuth.configure do |config|
|
||||
config.on_failure do
|
||||
'yoyo'
|
||||
end
|
||||
end
|
||||
|
||||
OmniAuth.config.on_failure.call.should == 'yoyo'
|
||||
end
|
||||
end
|
||||
|
||||
describe '::Utils' do
|
||||
describe '.deep_merge' do
|
||||
it 'should combine hashes' do
|
||||
OmniAuth::Utils.deep_merge({'abc' => {'def' => 123}}, {'abc' => {'foo' => 'bar'}}).should == {
|
||||
'abc' => {'def' => 123, 'foo' => 'bar'}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe '.camelize' do
|
||||
it 'should work on normal cases' do
|
||||
{
|
||||
'some_word' => 'SomeWord',
|
||||
'AnotherWord' => 'AnotherWord',
|
||||
'one' => 'One',
|
||||
'three_words_now' => 'ThreeWordsNow'
|
||||
}.each_pair{ |k,v| OmniAuth::Utils.camelize(k).should == v }
|
||||
end
|
||||
|
||||
it 'should work in special cases' do
|
||||
{
|
||||
'oauth' => "OAuth",
|
||||
'openid' => 'OpenID',
|
||||
'open_id' => 'OpenID'
|
||||
}.each_pair{ |k,v| OmniAuth::Utils.camelize(k).should == v}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
require 'omniauth/password'
|
||||
|
||||
describe OmniAuth::Strategies::Password do
|
||||
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
--colour
|
||||
--format=specdoc
|
|
@ -0,0 +1,10 @@
|
|||
require 'rubygems'
|
||||
require 'spec'
|
||||
require 'spec/autorun'
|
||||
require 'rack/test'
|
||||
require 'webmock/rspec'
|
||||
|
||||
include Rack::Test::Methods
|
||||
include WebMock
|
||||
|
||||
require 'omniauth/core'
|
|
@ -0,0 +1,10 @@
|
|||
require 'rubygems'
|
||||
require 'rake'
|
||||
|
||||
require 'spec/rake/spectask'
|
||||
Spec::Rake::SpecTask.new(:spec) do |spec|
|
||||
spec.libs << '../oa-core/lib' << 'lib' << 'spec'
|
||||
spec.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
||||
|
||||
task :default => :spec
|
|
@ -0,0 +1,5 @@
|
|||
require 'oauth'
|
||||
require 'omniauth/core'
|
||||
require 'omniauth/strategies/oauth'
|
||||
require 'omniauth/strategies/twitter'
|
||||
require 'omniauth/strategies/linked_in'
|
|
@ -1,3 +1,5 @@
|
|||
require 'omniauth/core'
|
||||
require 'omniauth/strategies/oauth'
|
||||
require 'nokogiri'
|
||||
|
||||
module OmniAuth
|
|
@ -1,3 +1,5 @@
|
|||
require 'omniauth/core'
|
||||
require 'omniauth/strategies/oauth'
|
||||
require 'json'
|
||||
|
||||
module OmniAuth
|
|
@ -0,0 +1,18 @@
|
|||
require 'omniauth/version'
|
||||
|
||||
Gem::Specification.new do |gem|
|
||||
gem.name = "oa-oauth"
|
||||
gem.version = File.open(File.dirname(__FILE__) + '/VERSION', 'r').read.trim
|
||||
gem.summary = %Q{OAuth strategies for OmniAuth.}
|
||||
gem.description = %Q{OAuth strategies for OmniAuth.}
|
||||
gem.email = "michael@intridea.com"
|
||||
gem.homepage = "http://github.com/intridea/omni_auth"
|
||||
gem.authors = ["Michael Bleigh"]
|
||||
|
||||
gem.add_dependency 'oa-core'
|
||||
gem.add_dependency 'oauth'
|
||||
gem.add_dependency 'nokogiri'
|
||||
gem.add_dependency 'json'
|
||||
|
||||
gem.add_development_dependency "rspec", ">= 1.2.9"
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
--colour
|
||||
--format=specdoc
|
||||
--backtrace
|
|
@ -0,0 +1,10 @@
|
|||
require 'rubygems'
|
||||
require 'spec'
|
||||
require 'spec/autorun'
|
||||
require 'rack/test'
|
||||
require 'webmock/rspec'
|
||||
|
||||
include Rack::Test::Methods
|
||||
include WebMock
|
||||
|
||||
require 'omniauth/oauth'
|
|
@ -0,0 +1,10 @@
|
|||
require 'rubygems'
|
||||
require 'rake'
|
||||
|
||||
require 'spec/rake/spectask'
|
||||
Spec::Rake::SpecTask.new(:spec) do |spec|
|
||||
spec.libs << '../oa-core/lib' << 'lib' << 'spec'
|
||||
spec.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
||||
|
||||
task :default => :spec
|
|
@ -0,0 +1,2 @@
|
|||
require 'omniauth/core'
|
||||
require 'omniauth/strategies/open_id'
|
|
@ -0,0 +1,10 @@
|
|||
require 'rubygems'
|
||||
require 'rake'
|
||||
|
||||
require 'spec/rake/spectask'
|
||||
Spec::Rake::SpecTask.new(:spec) do |spec|
|
||||
spec.libs << '../oa-core/lib' << 'lib' << 'spec'
|
||||
spec.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
||||
|
||||
task :default => :spec
|
|
@ -1,69 +0,0 @@
|
|||
# Generated by jeweler
|
||||
# DO NOT EDIT THIS FILE DIRECTLY
|
||||
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = %q{omni_auth}
|
||||
s.version = "0.0.0.alpha.1"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["Michael Bleigh"]
|
||||
s.date = %q{2010-03-30}
|
||||
s.description = %q{Auth from anywhere.}
|
||||
s.email = %q{michael@intridea.com}
|
||||
s.extra_rdoc_files = [
|
||||
"LICENSE",
|
||||
"README.rdoc"
|
||||
]
|
||||
s.files = [
|
||||
".document",
|
||||
".gitignore",
|
||||
"LICENSE",
|
||||
"README.rdoc",
|
||||
"Rakefile",
|
||||
"VERSION",
|
||||
"lib/omni_auth.rb",
|
||||
"lib/omni_auth/strategies/gowalla.rb",
|
||||
"lib/omni_auth/strategies/http_basic.rb",
|
||||
"lib/omni_auth/strategies/linked_in.rb",
|
||||
"lib/omni_auth/strategies/oauth.rb",
|
||||
"lib/omni_auth/strategies/twitter.rb",
|
||||
"lib/omni_auth/strategy.rb",
|
||||
"spec/auth_elsewhere/oauth_spec.rb",
|
||||
"spec/spec.opts",
|
||||
"spec/spec_helper.rb"
|
||||
]
|
||||
s.homepage = %q{http://github.com/intridea/omni_auth}
|
||||
s.rdoc_options = ["--charset=UTF-8"]
|
||||
s.require_paths = ["lib"]
|
||||
s.rubygems_version = %q{1.3.6}
|
||||
s.summary = %q{Auth from anywhere.}
|
||||
s.test_files = [
|
||||
"spec/auth_elsewhere/oauth_spec.rb",
|
||||
"spec/spec_helper.rb"
|
||||
]
|
||||
|
||||
if s.respond_to? :specification_version then
|
||||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
||||
s.specification_version = 3
|
||||
|
||||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
||||
s.add_runtime_dependency(%q<rack>, [">= 0"])
|
||||
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
||||
s.add_runtime_dependency(%q<oauth>, [">= 0"])
|
||||
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
||||
else
|
||||
s.add_dependency(%q<rack>, [">= 0"])
|
||||
s.add_dependency(%q<rest-client>, [">= 0"])
|
||||
s.add_dependency(%q<oauth>, [">= 0"])
|
||||
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
||||
end
|
||||
else
|
||||
s.add_dependency(%q<rack>, [">= 0"])
|
||||
s.add_dependency(%q<rest-client>, [">= 0"])
|
||||
s.add_dependency(%q<oauth>, [">= 0"])
|
||||
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
||||
end
|
||||
end
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
= rack-oauthable
|
||||
= OmniAuth
|
||||
|
||||
Description goes here.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
require 'omniauth/core'
|
||||
|
||||
%w(password oauth basic openid).each do |s|
|
||||
begin
|
||||
require "omniauth/#{s}"
|
||||
rescue LoadError
|
||||
puts "Unable to find the files for oa-#{s}, ignored it."
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe OmniAuth::Strategies::Password do
|
||||
before(:each) do
|
||||
FakeAdapter.reset!
|
||||
end
|
||||
|
||||
it do
|
||||
FakeAdapter.authenticate('mbleigh','dude').should be_false
|
||||
FakeAdapter.register('mbleigh','dude')
|
||||
FakeAdapter.authenticate('mbleigh','dude').should be_true
|
||||
end
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
--color
|
||||
--format=specdoc
|
||||
--backtrace
|
|
@ -1,16 +0,0 @@
|
|||
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
|
||||
require 'rubygems'
|
||||
require 'omni_auth'
|
||||
require 'spec'
|
||||
require 'spec/autorun'
|
||||
require 'rack/test'
|
||||
require 'webmock/rspec'
|
||||
|
||||
include Rack::Test::Methods
|
||||
include WebMock
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
|
||||
end
|
Загрузка…
Ссылка в новой задаче