Class: OmniAuth::Strategies::ServiceNow
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::ServiceNow
- Defined in:
- lib/omniauth/strategies/service_now.rb
Constant Summary collapse
- SITE_REGEXP =
/(?:https:\/\/)?(?:([^.]+)\.)?service-now\.com/
Instance Method Summary collapse
- #authorize_params ⇒ Object
- #build_access_token ⇒ Object
- #callback_url ⇒ Object
- #instance_id ⇒ Object
- #raw_info ⇒ Object
- #smart_client_id ⇒ Object
- #smart_client_secret ⇒ Object
- #smart_site ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/omniauth/strategies/service_now.rb', line 27 def super.tap do |params| %w[client_options].each do |v| if request.params[v] params[v.to_sym] = request.params[v] end end end end |
#build_access_token ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/omniauth/strategies/service_now.rb', line 37 def build_access_token verifier = request.params["code"] # Override regular client when using setup: proc if env['omniauth.params']['client_id'] && env['omniauth.params']['client_secret'] && env['omniauth.params']['site'] client = ::OAuth2::Client.new( env['omniauth.params']['client_id'], env['omniauth.params']['client_secret'], site: env['omniauth.params']['site'], authorize_url: .., token_url: ..token_url ) client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(token_params.to_hash(:symbolize_keys => true)), deep_symbolize(.auth_token_params)) else super end end |
#callback_url ⇒ Object
80 81 82 |
# File 'lib/omniauth/strategies/service_now.rb', line 80 def callback_url full_host + script_name + callback_path end |
#instance_id ⇒ Object
76 77 78 |
# File 'lib/omniauth/strategies/service_now.rb', line 76 def instance_id @instance_id ||= smart_site.match(SITE_REGEXP)[1] if smart_site end |
#raw_info ⇒ Object
60 61 62 |
# File 'lib/omniauth/strategies/service_now.rb', line 60 def raw_info @raw_info ||= [:extra_client_id_and_client_secret] ? { client_id: smart_client_id, client_secret: smart_client_secret } : {} end |
#smart_client_id ⇒ Object
64 65 66 |
# File 'lib/omniauth/strategies/service_now.rb', line 64 def smart_client_id @smart_client_id ||= env['omniauth.params']['client_id'] || env['omniauth.strategy']..client_id end |
#smart_client_secret ⇒ Object
68 69 70 |
# File 'lib/omniauth/strategies/service_now.rb', line 68 def smart_client_secret @smart_client_secret ||= env['omniauth.params']['client_secret'] || env['omniauth.strategy']..client_secret end |
#smart_site ⇒ Object
72 73 74 |
# File 'lib/omniauth/strategies/service_now.rb', line 72 def smart_site @site ||= env['omniauth.params']['site'] || env['omniauth.strategy']..site || ..site end |