omniauth-salesforce-ultimate 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rubocop.yml +3 -0
- data/.tool-versions +1 -0
- data/Gemfile +7 -0
- data/README.md +43 -0
- data/Rakefile +12 -0
- data/lib/omniauth/salesforce/version.rb +5 -0
- data/lib/omniauth/strategies/salesforce.rb +99 -0
- data/lib/omniauth-salesforce-ultimate.rb +2 -0
- data/omniauth-salesforce-ultimate.gemspec +26 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a155ec80e3e63927a4e6b7644affdd25c8640492315f00945fda5d7032d7f673
|
4
|
+
data.tar.gz: 057dc5a98c1f92234456363f4914883ae6989860920d3f29f51dafd8313e7f5f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d97dd09088ecb2a24c15e2b0d624d843103ebae582f6b07579f096f720ca404714737226085ff7e0643e1edd05006ba7fe4438a3323b2c1df78a1d1da5adaebf
|
7
|
+
data.tar.gz: ad14a7faf0092173464b9f6d76627cf47dccceffa2f98ada5b2f00ee7c777547774dd76fd3d3df5d826e1891c1efc7c03a8cb8df186451c744898c93132ff097
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.1.2
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# omniauth-salesforce
|
2
|
+
|
3
|
+
[OmniAuth](https://github.com/intridea/omniauth) Strategy for [salesforce.com](salesforce.com).
|
4
|
+
|
5
|
+
Note: This is a fork of the [original](https://github.com/richardvanhook/omniauth-salesforce) project and is now the main repository for the omniauth-salesforce gem.
|
6
|
+
|
7
|
+
## Basic Usage
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
require "sinatra"
|
11
|
+
require "omniauth"
|
12
|
+
require "omniauth-salesforce"
|
13
|
+
|
14
|
+
class MyApplication < Sinatra::Base
|
15
|
+
use Rack::Session
|
16
|
+
use OmniAuth::Builder do
|
17
|
+
provider :salesforce, ENV['SALESFORCE_KEY'], ENV['SALESFORCE_SECRET']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
## Including other sites
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
use OmniAuth::Builder do
|
26
|
+
provider :salesforce,
|
27
|
+
ENV['SALESFORCE_KEY'],
|
28
|
+
ENV['SALESFORCE_SECRET']
|
29
|
+
provider OmniAuth::Strategies::SalesforceSandbox,
|
30
|
+
ENV['SALESFORCE_SANDBOX_KEY'],
|
31
|
+
ENV['SALESFORCE_SANDBOX_SECRET']
|
32
|
+
provider OmniAuth::Strategies::SalesforcePreRelease,
|
33
|
+
ENV['SALESFORCE_PRERELEASE_KEY'],
|
34
|
+
ENV['SALESFORCE_PRERELEASE_SECRET']
|
35
|
+
provider OmniAuth::Strategies::DatabaseDotCom,
|
36
|
+
ENV['DATABASE_DOT_COM_KEY'],
|
37
|
+
ENV['DATABASE_DOT_COM_SECRET']
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
## Resources
|
42
|
+
|
43
|
+
* [Article: Digging Deeper into OAuth 2.0 on Force.com](http://wiki.developerforce.com/index.php/Digging_Deeper_into_OAuth_2.0_on_Force.com)
|
data/Rakefile
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'openssl'
|
3
|
+
require 'base64'
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class Salesforce < OmniAuth::Strategies::OAuth2
|
8
|
+
|
9
|
+
MOBILE_USER_AGENTS = 'webos|ipod|iphone|ipad|android|blackberry|mobile'
|
10
|
+
|
11
|
+
option :client_options, {
|
12
|
+
:site => 'https://login.salesforce.com',
|
13
|
+
:authorize_url => '/services/oauth2/authorize',
|
14
|
+
:token_url => '/services/oauth2/token'
|
15
|
+
}
|
16
|
+
option :authorize_options, [
|
17
|
+
:scope,
|
18
|
+
:display,
|
19
|
+
:immediate,
|
20
|
+
:state,
|
21
|
+
:prompt,
|
22
|
+
:redirect_uri,
|
23
|
+
:login_hint
|
24
|
+
]
|
25
|
+
|
26
|
+
def request_phase
|
27
|
+
req = Rack::Request.new(@env)
|
28
|
+
options.update(req.params)
|
29
|
+
ua = req.user_agent.to_s
|
30
|
+
if !options.has_key?(:display)
|
31
|
+
mobile_request = ua.downcase =~ Regexp.new(MOBILE_USER_AGENTS)
|
32
|
+
options[:display] = mobile_request ? 'touch' : 'page'
|
33
|
+
end
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def auth_hash
|
38
|
+
signed_value = access_token.params['id'] + access_token.params['issued_at']
|
39
|
+
raw_expected_signature = OpenSSL::HMAC.digest('sha256', options.client_secret.to_s, signed_value)
|
40
|
+
expected_signature = Base64.strict_encode64 raw_expected_signature
|
41
|
+
signature = access_token.params['signature']
|
42
|
+
fail! "Salesforce user id did not match signature!" unless signature == expected_signature
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
uid { raw_info['id'] }
|
47
|
+
|
48
|
+
info do
|
49
|
+
{
|
50
|
+
'name' => raw_info['display_name'],
|
51
|
+
'email' => raw_info['email'],
|
52
|
+
'nickname' => raw_info['nick_name'],
|
53
|
+
'first_name' => raw_info['first_name'],
|
54
|
+
'last_name' => raw_info['last_name'],
|
55
|
+
'location' => '',
|
56
|
+
'description' => '',
|
57
|
+
'image' => raw_info['photos']['thumbnail'] + "?oauth_token=#{access_token.token}",
|
58
|
+
'phone' => '',
|
59
|
+
'urls' => raw_info['urls']
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
credentials do
|
64
|
+
hash = {'token' => access_token.token}
|
65
|
+
hash.merge!('instance_url' => access_token.params["instance_url"])
|
66
|
+
hash.merge!('refresh_token' => access_token.refresh_token) if access_token.refresh_token
|
67
|
+
hash
|
68
|
+
end
|
69
|
+
|
70
|
+
def raw_info
|
71
|
+
access_token.options[:mode] = :header
|
72
|
+
@raw_info ||= access_token.post(access_token['id']).parsed
|
73
|
+
end
|
74
|
+
|
75
|
+
extra do
|
76
|
+
raw_info.merge({
|
77
|
+
'instance_url' => access_token.params['instance_url'],
|
78
|
+
'pod' => access_token.params['instance_url'],
|
79
|
+
'signature' => access_token.params['signature'],
|
80
|
+
'issued_at' => access_token.params['issued_at']
|
81
|
+
})
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
class SalesforceSandbox < OmniAuth::Strategies::Salesforce
|
87
|
+
default_options[:client_options][:site] = 'https://test.salesforce.com'
|
88
|
+
end
|
89
|
+
|
90
|
+
class DatabaseDotCom < OmniAuth::Strategies::Salesforce
|
91
|
+
default_options[:client_options][:site] = 'https://login.database.com'
|
92
|
+
end
|
93
|
+
|
94
|
+
class SalesforcePreRelease < OmniAuth::Strategies::Salesforce
|
95
|
+
default_options[:client_options][:site] = 'https://prerellogin.pre.salesforce.com/'
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path(
|
4
|
+
File.join('..', 'lib', 'omniauth', 'salesforce', 'version'),
|
5
|
+
__FILE__
|
6
|
+
)
|
7
|
+
|
8
|
+
Gem::Specification.new do |gem|
|
9
|
+
gem.authors = ["Herculano Chaves"]
|
10
|
+
gem.email = ["herculanoweb@gmail.com"]
|
11
|
+
gem.description = %q{OmniAuth strategy for salesforce.com. Addapted to work with Oauth 2.0.}
|
12
|
+
gem.summary = %q{OmniAuth strategy for salesforce.com.}
|
13
|
+
gem.homepage = "https://github.com/herculano-ch/omniauth-salesforce"
|
14
|
+
|
15
|
+
gem.name = 'omniauth-salesforce-ultimate'
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
gem.version = OmniAuth::Salesforce::VERSION
|
18
|
+
gem.license = 'MIT'
|
19
|
+
gem.files = `git ls-files`.split("\n")
|
20
|
+
|
21
|
+
gem.add_dependency 'omniauth', '~> 2.0'
|
22
|
+
gem.add_dependency 'omniauth-oauth2', '>= 1.7'
|
23
|
+
gem.required_ruby_version = '>= 2.2'
|
24
|
+
|
25
|
+
gem.add_development_dependency 'rubocop', '~> 1.42'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-salesforce-ultimate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Herculano Chaves
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.42'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.42'
|
55
|
+
description: OmniAuth strategy for salesforce.com. Addapted to work with Oauth 2.0.
|
56
|
+
email:
|
57
|
+
- herculanoweb@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rubocop.yml"
|
64
|
+
- ".tool-versions"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/omniauth-salesforce-ultimate.rb
|
69
|
+
- lib/omniauth/salesforce/version.rb
|
70
|
+
- lib/omniauth/strategies/salesforce.rb
|
71
|
+
- omniauth-salesforce-ultimate.gemspec
|
72
|
+
homepage: https://github.com/herculano-ch/omniauth-salesforce
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '2.2'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubygems_version: 3.3.7
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: OmniAuth strategy for salesforce.com.
|
95
|
+
test_files: []
|