Class: OmniAuth::Strategies::Vis

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/vis.rb

Instance Method Summary collapse

Instance Method Details

#callback_urlObject

to fix always getting invalid_grant error see github.com/omniauth/omniauth-oauth2/issues/81#issuecomment-231442739



41
42
43
# File 'lib/omniauth/strategies/vis.rb', line 41

def callback_url
  full_host + script_name + callback_path
end

#on_path?(path) ⇒ Boolean

Fix strange bugs with urls containing double / like dhamma.org//oauth/callback

Returns:

  • (Boolean)


35
36
37
# File 'lib/omniauth/strategies/vis.rb', line 35

def on_path?(path)
  current_path.squeeze('/').casecmp(path.squeeze('/')).zero?
end

#raw_infoObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/omniauth/strategies/vis.rb', line 45

def raw_info
  return @raw_info if @raw_info.present?

  @raw_info = if options.jwt_shared_secret.present?
                # get info from the JWT token, so we save an API call
                JWT.decode(
                  access_token.token,
                  options.jwt_shared_secret,
                  true,
                  { algorithm: "hs512" }
                ).first["user"]
              else
                # get info from API
                access_token.get("/api/v1/me.json").parsed
              end
end

#setup_phaseObject



18
19
20
21
22
23
24
# File 'lib/omniauth/strategies/vis.rb', line 18

def setup_phase
  # configure Oauth2 client_options.site from a custom server_url option
  options.client_options.site = options.server_url

  # Authorize all params to be passed to VIS
  options.authorize_params = request.params.to_h
end