openstax_salesforce 8.3.0 → 9.0.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 +4 -4
- data/README.md +14 -3
- data/config/initializers/openstax_salesforce.rb +9 -4
- data/lib/openstax/salesforce/client.rb +15 -4
- data/lib/openstax/salesforce/version.rb +1 -1
- data/lib/openstax_salesforce.rb +36 -3
- metadata +11 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2df3568d0d57428c97b0eff64ce15be14c9e16912bf756fcc9ed937a88e18ac2
|
|
4
|
+
data.tar.gz: 1c8571197d7287c9d1d20c8e96044215c18884761b81fb96071c53839b3c0713
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9f27f8ac4bda5075dfb9d4f048ab0c29e930cea5dd13f4ecbf5776bb58e85e66152a79c41ccd476cdad6636c8eaca4b24eb7ad35c2e0d1bc1734406cfca0f44
|
|
7
|
+
data.tar.gz: 7fbb3be31886114129e888d45d7f0dff61f00f037c55fb0af7af50c809641133ee89c8249d6d83f18435623707a4a27a8a5fe12a56ba924ca4507ad4f6dcc67c
|
data/README.md
CHANGED
|
@@ -38,13 +38,24 @@ After installation, the initializer for OpenStax::Salesforce will be located und
|
|
|
38
38
|
`config/initializers/openstax_salesforce.rb`. Make sure to configure it to suit your needs.
|
|
39
39
|
|
|
40
40
|
You will need the following information from Salesforce:
|
|
41
|
-
- Your username (append .sandboxname if using a sandbox)
|
|
42
|
-
- Your password
|
|
43
|
-
- Your security token
|
|
44
41
|
- Connected App's client key
|
|
45
42
|
- Connected App's client secret
|
|
43
|
+
- Your org's My Domain login domain (e.g. `openstax.my.salesforce.com`, or
|
|
44
|
+
`openstax--sandboxname.sandbox.my.salesforce.com` for a sandbox)
|
|
46
45
|
Enter all the above information in the initializer, secrets.yml or environment variables.
|
|
47
46
|
|
|
47
|
+
This uses the OAuth 2.0 client credentials flow. In Salesforce, the Connected App
|
|
48
|
+
needs "Enable Client Credentials Flow" checked and a **Run As** user set under
|
|
49
|
+
OAuth Policies — every object and field this gem touches must be readable and
|
|
50
|
+
writable by that user. Requests to `login.salesforce.com` and `test.salesforce.com`
|
|
51
|
+
are not supported by this flow, which is why the login domain must be My Domain.
|
|
52
|
+
|
|
53
|
+
### Username-password flow (deprecated)
|
|
54
|
+
|
|
55
|
+
Also setting `username`, `password` and `security_token` switches back to the OAuth
|
|
56
|
+
username-password flow. Salesforce stops supporting it in Spring '27, so this exists
|
|
57
|
+
only to let apps migrate one at a time. Leave the username unset for new setups.
|
|
58
|
+
|
|
48
59
|
## Testing
|
|
49
60
|
|
|
50
61
|
From the gem's main folder, run `bundle install` and then `bundle exec rake` to run all the specs.
|
|
@@ -9,13 +9,18 @@ OpenStax::Salesforce.configure do |config|
|
|
|
9
9
|
raise "Add a `salesforce` section to your Rails secrets!"
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
#
|
|
12
|
+
# Connected App credentials for the OAuth client credentials flow. The login
|
|
13
|
+
# domain must be the org's My Domain; Salesforce rejects this flow at
|
|
14
|
+
# login.salesforce.com and test.salesforce.com.
|
|
15
|
+
config.consumer_key = salesforce_secrets[:consumer_key]
|
|
16
|
+
config.consumer_secret = salesforce_secrets[:consumer_secret]
|
|
17
|
+
|
|
18
|
+
# Setting these switches back to the username-password flow, which Salesforce
|
|
19
|
+
# stops supporting in Spring '27. See the README.
|
|
13
20
|
config.username = salesforce_secrets[:username]
|
|
14
21
|
config.password = salesforce_secrets[:password]
|
|
15
22
|
config.security_token = salesforce_secrets[:security_token]
|
|
16
|
-
config.consumer_key = salesforce_secrets[:consumer_key]
|
|
17
|
-
config.consumer_secret = salesforce_secrets[:consumer_secret]
|
|
18
23
|
|
|
19
|
-
config.api_version = salesforce_secrets.fetch :api_version, '
|
|
24
|
+
config.api_version = salesforce_secrets.fetch :api_version, '61.0'
|
|
20
25
|
config.login_domain = salesforce_secrets.fetch :login_domain, 'test.salesforce.com'
|
|
21
26
|
end
|
|
@@ -7,14 +7,25 @@ module OpenStax
|
|
|
7
7
|
|
|
8
8
|
configuration.validate!
|
|
9
9
|
|
|
10
|
+
# Restforce picks its auth middleware from whichever options are present, and
|
|
11
|
+
# a username/password pair wins over client credentials.
|
|
12
|
+
legacy_options =
|
|
13
|
+
if configuration.username_password_flow?
|
|
14
|
+
{
|
|
15
|
+
username: configuration.username,
|
|
16
|
+
password: configuration.password,
|
|
17
|
+
security_token: configuration.security_token
|
|
18
|
+
}
|
|
19
|
+
else
|
|
20
|
+
{}
|
|
21
|
+
end
|
|
22
|
+
|
|
10
23
|
super(
|
|
11
|
-
username: configuration.username,
|
|
12
|
-
password: configuration.password,
|
|
13
|
-
security_token: configuration.security_token,
|
|
14
24
|
client_id: configuration.consumer_key,
|
|
15
25
|
client_secret: configuration.consumer_secret,
|
|
16
26
|
api_version: configuration.api_version,
|
|
17
|
-
host: configuration.login_domain
|
|
27
|
+
host: configuration.login_domain,
|
|
28
|
+
**legacy_options
|
|
18
29
|
)
|
|
19
30
|
end
|
|
20
31
|
end
|
data/lib/openstax_salesforce.rb
CHANGED
|
@@ -19,6 +19,9 @@ require "openstax/salesforce/remote/campaign_member"
|
|
|
19
19
|
require "openstax/salesforce/remote/account_contact_relation"
|
|
20
20
|
require "openstax/salesforce/remote/openstax_account"
|
|
21
21
|
|
|
22
|
+
# openstax_utilities defines this too, but this gem doesn't depend on it
|
|
23
|
+
class IllegalState < StandardError; end unless defined?(IllegalState)
|
|
24
|
+
|
|
22
25
|
module OpenStax
|
|
23
26
|
module Salesforce
|
|
24
27
|
def self.configure
|
|
@@ -31,6 +34,9 @@ module OpenStax
|
|
|
31
34
|
|
|
32
35
|
# See `config/initializers/openstax_salesforce.rb` for documentation on options
|
|
33
36
|
class Configuration
|
|
37
|
+
# Salesforce rejects client credentials token requests sent to these
|
|
38
|
+
GENERIC_LOGIN_DOMAINS = %w[login.salesforce.com test.salesforce.com].freeze
|
|
39
|
+
|
|
34
40
|
attr_writer :api_version, :login_domain
|
|
35
41
|
attr_accessor :username, :password, :security_token, :consumer_key, :consumer_secret
|
|
36
42
|
|
|
@@ -42,12 +48,39 @@ module OpenStax
|
|
|
42
48
|
@login_domain ||= 'test.salesforce.com'
|
|
43
49
|
end
|
|
44
50
|
|
|
51
|
+
# Salesforce retires the OAuth username-password flow in Spring '27, so a
|
|
52
|
+
# username is now optional: leave it unset to use client credentials.
|
|
53
|
+
def username_password_flow?
|
|
54
|
+
!username.nil?
|
|
55
|
+
end
|
|
56
|
+
|
|
45
57
|
def validate!
|
|
46
|
-
raise(IllegalState, "The Salesforce username is missing") if username.nil?
|
|
47
|
-
raise(IllegalState, "The Salesforce password is missing") if password.nil?
|
|
48
|
-
raise(IllegalState, "The Salesforce security token is missing") if security_token.nil?
|
|
49
58
|
raise(IllegalState, "The Salesforce consumer key is missing") if consumer_key.nil?
|
|
50
59
|
raise(IllegalState, "The Salesforce consumer secret is missing") if consumer_secret.nil?
|
|
60
|
+
|
|
61
|
+
if username_password_flow?
|
|
62
|
+
raise(IllegalState, "The Salesforce password is missing") if password.nil?
|
|
63
|
+
raise(IllegalState, "The Salesforce security token is missing") if security_token.nil?
|
|
64
|
+
return
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Half-removed credentials would otherwise switch flows silently
|
|
68
|
+
unless password.nil? && security_token.nil?
|
|
69
|
+
raise(
|
|
70
|
+
IllegalState,
|
|
71
|
+
"The Salesforce password and security token only apply to the username-password " \
|
|
72
|
+
"flow. Remove them to use client credentials, or set a username to keep using " \
|
|
73
|
+
"the username-password flow."
|
|
74
|
+
)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if GENERIC_LOGIN_DOMAINS.include?(login_domain)
|
|
78
|
+
raise(
|
|
79
|
+
IllegalState,
|
|
80
|
+
"The Salesforce client credentials flow requires the org's My Domain as the " \
|
|
81
|
+
"login domain (e.g. myorg.my.salesforce.com), not #{login_domain}"
|
|
82
|
+
)
|
|
83
|
+
end
|
|
51
84
|
end
|
|
52
85
|
end
|
|
53
86
|
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openstax_salesforce
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 9.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- JP Slavinsky
|
|
8
8
|
- Dante Soares
|
|
9
9
|
- Michael Volo
|
|
10
|
-
autorequire:
|
|
10
|
+
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2026-
|
|
13
|
+
date: 2026-08-17 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rails
|
|
@@ -18,34 +18,28 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - ">="
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: '
|
|
22
|
-
- - "<"
|
|
23
|
-
- !ruby/object:Gem::Version
|
|
24
|
-
version: '7.0'
|
|
21
|
+
version: '6.1'
|
|
25
22
|
type: :runtime
|
|
26
23
|
prerelease: false
|
|
27
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
28
25
|
requirements:
|
|
29
26
|
- - ">="
|
|
30
27
|
- !ruby/object:Gem::Version
|
|
31
|
-
version: '
|
|
32
|
-
- - "<"
|
|
33
|
-
- !ruby/object:Gem::Version
|
|
34
|
-
version: '7.0'
|
|
28
|
+
version: '6.1'
|
|
35
29
|
- !ruby/object:Gem::Dependency
|
|
36
30
|
name: restforce
|
|
37
31
|
requirement: !ruby/object:Gem::Requirement
|
|
38
32
|
requirements:
|
|
39
33
|
- - ">="
|
|
40
34
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '
|
|
35
|
+
version: '7.1'
|
|
42
36
|
type: :runtime
|
|
43
37
|
prerelease: false
|
|
44
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
45
39
|
requirements:
|
|
46
40
|
- - ">="
|
|
47
41
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '
|
|
42
|
+
version: '7.1'
|
|
49
43
|
- !ruby/object:Gem::Dependency
|
|
50
44
|
name: openstax_active_force
|
|
51
45
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -180,7 +174,7 @@ homepage: https://github.com/openstax/openstax_salesforce
|
|
|
180
174
|
licenses:
|
|
181
175
|
- MIT
|
|
182
176
|
metadata: {}
|
|
183
|
-
post_install_message:
|
|
177
|
+
post_install_message:
|
|
184
178
|
rdoc_options: []
|
|
185
179
|
require_paths:
|
|
186
180
|
- lib
|
|
@@ -188,15 +182,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
188
182
|
requirements:
|
|
189
183
|
- - ">="
|
|
190
184
|
- !ruby/object:Gem::Version
|
|
191
|
-
version: '0'
|
|
185
|
+
version: '3.0'
|
|
192
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
187
|
requirements:
|
|
194
188
|
- - ">="
|
|
195
189
|
- !ruby/object:Gem::Version
|
|
196
190
|
version: '0'
|
|
197
191
|
requirements: []
|
|
198
|
-
rubygems_version: 3.
|
|
199
|
-
signing_key:
|
|
192
|
+
rubygems_version: 3.3.27
|
|
193
|
+
signing_key:
|
|
200
194
|
specification_version: 4
|
|
201
195
|
summary: Interface gem for accessing OpenStax's Salesforce instance
|
|
202
196
|
test_files: []
|