omniauth-google-apps 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-google-apps.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ gem 'rb-fsevent'
11
+ gem 'growl'
12
+ end
13
+
14
+ group :example do
15
+ gem 'sinatra'
16
+ gem 'thin'
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-google-apps (0.0.1)
5
+ omniauth (~> 1.0)
6
+ omniauth-openid (~> 1.0)
7
+ ruby-openid-apps-discovery (~> 1.2.0)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ addressable (2.2.6)
13
+ crack (0.3.1)
14
+ daemons (1.1.4)
15
+ diff-lcs (1.1.3)
16
+ eventmachine (0.12.10)
17
+ ffi (1.0.11)
18
+ growl (1.0.3)
19
+ guard (0.9.1)
20
+ ffi (>= 0.5.0)
21
+ thor (~> 0.14.6)
22
+ guard-bundler (0.1.3)
23
+ bundler (>= 1.0.0)
24
+ guard (>= 0.2.2)
25
+ guard-rspec (0.5.9)
26
+ guard (>= 0.8.4)
27
+ hashie (1.2.0)
28
+ multi_json (1.0.4)
29
+ omniauth (1.0.1)
30
+ hashie (~> 1.2)
31
+ rack
32
+ omniauth-openid (1.0.1)
33
+ omniauth (~> 1.0)
34
+ rack-openid (~> 1.3.1)
35
+ rack (1.3.5)
36
+ rack-openid (1.3.1)
37
+ rack (>= 1.1.0)
38
+ ruby-openid (>= 2.1.8)
39
+ rack-protection (1.1.4)
40
+ rack
41
+ rack-test (0.6.1)
42
+ rack (>= 1.0)
43
+ rb-fsevent (0.4.3.1)
44
+ rspec (2.7.0)
45
+ rspec-core (~> 2.7.0)
46
+ rspec-expectations (~> 2.7.0)
47
+ rspec-mocks (~> 2.7.0)
48
+ rspec-core (2.7.1)
49
+ rspec-expectations (2.7.0)
50
+ diff-lcs (~> 1.1.2)
51
+ rspec-mocks (2.7.0)
52
+ ruby-openid (2.1.8)
53
+ ruby-openid-apps-discovery (1.2.0)
54
+ ruby-openid (>= 2.1.7)
55
+ simplecov (0.5.4)
56
+ multi_json (~> 1.0.3)
57
+ simplecov-html (~> 0.5.3)
58
+ simplecov-html (0.5.3)
59
+ sinatra (1.3.1)
60
+ rack (~> 1.3, >= 1.3.4)
61
+ rack-protection (~> 1.1, >= 1.1.2)
62
+ tilt (~> 1.3, >= 1.3.3)
63
+ thin (1.3.1)
64
+ daemons (>= 1.0.9)
65
+ eventmachine (>= 0.12.6)
66
+ rack (>= 1.0.0)
67
+ thor (0.14.6)
68
+ tilt (1.3.3)
69
+ webmock (1.7.8)
70
+ addressable (~> 2.2, > 2.2.5)
71
+ crack (>= 0.1.7)
72
+
73
+ PLATFORMS
74
+ ruby
75
+
76
+ DEPENDENCIES
77
+ growl
78
+ guard
79
+ guard-bundler
80
+ guard-rspec
81
+ omniauth-google-apps!
82
+ rack-test
83
+ rb-fsevent
84
+ rspec (~> 2.7)
85
+ simplecov
86
+ sinatra
87
+ thin
88
+ webmock
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ watch('omniauth-google-apps.gemspec')
10
+ end
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # OmniAuth Google Apps
2
+
3
+ This is the OmniAuth strategy for authenticating to Google Apps.
4
+
5
+ ## Basic Usage
6
+
7
+ use OmniAuth::Builder do
8
+ # domain is optional attribute
9
+ provider :google_apps #, domain: 'intridea.com'
10
+ end
11
+
12
+ ## License
13
+
14
+ Copyright (c) 2011 Dingding Ye.
15
+
16
+ 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:
17
+
18
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
19
+
20
+ 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.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new
10
+
11
+ desc 'Run specs'
12
+ task :default => :spec
data/examples/test.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.setup :default, :development, :example
5
+
6
+ require 'sinatra'
7
+ require 'omniauth-google-apps'
8
+
9
+ use Rack::Session::Cookie
10
+ use OmniAuth::Builder do
11
+ provider :google_apps
12
+ end
13
+
14
+ get '/' do
15
+ <<-HTML
16
+ <a href='/auth/google_apps'>Sign in with Google Apps</a>
17
+ HTML
18
+ end
19
+
20
+ post '/auth/:name/callback' do
21
+ auth = request.env['omniauth.auth']
22
+ # do whatever you want with the information!
23
+ puts auth.inspect
24
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-google-apps/version"
2
+ require "omniauth/strategies/google_apps"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module GoogleApps
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ require 'omniauth-openid'
2
+ require 'openid/gapps'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class GoogleApps < OmniAuth::Strategies::OpenID
7
+ option :name, "google_apps"
8
+ option :domain, nil
9
+
10
+ def get_identifier
11
+ f = OmniAuth::Form.new(:title => 'Google Apps Authentication')
12
+ f.label_field('Google Apps Domain', 'domain')
13
+ f.input_field('url', 'domain')
14
+ f.to_response
15
+ end
16
+
17
+ def identifier
18
+ options[:domain] || request['domain']
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ require 'openid/consumer'
2
+ require 'gapps_openid'
3
+
4
+ module OpenID
5
+ # Because gapps_openid changes the discovery order
6
+ # (looking first for Google Apps, then anything else),
7
+ # we need to monkeypatch it to make it play nicely
8
+ # with others.
9
+ def self.discover(uri)
10
+ discovered = self.default_discover(uri)
11
+
12
+ if discovered.last.empty?
13
+ info = discover_google_apps(uri)
14
+ return info if info
15
+ end
16
+
17
+ return discovered
18
+ rescue OpenID::DiscoveryFailure => e
19
+ info = discover_google_apps(uri)
20
+
21
+ if info.nil?
22
+ raise e
23
+ else
24
+ return info
25
+ end
26
+ end
27
+
28
+ def self.discover_google_apps(uri)
29
+ discovery = GoogleDiscovery.new
30
+ discovery.perform_discovery(uri)
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-google-apps/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-google-apps"
7
+ s.version = Omniauth::GoogleApps::VERSION
8
+ s.authors = ["Dingding Ye"]
9
+ s.email = ["yedingding@gmail.com"]
10
+ s.homepage = "https://github.com/sishen/omniauth-google-apps"
11
+ s.summary = %q{OmniAuth strategy for Google Apps.}
12
+ s.description = %q{OmniAuth strategy for Google Apps.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ # specify any dependencies here; for example:
20
+ s.add_dependency 'omniauth', '~> 1.0'
21
+ s.add_dependency 'omniauth-openid', '~> 1.0'
22
+ s.add_dependency 'ruby-openid-apps-discovery', '~> 1.2.0'
23
+ s.add_development_dependency 'rspec', '~> 2.7'
24
+ s.add_development_dependency 'rack-test'
25
+ s.add_development_dependency 'simplecov'
26
+ s.add_development_dependency 'webmock'
27
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::GoogleApps do
4
+ it 'should do some testing' do
5
+ pending
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-google-apps'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-google-apps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dingding Ye
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-20 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &70161765972780 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70161765972780
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-openid
27
+ requirement: &70161765971800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70161765971800
36
+ - !ruby/object:Gem::Dependency
37
+ name: ruby-openid-apps-discovery
38
+ requirement: &70161765970260 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.2.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70161765970260
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70161765969580 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.7'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70161765969580
58
+ - !ruby/object:Gem::Dependency
59
+ name: rack-test
60
+ requirement: &70161765968840 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70161765968840
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: &70161765968020 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70161765968020
80
+ - !ruby/object:Gem::Dependency
81
+ name: webmock
82
+ requirement: &70161765967180 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70161765967180
91
+ description: OmniAuth strategy for Google Apps.
92
+ email:
93
+ - yedingding@gmail.com
94
+ executables: []
95
+ extensions: []
96
+ extra_rdoc_files: []
97
+ files:
98
+ - .gitignore
99
+ - Gemfile
100
+ - Gemfile.lock
101
+ - Guardfile
102
+ - README.md
103
+ - Rakefile
104
+ - examples/test.rb
105
+ - lib/omniauth-google-apps.rb
106
+ - lib/omniauth-google-apps/version.rb
107
+ - lib/omniauth/strategies/google_apps.rb
108
+ - lib/openid/gapps.rb
109
+ - omniauth-google-apps.gemspec
110
+ - spec/omniauth/strategies/google_apps_spec.rb
111
+ - spec/spec_helper.rb
112
+ homepage: https://github.com/sishen/omniauth-google-apps
113
+ licenses: []
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 1.8.10
133
+ signing_key:
134
+ specification_version: 3
135
+ summary: OmniAuth strategy for Google Apps.
136
+ test_files:
137
+ - spec/omniauth/strategies/google_apps_spec.rb
138
+ - spec/spec_helper.rb
139
+ has_rdoc: