omniauth-fullscreen 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +54 -0
- data/.rspec +1 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +20 -0
- data/README.md +111 -0
- data/Rakefile +7 -0
- data/examples/config.ru +42 -0
- data/examples/omni_auth.rb +3 -0
- data/lib/omniauth-fullscreen.rb +2 -0
- data/lib/omniauth/fullscreen/version.rb +5 -0
- data/lib/omniauth/strategies/fullscreen.rb +61 -0
- data/omniauth-fullscreen.gemspec +22 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YWE2ZGJkMTk5NGU3OTBkYTRiZWU5ODQwZTA5NGNkNDk3ZGI2N2FhMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzAyMmFlZmU1YmExYzkwNDMxNDZlZjk3MTQxNTExMTVmY2JjNmUzZA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
N2VjNmEyODNlOGQzNGJlMTcyZmVjMWRmY2JlZTgxYThkNGI4YTk1MDgzNzJh
|
10
|
+
MzkwMjNlZTg5MDAzZDEyMDQyYmFkZjZiNDY3NzUyMDgyMGUzYjc3ZmU2ODI4
|
11
|
+
NTRjYjczOTI2NWQxMTQ3MWEwMjdmNTZhYWVmZDMwZjFiMGM0ZTQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjdlNmYyMTYwYzE0YjdhMGJkMDViNzZlZTUyMmE2ZDA1NDgzYzZjODNjZDhi
|
14
|
+
ZWFmNjc3NTkxNDRhYzUxOWFlN2ViNmQ5YWQwYTRhNTVhOGM0ZmU3YmE5OGY1
|
15
|
+
YjQ5OTk2NTA5NGEwODExY2ZlNjliMWIyOGVjZTExYTJmZjFlOTc=
|
data/.gitignore
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
|
15
|
+
# jeweler generated
|
16
|
+
pkg
|
17
|
+
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
19
|
+
#
|
20
|
+
# * Create a file at ~/.gitignore
|
21
|
+
# * Include files you want ignored
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
23
|
+
#
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
26
|
+
#
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
28
|
+
#
|
29
|
+
# For MacOS:
|
30
|
+
#
|
31
|
+
#.DS_Store
|
32
|
+
|
33
|
+
# For TextMate
|
34
|
+
#*.tmproj
|
35
|
+
#tmtags
|
36
|
+
|
37
|
+
# For emacs:
|
38
|
+
#*~
|
39
|
+
#\#*
|
40
|
+
#.\#*
|
41
|
+
|
42
|
+
# For vim:
|
43
|
+
#*.swp
|
44
|
+
|
45
|
+
# For redcar:
|
46
|
+
#.redcar
|
47
|
+
|
48
|
+
# For rubinius:
|
49
|
+
#*.rbc
|
50
|
+
|
51
|
+
# RVM
|
52
|
+
.rvmrc
|
53
|
+
|
54
|
+
Gemfile.lock
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Sean Stavropoulos
|
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,111 @@
|
|
1
|
+
# OmniAuth Fullscreen Strategy
|
2
|
+
|
3
|
+
Strategy to authenticate with Fullscreen via OAuth2 in OmniAuth.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add to your `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "omniauth-fullscreen"
|
11
|
+
```
|
12
|
+
Then `bundle install`.
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Here's an example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
20
|
+
provider :fullscreen, ENV["FULLSCREEN_KEY"], ENV["FULLSCREEN_SECRET"]
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
You can now access the OmniAuth Google OAuth2 URL: `/auth/fullscreen`
|
25
|
+
|
26
|
+
### Devise
|
27
|
+
|
28
|
+
For devise, you should also make sure you have an OmniAuth callback controller setup
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
32
|
+
def fullscreen
|
33
|
+
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
34
|
+
@user = User.find_for_fullscreen_oauth(request.env["omniauth.auth"], current_user)
|
35
|
+
|
36
|
+
if @user.persisted?
|
37
|
+
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Fullscreen"
|
38
|
+
sign_in_and_redirect @user, :event => :authentication
|
39
|
+
else
|
40
|
+
session["devise.google_data"] = request.env["omniauth.auth"]
|
41
|
+
redirect_to new_user_registration_url
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
and bind to or create the user
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
def self.find_for_fullscreen_oauth(access_token, signed_in_resource=nil)
|
51
|
+
data = access_token.info
|
52
|
+
user = User.where(:email => data["email"]).first
|
53
|
+
|
54
|
+
unless user
|
55
|
+
user = User.create(name: data["name"],
|
56
|
+
email: data["email"],
|
57
|
+
password: Devise.friendly_token[0,20]
|
58
|
+
)
|
59
|
+
end
|
60
|
+
user
|
61
|
+
end
|
62
|
+
```
|
63
|
+
## Configuration
|
64
|
+
|
65
|
+
You can configure several options, which you pass in to the `provider` method via a hash:
|
66
|
+
|
67
|
+
## Auth Hash
|
68
|
+
|
69
|
+
Here's an example of an authentication hash available in the callback by accessing `request.env["omniauth.auth"]`:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
{
|
73
|
+
:provider => "fullscreen",
|
74
|
+
:uid => 12345,
|
75
|
+
:info => {
|
76
|
+
:email => "john@company_name.com",
|
77
|
+
:first_name => "John",
|
78
|
+
:last_name => "Doe"
|
79
|
+
},
|
80
|
+
:credentials => {
|
81
|
+
:token => "token",
|
82
|
+
:refresh_token => "another_token",
|
83
|
+
:expires_at => 1354920555,
|
84
|
+
:expires => true
|
85
|
+
}
|
86
|
+
}
|
87
|
+
```
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
Copyright (c) 2013 Sean Stavropoulos
|
92
|
+
|
93
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
94
|
+
a copy of this software and associated documentation files (the
|
95
|
+
"Software"), to deal in the Software without restriction, including
|
96
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
97
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
98
|
+
permit persons to whom the Software is furnished to do so, subject to
|
99
|
+
the following conditions:
|
100
|
+
|
101
|
+
The above copyright notice and this permission notice shall be
|
102
|
+
included in all copies or substantial portions of the Software.
|
103
|
+
|
104
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
105
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
106
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
107
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
108
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
109
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
110
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
111
|
+
|
data/Rakefile
ADDED
data/examples/config.ru
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Sample app for Google OAuth2 Strategy
|
2
|
+
# Make sure to setup the ENV variables GOOGLE_KEY and GOOGLE_SECRET
|
3
|
+
# Run with "bundle exec rackup"
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'bundler'
|
7
|
+
require 'sinatra'
|
8
|
+
require 'omniauth'
|
9
|
+
require 'omniauth-fullscreen'
|
10
|
+
|
11
|
+
# Do not use for production code.
|
12
|
+
# This is only to make setup easier when running through the sample.
|
13
|
+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
14
|
+
|
15
|
+
class App < Sinatra::Base
|
16
|
+
get '/' do
|
17
|
+
<<-HTML
|
18
|
+
<ul>
|
19
|
+
<li><a href='/auth/fullscreen'>Sign in with Fullscreen</a></li>
|
20
|
+
</ul>
|
21
|
+
HTML
|
22
|
+
end
|
23
|
+
|
24
|
+
get '/auth/:provider/callback' do
|
25
|
+
content_type 'text/plain'
|
26
|
+
request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
|
27
|
+
end
|
28
|
+
|
29
|
+
get '/auth/failure' do
|
30
|
+
content_type 'text/plain'
|
31
|
+
request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
use Rack::Session::Cookie, :secret => ENV['RACK_COOKIE_SECRET']
|
36
|
+
|
37
|
+
use OmniAuth::Builder do
|
38
|
+
# Regular usage
|
39
|
+
provider :fullscreen, ENV['FULLSCREEN_KEY'], ENV['FULLSCREEN_SECRET'], {}
|
40
|
+
end
|
41
|
+
|
42
|
+
run App.new
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Fullscreen < OmniAuth::Strategies::OAuth2
|
6
|
+
|
7
|
+
option :name, 'fullscreen'
|
8
|
+
|
9
|
+
option :authorize_options, [:state]
|
10
|
+
|
11
|
+
option :client_options, {
|
12
|
+
site: 'https://accounts.fullscreen.net',
|
13
|
+
authorize_url: '/auth/authorize',
|
14
|
+
token_url: '/auth/token'
|
15
|
+
}
|
16
|
+
|
17
|
+
##
|
18
|
+
# You can pass +state+ param to the auth request, if
|
19
|
+
# you need to set them dynamically. You can also set these options
|
20
|
+
# in the OmniAuth config :authorize_params option.
|
21
|
+
#
|
22
|
+
# /auth/fullscreen?state=ABC
|
23
|
+
#
|
24
|
+
def authorize_params
|
25
|
+
super.tap do |params|
|
26
|
+
%w[state].each do |v|
|
27
|
+
if request.params[v]
|
28
|
+
params[v.to_sym] = request.params[v]
|
29
|
+
|
30
|
+
# to support omniauth-oauth2's auto csrf protection
|
31
|
+
session['omniauth.state'] = params[:state] if v == 'state'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
uid { user_info['id'] }
|
38
|
+
|
39
|
+
info do
|
40
|
+
{
|
41
|
+
first_name: user_info['info']['first_name'],
|
42
|
+
last_name: user_info['info']['last_name'],
|
43
|
+
email: user_info['info']['email']
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
extra do
|
48
|
+
{
|
49
|
+
user_info: user_info
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def user_info
|
54
|
+
@raw_info ||= @access_token.get("/auth/user.json").parsed
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
OmniAuth.config.add_camelization 'fullscreen', 'Fullscreen'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth/fullscreen/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Sean Stavropoulos"]
|
6
|
+
gem.email = ["seans@fullscreen.net"]
|
7
|
+
gem.description = %q{The Official Fullscreen OAuth2 strategy}
|
8
|
+
gem.summary = %q{A Official Fullscreen OAuth2 strategy}
|
9
|
+
gem.homepage = "https://github.com/fullscreeninc/omniauth-fullscreen"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "omniauth-fullscreen"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = OmniAuth::Fullscreen::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'omniauth-oauth2'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rspec', '~> 2.6.0'
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-fullscreen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sean Stavropoulos
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.6.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.6.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: The Official Fullscreen OAuth2 strategy
|
56
|
+
email:
|
57
|
+
- seans@fullscreen.net
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .rspec
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- examples/config.ru
|
69
|
+
- examples/omni_auth.rb
|
70
|
+
- lib/omniauth-fullscreen.rb
|
71
|
+
- lib/omniauth/fullscreen/version.rb
|
72
|
+
- lib/omniauth/strategies/fullscreen.rb
|
73
|
+
- omniauth-fullscreen.gemspec
|
74
|
+
homepage: https://github.com/fullscreeninc/omniauth-fullscreen
|
75
|
+
licenses: []
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.0.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: A Official Fullscreen OAuth2 strategy
|
97
|
+
test_files: []
|