tap/config/initializers/zeuswpi.rb

39 lines
1 KiB
Ruby
Raw Normal View History

2015-03-19 18:03:17 +00:00
require 'omniauth-oauth2'
module OmniAuth
module Strategies
2015-03-19 21:37:16 +00:00
class Zeuswpi < OmniAuth::Strategies::OAuth2
option :provider_ignores_state, true
2015-03-19 18:03:17 +00:00
# Give your strategy a name.
2015-03-19 21:37:16 +00:00
option :name, "zeuswpi"
2015-03-19 18:03:17 +00:00
# This is where you pass the options you would pass when
# initializing your consumer from the OAuth gem.
option :client_options, {
2015-03-20 01:21:56 +00:00
site: "https://kelder.zeus.ugent.be",
2015-03-19 21:37:16 +00:00
authorize_url: "/oauth/oauth2/authorize/",
token_url: "/oauth/oauth2/token/",
2015-03-19 18:03:17 +00:00
}
# 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.
2015-03-19 21:37:16 +00:00
uid{ raw_info['username'] }
2015-03-19 18:03:17 +00:00
extra do
{
'raw_info' => raw_info
}
end
def raw_info
2015-03-19 21:37:16 +00:00
@raw_info ||= access_token.get('/oauth/api/current_user/').parsed
2015-03-19 18:03:17 +00:00
end
end
end
end