Fix FixedAuthoritiesExtractor map extract bug

Fix issue where FixedAuthoritiesExtractor would fail to obtain standard
item from the map because an incorrect key was used.

Fixes gh-6396
This commit is contained in:
Phillip Webb 2016-07-15 13:01:43 -07:00
parent 5a941bb5a5
commit 68b9792ed6
2 changed files with 5 additions and 3 deletions

View File

@ -79,7 +79,7 @@ public class FixedAuthoritiesExtractor implements AuthoritiesExtractor {
}
for (String key : AUTHORITY_KEYS) {
if (map.containsKey(key)) {
return map.get(map);
return map.get(key);
}
}
return map;

View File

@ -75,8 +75,10 @@ public class FixedAuthoritiesExtractorTests {
@Test
public void authoritiesAsListOfMapsWithStandardKey() {
this.map.put("authorities",
Arrays.asList(Collections.singletonMap("role", "ROLE_ADMIN")));
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("role", "ROLE_ADMIN");
map.put("extra", "value");
this.map.put("authorities", Arrays.asList(map));
assertThat(this.extractor.extractAuthorities(this.map).toString())
.isEqualTo("[ROLE_ADMIN]");
}