discourse_api 0.48.0 → 1.1.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/.github/workflows/ci.yml +8 -9
- data/CHANGELOG.md +17 -4
- data/discourse_api.gemspec +2 -2
- data/lib/discourse_api/single_sign_on.rb +46 -9
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/sso_spec.rb +4 -4
- data/spec/discourse_api/single_sign_on_spec.rb +43 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b3a4fa6e58bafa87e83cc91ac1d064ad4a28d5a16b333348e69e5e34616656a
|
4
|
+
data.tar.gz: bf82b1cdfb447f2233166d7dced4fdcbd79c7aecbdb1e1831a4df4fa085fbdbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3852fbddac9d6fd014683731c3d86fdebb29c2805729a0c82802362c7e0cd6a1904be8b63a514ef26520f23864b2540eae3e78f9a40bf8cf2f6d8f097bc145ff
|
7
|
+
data.tar.gz: b264bbe0726bc891188318f680425e7512a66ce7e87c5a7d41e4a3010b0c528acae122c3299e687728ec4ea4d0fb24c42802bf73eb1f3b60c3d70b6c1375b008
|
data/.github/workflows/ci.yml
CHANGED
@@ -4,7 +4,6 @@ on:
|
|
4
4
|
pull_request:
|
5
5
|
push:
|
6
6
|
branches:
|
7
|
-
- master
|
8
7
|
- main
|
9
8
|
|
10
9
|
jobs:
|
@@ -14,13 +13,13 @@ jobs:
|
|
14
13
|
strategy:
|
15
14
|
matrix:
|
16
15
|
ruby:
|
17
|
-
- 2.
|
18
|
-
- 2.
|
19
|
-
-
|
20
|
-
- 3.
|
16
|
+
- '2.6'
|
17
|
+
- '2.7'
|
18
|
+
- '3.0'
|
19
|
+
- '3.1'
|
21
20
|
|
22
21
|
steps:
|
23
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v3
|
24
23
|
|
25
24
|
- name: Setup ruby
|
26
25
|
uses: ruby/setup-ruby@v1
|
@@ -35,15 +34,15 @@ jobs:
|
|
35
34
|
run: bundle exec rake test
|
36
35
|
|
37
36
|
publish:
|
38
|
-
if: github.event_name == 'push' &&
|
37
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
39
38
|
needs: build
|
40
39
|
runs-on: ubuntu-latest
|
41
40
|
|
42
41
|
steps:
|
43
|
-
- uses: actions/checkout@
|
42
|
+
- uses: actions/checkout@v3
|
44
43
|
|
45
44
|
- name: Release Gem
|
46
|
-
uses: discourse/publish-rubygems-action@v2
|
45
|
+
uses: discourse/publish-rubygems-action@v2
|
47
46
|
env:
|
48
47
|
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
49
48
|
GIT_EMAIL: team@discourse.org
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.1.0] - 2022-07-05
|
10
|
+
### Changed
|
11
|
+
- `DiscourseApi::SingleSignOn.parse` now raises `DiscourseApi::SingleSignOn::ParseError` (inherits from `RuntimeError` to preserve backward compatibility) instead of `RuntimeError` when there's a signature mismatch.
|
12
|
+
- `DiscourseApi::SingleSignOn.parse` now raises `DiscourseApi::SingleSignOn::MissingConfigError` (also inherits from `RuntimeError`) if `sso_secret` or `sso_url` are missing.
|
13
|
+
|
14
|
+
## [1.0.0] - 2022-05-01
|
15
|
+
### Changed
|
16
|
+
- The package now requires ruby 2.6+
|
17
|
+
|
18
|
+
## [0.48.1] - 2022-04-13
|
19
|
+
### Added
|
20
|
+
- New attributes for Discourse Connect (aka SSO)
|
21
|
+
|
9
22
|
## [0.48.0] - 2022-01-28
|
10
23
|
### Added
|
11
24
|
- `group_add_owners` method (#239)
|
@@ -61,7 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
61
74
|
|
62
75
|
## [0.43.1] - 2020-11-04
|
63
76
|
### Fixed
|
64
|
-
- Tagged version 0.43.0 got pushed without
|
77
|
+
- Tagged version 0.43.0 got pushed without commit due to new master branch
|
65
78
|
protections in github. No, code changes here just making sure tags align with
|
66
79
|
commits.
|
67
80
|
|
@@ -114,7 +127,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
114
127
|
## [0.38.0] - 2019-10-18
|
115
128
|
### Added
|
116
129
|
- Allow setting locale in SingleSignOn
|
117
|
-
- Optional param to group
|
130
|
+
- Optional param to group members to include owners as well as members
|
118
131
|
|
119
132
|
## [0.37.0] - 2019-09-23
|
120
133
|
### Added
|
@@ -127,7 +140,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
127
140
|
- Added poll methods
|
128
141
|
### Fixed
|
129
142
|
- Updated create topic example
|
130
|
-
- Fixed
|
143
|
+
- Fixed capitalization for header auth keys
|
131
144
|
|
132
145
|
## [0.35.0] - 2019-05-15
|
133
146
|
### Added
|
@@ -289,7 +302,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
289
302
|
- group_members: Allows you to retrieve more than 100 users with pagination (offset &
|
290
303
|
limit)
|
291
304
|
### Fixed
|
292
|
-
-
|
305
|
+
- Deprecation warning with SimpleCov
|
293
306
|
- updated rack dependency and added ruby 2.3 to travis config
|
294
307
|
|
295
308
|
## [0.9.1] - 2016-03-23
|
data/discourse_api.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'rspec', '~> 3.4'
|
31
31
|
spec.add_development_dependency 'simplecov', '~> 0.11'
|
32
32
|
spec.add_development_dependency 'webmock', '~> 3.0'
|
33
|
-
spec.add_development_dependency 'rubocop-discourse', '~> 2.
|
33
|
+
spec.add_development_dependency 'rubocop-discourse', '~> 2.5.0'
|
34
34
|
|
35
|
-
spec.required_ruby_version = '>= 2.
|
35
|
+
spec.required_ruby_version = '>= 2.6.0'
|
36
36
|
end
|
@@ -5,12 +5,49 @@ require 'openssl'
|
|
5
5
|
|
6
6
|
module DiscourseApi
|
7
7
|
class SingleSignOn
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
class ParseError < RuntimeError; end
|
9
|
+
class MissingConfigError < RuntimeError; end
|
10
|
+
|
11
|
+
ACCESSORS = [
|
12
|
+
:add_groups,
|
13
|
+
:admin,
|
14
|
+
:avatar_force_update,
|
15
|
+
:avatar_url,
|
16
|
+
:bio,
|
17
|
+
:card_background_url,
|
18
|
+
:confirmed_2fa,
|
19
|
+
:email,
|
20
|
+
:external_id,
|
21
|
+
:groups,
|
22
|
+
:locale,
|
23
|
+
:locale_force_update,
|
24
|
+
:moderator,
|
25
|
+
:name,
|
26
|
+
:no_2fa_methods,
|
27
|
+
:nonce,
|
28
|
+
:profile_background_url,
|
29
|
+
:remove_groups,
|
30
|
+
:require_2fa,
|
31
|
+
:require_activation,
|
32
|
+
:return_sso_url,
|
33
|
+
:suppress_welcome_message,
|
34
|
+
:title,
|
35
|
+
:username,
|
36
|
+
]
|
37
|
+
|
11
38
|
FIXNUMS = []
|
12
|
-
|
13
|
-
|
39
|
+
|
40
|
+
BOOLS = [
|
41
|
+
:admin,
|
42
|
+
:avatar_force_update,
|
43
|
+
:confirmed_2fa,
|
44
|
+
:locale_force_update,
|
45
|
+
:moderator,
|
46
|
+
:no_2fa_methods,
|
47
|
+
:require_2fa,
|
48
|
+
:require_activation,
|
49
|
+
:suppress_welcome_message,
|
50
|
+
]
|
14
51
|
ARRAYS = [:groups]
|
15
52
|
#NONCE_EXPIRY_TIME = 10.minutes # minutes is a rails method and is causing an error. Is this needed in the api?
|
16
53
|
|
@@ -18,11 +55,11 @@ module DiscourseApi
|
|
18
55
|
attr_writer :custom_fields, :sso_secret, :sso_url
|
19
56
|
|
20
57
|
def self.sso_secret
|
21
|
-
raise
|
58
|
+
raise MissingConfigError, "sso_secret not implemented on class, be sure to set it on instance"
|
22
59
|
end
|
23
60
|
|
24
61
|
def self.sso_url
|
25
|
-
raise
|
62
|
+
raise MissingConfigError, "sso_url not implemented on class, be sure to set it on instance"
|
26
63
|
end
|
27
64
|
|
28
65
|
def self.parse_hash(payload)
|
@@ -64,9 +101,9 @@ module DiscourseApi
|
|
64
101
|
if sso.sign(parsed["sso"]) != parsed["sig"]
|
65
102
|
diags = "\n\nsso: #{parsed["sso"]}\n\nsig: #{parsed["sig"]}\n\nexpected sig: #{sso.sign(parsed["sso"])}"
|
66
103
|
if parsed["sso"] =~ /[^a-zA-Z0-9=\r\n\/+]/m
|
67
|
-
raise
|
104
|
+
raise ParseError, "The SSO field should be Base64 encoded, using only A-Z, a-z, 0-9, +, /, and = characters. Your input contains characters we don't understand as Base64, see http://en.wikipedia.org/wiki/Base64 #{diags}"
|
68
105
|
else
|
69
|
-
raise
|
106
|
+
raise ParseError, "Bad signature for payload #{diags}"
|
70
107
|
end
|
71
108
|
end
|
72
109
|
|
@@ -27,10 +27,10 @@ describe DiscourseApi::API::SSO do
|
|
27
27
|
}
|
28
28
|
end
|
29
29
|
let(:expected_unsigned_payload) do
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'&
|
33
|
-
'custom.custom.field_1=tomato'
|
30
|
+
'add_groups=a&add_groups=b&avatar_url=https%3A%2F%2Fwww.website.com'\
|
31
|
+
'&email=some%40email.com&external_id=abc&name=Some+User&remove_groups=c'\
|
32
|
+
'&remove_groups=d&title=ruby&username=some_user&custom.field_2=potato'\
|
33
|
+
'&custom.custom.field_1=tomato'
|
34
34
|
end
|
35
35
|
let(:sso_double) { DiscourseApi::SingleSignOn.parse_hash(params) }
|
36
36
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe DiscourseApi::SingleSignOn do
|
6
|
+
context "::MissingConfigError" do
|
7
|
+
it "inherits from RuntimeError for backward compatibility" do
|
8
|
+
expect(DiscourseApi::SingleSignOn::MissingConfigError).to be < RuntimeError
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "::ParseError" do
|
13
|
+
it "inherits from RuntimeError for backward compatibility" do
|
14
|
+
expect(DiscourseApi::SingleSignOn::ParseError).to be < RuntimeError
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context ".sso_secret" do
|
19
|
+
it "raises MissingConfigError when sso_secret is not present" do
|
20
|
+
expect {
|
21
|
+
described_class.sso_secret
|
22
|
+
}.to raise_error(DiscourseApi::SingleSignOn::MissingConfigError)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context ".sso_url" do
|
27
|
+
it "raises MissingConfigError when sso_url is not present" do
|
28
|
+
expect {
|
29
|
+
described_class.sso_url
|
30
|
+
}.to raise_error(DiscourseApi::SingleSignOn::MissingConfigError)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context ".parse" do
|
35
|
+
it "raises ParseError when there's a signature mismatch" do
|
36
|
+
sso = described_class.new
|
37
|
+
sso.sso_secret = "abcd"
|
38
|
+
expect {
|
39
|
+
described_class.parse(sso.payload, "dcba")
|
40
|
+
}.to raise_error(DiscourseApi::SingleSignOn::ParseError)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-
|
14
|
+
date: 2022-07-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -173,14 +173,14 @@ dependencies:
|
|
173
173
|
requirements:
|
174
174
|
- - "~>"
|
175
175
|
- !ruby/object:Gem::Version
|
176
|
-
version: 2.
|
176
|
+
version: 2.5.0
|
177
177
|
type: :development
|
178
178
|
prerelease: false
|
179
179
|
version_requirements: !ruby/object:Gem::Requirement
|
180
180
|
requirements:
|
181
181
|
- - "~>"
|
182
182
|
- !ruby/object:Gem::Version
|
183
|
-
version: 2.
|
183
|
+
version: 2.5.0
|
184
184
|
description: Discourse API
|
185
185
|
email:
|
186
186
|
- sam.saffron@gmail.com
|
@@ -274,6 +274,7 @@ files:
|
|
274
274
|
- spec/discourse_api/api/user_actions_spec.rb
|
275
275
|
- spec/discourse_api/api/users_spec.rb
|
276
276
|
- spec/discourse_api/client_spec.rb
|
277
|
+
- spec/discourse_api/single_sign_on_spec.rb
|
277
278
|
- spec/fixtures/admin_user.json
|
278
279
|
- spec/fixtures/api_key.json
|
279
280
|
- spec/fixtures/backups.json
|
@@ -340,7 +341,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
340
341
|
requirements:
|
341
342
|
- - ">="
|
342
343
|
- !ruby/object:Gem::Version
|
343
|
-
version: 2.
|
344
|
+
version: 2.6.0
|
344
345
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
345
346
|
requirements:
|
346
347
|
- - ">="
|
@@ -372,6 +373,7 @@ test_files:
|
|
372
373
|
- spec/discourse_api/api/user_actions_spec.rb
|
373
374
|
- spec/discourse_api/api/users_spec.rb
|
374
375
|
- spec/discourse_api/client_spec.rb
|
376
|
+
- spec/discourse_api/single_sign_on_spec.rb
|
375
377
|
- spec/fixtures/admin_user.json
|
376
378
|
- spec/fixtures/api_key.json
|
377
379
|
- spec/fixtures/backups.json
|