crowdint_auth 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.md +69 -0
- data/Rakefile +28 -0
- data/app/assets/stylesheets/crowdint_auth/application.css +13 -0
- data/app/controllers/crowdint_auth/application_controller.rb +4 -0
- data/app/controllers/crowdint_auth/omniauth_callbacks_controller.rb +25 -0
- data/app/helpers/crowdint_auth/application_helper.rb +4 -0
- data/app/views/layouts/crowdint_auth/application.html.erb +14 -0
- data/config/initializers/devise.rb +5 -0
- data/config/routes.rb +2 -0
- data/lib/crowdint_auth.rb +6 -0
- data/lib/crowdint_auth/engine.rb +4 -0
- data/lib/crowdint_auth/version.rb +3 -0
- data/lib/tasks/crowdint_auth_tasks.rake +4 -0
- metadata +129 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# CrowdintAuth
|
2
|
+
|
3
|
+
Adds the configuration to use Devise with our Crowd Interactive
|
4
|
+
Google Apps account for authentication.
|
5
|
+
|
6
|
+
# Installation
|
7
|
+
|
8
|
+
Gemfile
|
9
|
+
|
10
|
+
gem 'crowdint_auth'
|
11
|
+
|
12
|
+
Run
|
13
|
+
|
14
|
+
bundle install
|
15
|
+
|
16
|
+
# Usage
|
17
|
+
|
18
|
+
## Migration
|
19
|
+
|
20
|
+
Devise model needs the following extra fields:
|
21
|
+
|
22
|
+
class AddColumnsToRankitUsers < ActiveRecord::Migration
|
23
|
+
def change
|
24
|
+
add_column :rankit_users, :provider, :string
|
25
|
+
add_column :users, :uid, :string
|
26
|
+
end
|
27
|
+
|
28
|
+
## Routes
|
29
|
+
|
30
|
+
### If your user class is User
|
31
|
+
|
32
|
+
Set up the devise routes:
|
33
|
+
|
34
|
+
devise_scope :user do
|
35
|
+
match 'google_apps_sign_in', :to => "crowdint_auth/omniauth_callbacks#google_apps_sign_in"
|
36
|
+
end
|
37
|
+
|
38
|
+
devise_for :users, controllers: { omniauth_callbacks: 'crowdint_auth/omniauth_callbacks' }
|
39
|
+
|
40
|
+
The first match will determine the url for the login. That is, your sign in link
|
41
|
+
will probably look something like:
|
42
|
+
|
43
|
+
= link_to 'Sign In', google_apps_sign_in
|
44
|
+
|
45
|
+
### If your user class is named differently
|
46
|
+
|
47
|
+
Create your own omniauths controller:
|
48
|
+
|
49
|
+
class Users::OmniauthCallbacksController < CrowdintAuth::OmniauthCallbacksController
|
50
|
+
def user_class
|
51
|
+
OtherClassName
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
And set it up on routes:
|
56
|
+
|
57
|
+
devise_scope :user do
|
58
|
+
match 'google_apps_sign_in', :to => "users/omniauth_callbacks#google_apps_sign_in"
|
59
|
+
end
|
60
|
+
|
61
|
+
devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
|
62
|
+
|
63
|
+
# About the Author
|
64
|
+
|
65
|
+
[Crowd Interactive](http://www.crowdint.com) is a leading Ruby and Rails consultancy
|
66
|
+
firm based in Mexico currently doing business with startups in the United States.
|
67
|
+
We specialize in building and growing your existing development team, by adding
|
68
|
+
engineers onsite or offsite. We pick our clients carefully, as we only work with
|
69
|
+
companies we believe in. Find out more about us on our [website](http://www.crowdint.com).
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'rspec/core/rake_task'
|
16
|
+
|
17
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'CrowdintAuth'
|
20
|
+
rdoc.options << '--line-numbers'
|
21
|
+
rdoc.rdoc_files.include('README.rdoc')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
RSpec::Core::RakeTask.new :default
|
26
|
+
|
27
|
+
Bundler::GemHelper.install_tasks
|
28
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class CrowdintAuth::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
+
def user_class
|
3
|
+
::User
|
4
|
+
end
|
5
|
+
|
6
|
+
def create_user_record(email, name)
|
7
|
+
user_class.create(:email => email, :name => name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def google_apps
|
11
|
+
auth_hash = request.env['omniauth.auth']
|
12
|
+
email = auth_hash.info['email']
|
13
|
+
|
14
|
+
user = user_class.find_by_email(email)
|
15
|
+
user ||= create_user_record(email, auth_hash.info['name'])
|
16
|
+
|
17
|
+
if user.persisted?
|
18
|
+
sign_in_and_redirect user
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def google_apps_sign_in
|
23
|
+
redirect_to user_omniauth_authorize_path :google_apps
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CrowdintAuth</title>
|
5
|
+
<%= stylesheet_link_tag "crowdint_auth/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "crowdint_auth/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crowdint_auth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Padilla
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.8
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.8
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: devise
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: omniauth-google-apps
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec-rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: ! 'Authenticate Rails apps with CrowdInt''s Google Apps and Devise '
|
79
|
+
email:
|
80
|
+
- david@crowdint.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- app/assets/stylesheets/crowdint_auth/application.css
|
86
|
+
- app/controllers/crowdint_auth/application_controller.rb
|
87
|
+
- app/controllers/crowdint_auth/omniauth_callbacks_controller.rb
|
88
|
+
- app/helpers/crowdint_auth/application_helper.rb
|
89
|
+
- app/views/layouts/crowdint_auth/application.html.erb
|
90
|
+
- config/initializers/devise.rb
|
91
|
+
- config/routes.rb
|
92
|
+
- lib/crowdint_auth/engine.rb
|
93
|
+
- lib/crowdint_auth/version.rb
|
94
|
+
- lib/crowdint_auth.rb
|
95
|
+
- lib/tasks/crowdint_auth_tasks.rake
|
96
|
+
- MIT-LICENSE
|
97
|
+
- Rakefile
|
98
|
+
- README.md
|
99
|
+
homepage: https://github.com/dabit/crowdint_auth
|
100
|
+
licenses: []
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
hash: -2420540728232221423
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
hash: -2420540728232221423
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 1.8.23
|
126
|
+
signing_key:
|
127
|
+
specification_version: 3
|
128
|
+
summary: Authenticate Rails apps with CrowdInt's Google Apps and Devise
|
129
|
+
test_files: []
|