Skip to content

Commit

Permalink
CAS-1352: Usename attribute should not be required in the list of all…
Browse files Browse the repository at this point in the history
…owed attributes

Specifying the username attribute in the service registry for a given service currently requires that the same attribute exist in the list of allowed attributes.

https://issues.jasig.org/browse/CAS-1352
  • Loading branch information
SavvasMisaghMoayyed committed Sep 12, 2013
1 parent d0adc14 commit 21a0f23
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ private String determinePrincipalIdForRegisteredService(final Principal principa
} else if (StringUtils.isBlank(serviceUsernameAttribute)) {
principalId = principal.getId();
} else {
if ((registeredService.isIgnoreAttributes() || registeredService.getAllowedAttributes().contains(serviceUsernameAttribute)) &&
principal.getAttributes().containsKey(serviceUsernameAttribute)) {
if (principal.getAttributes().containsKey(serviceUsernameAttribute)) {
principalId = principal.getAttributes().get(registeredService.getUsernameAttribute()).toString();
} else {
principalId = principal.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,17 @@ public void testValidateServiceTicketWithUsernameAttribute() throws TicketExcept

@Test
public void testValidateServiceTicketWithInvalidUsernameAttribute() throws TicketException {
UsernamePasswordCredentials cred = TestUtils.getCredentialsWithSameUsernameAndPassword();
final UsernamePasswordCredentials cred = TestUtils.getCredentialsWithSameUsernameAndPassword();
final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);

Service svc = TestUtils.getService("eduPersonTestInvalid");
final Service svc = TestUtils.getService("eduPersonTestInvalid");
final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket, svc);

final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket, svc);
final Authentication auth = assertion.getChainedAuthentications().get(0);

/*
* The attribute specified for this service is not allows in the list of returned attributes.
* The attribute specified for this service does not resolve.
* Therefore, we expect the default to be returned.
*/
assertEquals(auth.getPrincipal().getId(), cred.getUsername());
Expand Down
2 changes: 1 addition & 1 deletion cas-server-core/src/test/resources/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<property name="name" value="EduPerson Test Invalid Service" />
<property name="serviceId" value="eduPersonTestInvalid" />
<property name="evaluationOrder" value="4" />
<property name="usernameAttribute" value="eduPersonAffiliation" />
<property name="usernameAttribute" value="nonExistentAttributeName" />
<property name="allowedAttributes">
<list>
<value>groupMembership</value>
Expand Down

0 comments on commit 21a0f23

Please sign in to comment.