audiences 1.2.2 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/audiences/contexts_controller.rb +1 -1
- data/app/controllers/audiences/scim_proxy_controller.rb +1 -1
- data/app/models/audiences/context_users.rb +2 -2
- data/app/models/audiences/criterion_users.rb +2 -2
- data/app/models/audiences/external_user.rb +7 -0
- data/docs/CHANGELOG.md +9 -0
- data/lib/audiences/configuration.rb +2 -1
- data/lib/audiences/scim/resource.rb +16 -2
- data/lib/audiences/version.rb +1 -1
- data/lib/audiences.rb +3 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 319c6d5a55900512c509f3e27ac9e03489734e0a618c31414cb7cd57981fc916
|
4
|
+
data.tar.gz: 2a117b18cd56209481ead18fafccb7ba9b57b673b5cdfa5c0f03152184704e25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d08f9b199ae6ca61caeaff91606bb4a9cf21a171f17486a2919631a7b791ad37995a9645527199704d6ec8eb24ca4a1fba8543829dbd97f47c73174c9ba766f5
|
7
|
+
data.tar.gz: b1d6cc6305467c94bddb4abab023e451de05e2d9177f19c0a358da81429c6930c8381a6066afa6703f1826f4f6e0cb2bd5afed94a0cbba97c3816325b540e29b
|
@@ -4,7 +4,7 @@ module Audiences
|
|
4
4
|
class ScimProxyController < ApplicationController
|
5
5
|
def get
|
6
6
|
resources = Audiences::Scim.resource(params[:scim_path].to_sym)
|
7
|
-
.query(filter: params[:filter])
|
7
|
+
.query(filter: params[:filter], startIndex: params[:startIndex], count: params[:count])
|
8
8
|
|
9
9
|
render json: resources, except: %w[schemas meta]
|
10
10
|
end
|
@@ -21,8 +21,8 @@ module Audiences
|
|
21
21
|
|
22
22
|
def groups_users(group_ids)
|
23
23
|
filter = group_ids.map { "groups.value eq #{_1}" }.join(" OR ")
|
24
|
-
users = Audiences::Scim.resource(:Users).
|
25
|
-
ExternalUser.wrap(users
|
24
|
+
users = Audiences::Scim.resource(:Users).all(filter: filter)
|
25
|
+
ExternalUser.wrap(users)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -10,6 +10,13 @@ module Audiences
|
|
10
10
|
inverse_of: false
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.fetch(external_ids)
|
14
|
+
return [] unless external_ids.any?
|
15
|
+
|
16
|
+
filter = Array(external_ids).map { "externalId eq #{_1}" }.join(" OR ")
|
17
|
+
Audiences::Scim.resource(:Users).all(filter: filter)
|
18
|
+
end
|
19
|
+
|
13
20
|
def self.wrap(resources)
|
14
21
|
return [] unless resources&.any?
|
15
22
|
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# Version 1.3.1 (2024-10-11)
|
4
|
+
|
5
|
+
- Forward pagination parameters to SCIM on proxy [#397](https://github.com/powerhome/audiences/pull/397)
|
6
|
+
- Fix security flaw when setting extra users [#398](https://github.com/powerhome/audiences/pull/398)
|
7
|
+
|
8
|
+
# Version 1.3.0 (2024-09-03)
|
9
|
+
|
10
|
+
- Filter out inactive users by default [#382](https://github.com/powerhome/audiences/pull/382)
|
11
|
+
|
3
12
|
# Version 1.2.2 (2024-08-21)
|
4
13
|
|
5
14
|
- Permit configured resource attributes [#375](https://github.com/powerhome/audiences/pull/375)
|
@@ -46,7 +46,8 @@ module Audiences
|
|
46
46
|
# @see `resource`.
|
47
47
|
#
|
48
48
|
config_accessor :resources do
|
49
|
-
{ Users: Scim::Resource.new(type: :Users, attributes: ["photos" => %w[type value]
|
49
|
+
{ Users: Scim::Resource.new(type: :Users, attributes: ["active", { "photos" => %w[type value] }],
|
50
|
+
filter: "active eq true") }
|
50
51
|
end
|
51
52
|
|
52
53
|
#
|
@@ -3,20 +3,27 @@
|
|
3
3
|
module Audiences
|
4
4
|
module Scim
|
5
5
|
class Resource
|
6
|
-
attr_accessor :options, :type, :attributes
|
6
|
+
attr_accessor :options, :type, :attributes, :filter
|
7
7
|
|
8
|
-
def initialize(type:, attributes: [], **options)
|
8
|
+
def initialize(type:, attributes: [], filter: nil, **options)
|
9
9
|
@type = type
|
10
10
|
@options = options
|
11
11
|
@attributes = ["id", "externalId", "displayName", *attributes]
|
12
|
+
@filter = filter
|
12
13
|
end
|
13
14
|
|
14
15
|
def query(**options)
|
16
|
+
options_filter = options.delete(:filter)
|
15
17
|
ResourcesQuery.new(Scim.client, resource: self,
|
16
18
|
attributes: scim_attributes,
|
19
|
+
filter: merged_filter(options_filter),
|
17
20
|
**@options, **options)
|
18
21
|
end
|
19
22
|
|
23
|
+
def all(...)
|
24
|
+
query(...).all
|
25
|
+
end
|
26
|
+
|
20
27
|
def scim_attributes
|
21
28
|
@attributes.reduce([]) do |attrs, attr|
|
22
29
|
case attr
|
@@ -29,6 +36,13 @@ module Audiences
|
|
29
36
|
end
|
30
37
|
end.join(",")
|
31
38
|
end
|
39
|
+
|
40
|
+
def merged_filter(filter)
|
41
|
+
return @filter unless filter
|
42
|
+
return filter unless @filter
|
43
|
+
|
44
|
+
"(#{@filter}) and (#{filter})"
|
45
|
+
end
|
32
46
|
end
|
33
47
|
end
|
34
48
|
end
|
data/lib/audiences/version.rb
CHANGED
data/lib/audiences.rb
CHANGED
@@ -23,11 +23,12 @@ module_function
|
|
23
23
|
# @param params [Hash] the updated params
|
24
24
|
# @return Audience::Context
|
25
25
|
#
|
26
|
-
def update(key, criteria: [],
|
26
|
+
def update(key, criteria: [], extra_users: [], match_all: false)
|
27
27
|
Audiences::Context.load(key) do |context|
|
28
28
|
context.update!(
|
29
|
+
match_all: match_all,
|
29
30
|
criteria: ::Audiences::Criterion.map(criteria),
|
30
|
-
|
31
|
+
extra_users: ::Audiences::ExternalUser.fetch(extra_users.pluck("externalId"))
|
31
32
|
)
|
32
33
|
context.refresh_users!
|
33
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: audiences
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Palhares
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.5.
|
96
|
+
rubygems_version: 3.5.16
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Audiences system
|