Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit 6232f2d

Browse files
authored
1073: (#1218)
- Updated default serialization config to include href scalars by default (previously omitted). - Ensured our referenced Spring version is 4.3.5 since Spring Security and Spring Boot both reference that version. This was causing runtime conflicts in example applications.
1 parent 3901d15 commit 6232f2d

File tree

5 files changed

+40
-29
lines changed

5 files changed

+40
-29
lines changed

docs/source/forwarded-request.rst

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,8 @@ properties. This is the default configuration in effect if you don't specify an
164164
value:
165165
strategy: scalars
166166
fields:
167-
href:
168-
enabled: false
169167
customData:
170168
strategy: scalars
171-
fields:
172-
href:
173-
enabled: false
174169
groups:
175170
strategy: defined
176171
elements:
@@ -188,23 +183,18 @@ So what does this mean? You can summarize this in English as the following:
188183

189184
- all of the account's `scalar`_ (i.e. non object/collection) fields to be included, each as a JSON name/value pair.
190185

191-
- However, I want specific overriding rules for the ``href``, ``customData`` and ``groups`` fields. For these:
192-
193-
- don't include the account's ``href`` field. My origin server(s) behind the gateway probably won't talk
194-
directly with Stormpath and won't know what to do with that url, so exclude it
186+
- However, I want specific overriding rules for the ``customData`` and ``groups`` fields. For these:
195187

196188
- ``customData`` isn't a scalar, but I want it included anyway, so I'm going to define conversion rules for it
197-
too. Those are:
189+
too. That is :
198190

199191
- Include any of the customData's scalar properties automatically
200192

201-
- However, don't include the customData's ``href``, since my origin server(s) won't know what to do with it.
202-
203193
- ``groups`` isn't a scalar (it's a ``GroupsCollection`` object), but I want it included anyway.
204194

205195
- However, in this case I want to include *only* fields that are explicitly *defined* in its ``fields``
206196
list. (In this case, even though the strategy is ``defined``, no actual ``fields`` have been specified.
207-
This means that *no* fields on the ``GroupsCollection`` object itself, like 'size' and 'limit' will be
197+
This means that *no* fields on the ``GroupsCollection`` object itself, like 'href', 'size' and 'limit' will be
208198
included. We just want the collection's elements, described next.)
209199

210200
- The collection ``elements`` are enabled so I do want the elements in the collection.
@@ -221,6 +211,7 @@ bytes transmitted over the network, the actual value won't be pretty-printed):
221211
.. code-block:: json
222212
223213
{
214+
"href": "https://api.stormpath.com/v1/accounts/753veZGE2aIy64VnTrF5Ov",
224215
"username": "tk421",
225216
"email": "[email protected]",
226217
"givenName": "TK421",
@@ -233,20 +224,23 @@ bytes transmitted over the network, the actual value won't be pretty-printed):
233224
"passwordModifiedAt": "2016-12-15T19:58:55.000Z",
234225
"emailVerificationToken": null,
235226
"customData": {
227+
"href": "https://api.stormpath.com/v1/accounts/753veZGE2aIy64VnTrF5Ov/customData",
236228
"createdAt": "2016-12-15T19:58:55.272Z",
237229
"modifiedAt":"2016-12-15T19:59:23.729Z",
238230
"favoriteColor": "Blaster Black"
239231
},
240232
"groups": {
241233
"items": [
242234
{
235+
"href": "https://api.stormpath.com/v1/groups/4NQzRKj0qDq1wIg9M0jUfa",
243236
"name": "dsguards",
244237
"description": "Death Star Guards",
245238
"status": "ENABLED",
246239
"createdAt": "2016-12-28T00:34:46.453Z",
247240
"modifiedAt":"2016-12-28T00:34:46.453Z"
248241
},
249242
{
243+
"href": "https://api.stormpath.com/v1/groups/9fBEMQtvElx2Zn7a0ku1Dj",
250244
"name": "troopers",
251245
"description": "All stormtroopers",
252246
"status": "ENABLED",
@@ -398,6 +392,23 @@ The ``enabled`` conversion property indicates if the field will be included in t
398392
the value is ``false``, that field will not be included at all in the output sent to the origin server. The default
399393
value is ``true``.
400394

395+
For example, the following config indicates that, although the general strategy is to include the user account's
396+
scalar fields, the ``href`` field is excluded/omitted from the output JSON entirely:
397+
398+
.. code-block:: yaml
399+
:emphasize-lines: 8-9
400+
401+
stormpath:
402+
zuul:
403+
account:
404+
header:
405+
value:
406+
strategy: scalars
407+
fields:
408+
href:
409+
enabled: false
410+
411+
401412
.. _object conversion field:
402413

403414
``field``

examples/zuul-spring-cloud-starter/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@
3434
<packaging>jar</packaging>
3535

3636
<properties>
37-
<jdk.version>1.7</jdk.version>
38-
<jstl.version>1.2</jstl.version>
39-
<logback.version>1.1.7</logback.version>
4037
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
41-
<servlet.version>3.1.0</servlet.version>
42-
<slf4j.version>1.7.21</slf4j.version>
43-
<spring.version>4.3.2.RELEASE</spring.version>
4438
</properties>
4539

4640
<dependencies>

extensions/servlet/src/main/java/com/stormpath/sdk/convert/ResourceConverter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public class ResourceConverter<T> implements Function<T, Object> {
4646
private static final Logger log = LoggerFactory.getLogger(ResourceConverter.class);
4747

4848
public static final Conversion DEFAULT_CONFIG = Conversions
49-
.withField("href", Conversions.disabled())
50-
.withField("customData", Conversions.withField("href", Conversions.disabled()))
51-
.withField("groups", Conversions.withStrategy(ConversionStrategyName.DEFINED).setElements(Conversions.each(Conversions.withField("href", Conversions.disabled()))));
49+
//.withField("href", Conversions.disabled())
50+
.withField("customData", Conversions.withStrategy(ConversionStrategyName.SCALARS))
51+
.withField("groups", Conversions.withStrategy(ConversionStrategyName.DEFINED).setElements(Conversions.each(new Conversion())));
5252

5353
private Conversion config;
5454

extensions/servlet/src/test/groovy/com/stormpath/sdk/convert/ResourceConverterTest.groovy

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,13 @@ class ResourceConverterTest {
616616

617617
def result = fn.apply(account)
618618

619-
assertEquals result.size(), props.size() - 1 // no href
619+
assertEquals result.size(), props.size()
620+
assertEquals result.href, 'https://example.io/users/1'
620621
assertEquals result.username, props.username
621622
assertEquals result.email, props.email
622623

623-
assertEquals result.customData.size(), cd.size() - 1 // no href
624+
assertEquals result.customData.size(), cd.size()
625+
assertEquals result.customData.href, 'https://example.io/users/1/customData'
624626
assertTrue result.customData.containsKey('createdAt')
625627
assertTrue result.customData.containsKey('modifiedAt')
626628

@@ -629,15 +631,18 @@ class ResourceConverterTest {
629631
def i = result.groups.items.iterator()
630632

631633
def g = i.next()
632-
assertEquals g.size(), 1 //no href by default
634+
assertEquals g.size(), 2
635+
assertEquals g.href, 'https://example.io/groups/1'
633636
assertEquals g.name, 'foo'
634637

635638
g = i.next()
636-
assertEquals g.size(), 1 //no href by default
639+
assertEquals g.size(), 2
640+
assertEquals g.href, 'https://example.io/groups/2'
637641
assertEquals g.name, 'bar'
638642

639643
g = i.next()
640-
assertEquals g.size(), 1 //no href by default
644+
assertEquals g.size(), 2
645+
assertEquals g.href, 'https://example.io/groups/3'
641646
assertEquals g.name, 'baz'
642647
}
643648

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888

8989
<properties>
9090
<jdk.version>1.7</jdk.version>
91+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9192
<slf4j.version>1.7.21</slf4j.version>
9293
<bouncycastle.version>1.56</bouncycastle.version>
9394
<hazelcast.version>3.6.4</hazelcast.version>
@@ -100,10 +101,10 @@
100101
<maven-enforcer-plugin.version>1.4.1</maven-enforcer-plugin.version>
101102
<snakeyaml.version>1.17</snakeyaml.version>
102103
<servlet.version>3.1.0</servlet.version>
103-
<spring.version>4.3.2.RELEASE</spring.version>
104+
<spring.version>4.3.5.RELEASE</spring.version>
104105
<spring.boot.version>1.4.3.RELEASE</spring.boot.version>
105106
<spring.cloud.netflix.version>1.1.5.RELEASE</spring.cloud.netflix.version>
106-
<spring.security.version>4.2.0.RELEASE</spring.security.version>
107+
<spring.security.version>4.2.1.RELEASE</spring.security.version>
107108
<zuul.version>1.2.2</zuul.version>
108109

109110
<!-- Test Dependencies: Only required for testing when building the SDK. Not required by SDK users at runtime: -->

0 commit comments

Comments
 (0)