Add tab omniauth
This commit is contained in:
parent
bbf6adef38
commit
c9a24e81e2
3 changed files with 57 additions and 2 deletions
2
Gemfile
2
Gemfile
|
@ -75,4 +75,4 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
|
|||
|
||||
gem 'coveralls', require: false
|
||||
|
||||
gem 'omniauth'
|
||||
gem 'omniauth-oauth2'
|
||||
|
|
18
Gemfile.lock
18
Gemfile.lock
|
@ -108,6 +108,8 @@ GEM
|
|||
execjs (2.3.0)
|
||||
faker (1.4.2)
|
||||
i18n (~> 0.5)
|
||||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.9.6-x64-mingw32)
|
||||
globalid (0.3.2)
|
||||
activesupport (>= 4.1.0)
|
||||
|
@ -122,6 +124,7 @@ GEM
|
|||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (1.8.2)
|
||||
jwt (1.4.1)
|
||||
launchy (2.4.3)
|
||||
addressable (~> 2.3)
|
||||
loofah (2.0.1)
|
||||
|
@ -132,6 +135,8 @@ GEM
|
|||
mini_portile (0.6.2)
|
||||
minitest (5.5.1)
|
||||
multi_json (1.10.1)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
mysql2 (0.3.17)
|
||||
net-scp (1.2.1)
|
||||
net-ssh (>= 2.6.5)
|
||||
|
@ -141,9 +146,20 @@ GEM
|
|||
mini_portile (~> 0.6.0)
|
||||
nokogiri (1.6.6.2-x64-mingw32)
|
||||
mini_portile (~> 0.6.0)
|
||||
oauth2 (1.0.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.2.2)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (~> 1.0)
|
||||
omniauth-oauth2 (1.2.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
multi_json (~> 1.3)
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
orm_adapter (0.5.0)
|
||||
paper_trail (4.0.0.beta2)
|
||||
activerecord (>= 3.0, < 6.0)
|
||||
|
@ -267,7 +283,7 @@ DEPENDENCIES
|
|||
jquery-rails
|
||||
launchy
|
||||
mysql2
|
||||
omniauth
|
||||
omniauth-oauth2
|
||||
paper_trail (~> 4.0.0.beta)
|
||||
paperclip
|
||||
rails (= 4.2)
|
||||
|
|
39
config/initializers/tab.rb
Normal file
39
config/initializers/tab.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'omniauth-oauth2'
|
||||
|
||||
module OmniAuth
|
||||
module Strategies
|
||||
class Tab < OmniAuth::Strategies::OAuth2
|
||||
# Give your strategy a name.
|
||||
option :name, "tab"
|
||||
|
||||
# This is where you pass the options you would pass when
|
||||
# initializing your consumer from the OAuth gem.
|
||||
option :client_options, {
|
||||
:site => "http://kelder.zeus.ugent.be/oauth/oauth2/authorize/"
|
||||
}
|
||||
|
||||
# These are called after authentication has succeeded. If
|
||||
# possible, you should try to set the UID without making
|
||||
# additional calls (if the user id is returned with the token
|
||||
# or as a URI parameter). This may not be possible with all
|
||||
# providers.
|
||||
uid{ raw_info['id'] }
|
||||
|
||||
info do
|
||||
{
|
||||
:name => raw_info['name'],
|
||||
}
|
||||
end
|
||||
|
||||
extra do
|
||||
{
|
||||
'raw_info' => raw_info
|
||||
}
|
||||
end
|
||||
|
||||
def raw_info
|
||||
@raw_info ||= access_token.get('/me').parsed
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue