audiences 1.2.0 → 1.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a764dbb90f7727e7b0054227fedb0d8eee691ab7e65a5c0007413121de492965
4
- data.tar.gz: f4c0fc7843aae456f8df4e2aed78615fc3169257cdebe9a28578443ad32c0949
3
+ metadata.gz: 60a415497f4cea4f99f5581c92559b60e137f5cf54b3d57267cbd3ead22a72d0
4
+ data.tar.gz: 1039307cacefbf390c9cfd94d7eb6a31dc4c9ed1ed27290429c3a5045f1a9b86
5
5
  SHA512:
6
- metadata.gz: 4b04b83f5314e11bdd03d373632683bfe59e39eb2ded010c8b49ccbaf914904f4a05dc9788589488a670ae168df19293a175bc9ade59044568d0f27b8e1769d1
7
- data.tar.gz: a4abbd7408fceb3cc6349000003cddc78ceb564f2824d93dfbb27e340373603dc6cb9c844136954a95e12a374e1439216cd0d202cb75c6dd8b4feb9f91441545
6
+ metadata.gz: 1a45b7985d7c8e8ee3a8d0c224b254a61a599af150947f3f6b6ebc06eea0157415f9a1e50e21e33dc6121cd7421759c2107d5d70b61f57e4055b0d2d73523541
7
+ data.tar.gz: 91bcdc28abc2a07481a5f3f7b77ad8a7f3765c140e4afc2e248e856333537b2502a91ea7f8243f1a02ceb8857e3c6487bbc00667f82ce1616e32a817cda3fc11
@@ -44,7 +44,7 @@ module Audiences
44
44
  params.permit(
45
45
  :match_all,
46
46
  criteria: [groups: {}],
47
- extra_users: [:externalId, :displayName, { photos: %i[type value] }]
47
+ extra_users: Audiences.config.resources[:Users].attributes
48
48
  ).to_h.symbolize_keys
49
49
  end
50
50
  end
@@ -6,7 +6,7 @@ module Audiences
6
6
  resources = Audiences::Scim.resource(params[:scim_path].to_sym)
7
7
  .query(filter: params[:filter])
8
8
 
9
- render json: resources
9
+ render json: resources, except: %w[schemas meta]
10
10
  end
11
11
  end
12
12
  end
data/config/routes.rb CHANGED
@@ -10,10 +10,10 @@ end
10
10
  Rails.application.routes.draw do
11
11
  direct :audience_context do |owner, relation = nil|
12
12
  context = Audiences::Context.for(owner, relation: relation)
13
- Audiences::Engine.routes.url_helpers.route_for(:signed_context, key: context.signed_key, **url_options)
13
+ audiences.route_for(:signed_context, key: context.signed_key, **url_options)
14
14
  end
15
15
 
16
16
  direct :audience_scim_proxy do |options|
17
- Audiences::Engine.routes.url_helpers.route_for(:scim_proxy, **url_options, **options)
17
+ audiences.route_for(:scim_proxy, **url_options, **options)
18
18
  end
19
19
  end
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Unreleased
2
2
 
3
+ # Version 1.2.2 (2024-08-21)
4
+
5
+ - Permit configured resource attributes [#375](https://github.com/powerhome/audiences/pull/375)
6
+
7
+ # Version 1.2.1 (2024-08-06)
8
+
9
+ - Fix audiences URL helpers [#372](https://github.com/powerhome/audiences/pull/372)
10
+
3
11
  # Version 1.2.0 (2024-07-24)
4
12
 
5
13
  - Add `has_audience` and the ability to attach multiple audiences to the same owner [#363](https://github.com/powerhome/audiences/pull/363)
data/docs/README.md CHANGED
@@ -103,12 +103,12 @@ See a working example in our dummy app:
103
103
 
104
104
  ### SCIM Resource Attributes
105
105
 
106
- Configure which attributes are requested from the SCIM backend for each resource type. `Audiences` requires at least `id` and `displayName`, and also requests `photos` and `externalId` for users by default. To request additional attributes:
106
+ Configure which attributes are requested from the SCIM backend for each resource type. `Audiences` includes `id`, `externalId`, and `displayName` by default in every resource type. It also requests `photos.type` and `photos.value` for users by default. To request additional attributes:
107
107
 
108
108
  ```ruby
109
109
  Audiences.configure do |config|
110
- config.resource :Users, attributes: "id,externalId,displayName,photos,name"
111
- config.resource :Groups, attributes: "id,displayName,mfaRequired"
110
+ config.resource :Users, attributes: ["name" => %w[givenName familyName formatted]]
111
+ config.resource :Groups, attributes: %w[mfaRequired]
112
112
  end
113
113
  ```
114
114
 
@@ -46,7 +46,7 @@ module Audiences
46
46
  # @see `resource`.
47
47
  #
48
48
  config_accessor :resources do
49
- { Users: Scim::Resource.new(type: :Users, attributes: "id,externalId,displayName,photos") }
49
+ { Users: Scim::Resource.new(type: :Users, attributes: ["photos" => %w[type value]]) }
50
50
  end
51
51
 
52
52
  #
@@ -55,8 +55,8 @@ module Audiences
55
55
  # @param type [Symbol] the resource type in plural, as in scim (i.e.: :Users)
56
56
  # @param attributes [String] the list of attributes to fetch for the resource (i.e.: "id,externalId,displayName")
57
57
  # @see [Audiences::Scim::Resource]
58
- def config.resource(type:, **kwargs)
59
- config.resources[type] = Scim::Resource.new(type: type, **kwargs)
58
+ def config.resource(type, **kwargs)
59
+ resources[type] = Scim::Resource.new(type: type, **kwargs)
60
60
  end
61
61
 
62
62
  #
@@ -3,16 +3,31 @@
3
3
  module Audiences
4
4
  module Scim
5
5
  class Resource
6
- attr_accessor :options, :type
6
+ attr_accessor :options, :type, :attributes
7
7
 
8
- def initialize(type:, attributes: "id,externalId,displayName", **options)
8
+ def initialize(type:, attributes: [], **options)
9
9
  @type = type
10
10
  @options = options
11
- @options[:attributes] = attributes
11
+ @attributes = ["id", "externalId", "displayName", *attributes]
12
12
  end
13
13
 
14
14
  def query(**options)
15
- ResourcesQuery.new(Scim.client, resource: self, **@options, **options)
15
+ ResourcesQuery.new(Scim.client, resource: self,
16
+ attributes: scim_attributes,
17
+ **@options, **options)
18
+ end
19
+
20
+ def scim_attributes
21
+ @attributes.reduce([]) do |attrs, attr|
22
+ case attr
23
+ when Hash
24
+ attrs + attr.map do |key, nested_attrs|
25
+ nested_attrs.map { "#{key}.#{_1}" }
26
+ end
27
+ else
28
+ attrs + [attr]
29
+ end
30
+ end.join(",")
16
31
  end
17
32
  end
18
33
  end
@@ -12,9 +12,9 @@ module Audiences
12
12
  Client.new(**Audiences.config.scim)
13
13
  end
14
14
 
15
- def resource(type, **options)
15
+ def resource(type)
16
16
  Audiences.config.resources.fetch(type) do
17
- Resource.new(type: type, **options)
17
+ Resource.new(type: type)
18
18
  end
19
19
  end
20
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Audiences
4
- VERSION = "1.2.0"
4
+ VERSION = "1.2.2"
5
5
  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.2.0
4
+ version: 1.2.2
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-07-24 00:00:00.000000000 Z
11
+ date: 2024-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails