scope comparison for introspection endpoint

pull/516/head
Justin Richer 11 years ago
parent 61544ed774
commit 1c4c53f252

@ -22,7 +22,6 @@ import java.util.Set;
import org.mitre.oauth2.model.ClientDetailsEntity; import org.mitre.oauth2.model.ClientDetailsEntity;
import org.mitre.oauth2.model.OAuth2AccessTokenEntity; import org.mitre.oauth2.model.OAuth2AccessTokenEntity;
import org.mitre.oauth2.model.SystemScope;
import org.mitre.oauth2.model.OAuth2RefreshTokenEntity; import org.mitre.oauth2.model.OAuth2RefreshTokenEntity;
import org.mitre.oauth2.service.ClientDetailsEntityService; import org.mitre.oauth2.service.ClientDetailsEntityService;
import org.mitre.oauth2.service.OAuth2TokenEntityService; import org.mitre.oauth2.service.OAuth2TokenEntityService;
@ -120,25 +119,11 @@ public class IntrospectionEndpoint {
if (authClient.isAllowIntrospection()) { if (authClient.isAllowIntrospection()) {
// if it's the same client that the token was issued to, or it at least has all the scopes the token was issued with // if it's the same client that the token was issued to, or it at least has all the scopes the token was issued with
if (authClient.getClientId().equals(tokenClient.getClientId()) || authClient.getScope().containsAll(scopes)) { if (authClient.getClientId().equals(tokenClient.getClientId()) || scopeService.scopesMatch(authClient.getScope(), scopes)) {
// if it's a valid token, we'll print out information on it // if it's a valid token, we'll print out information on it
model.addAttribute("entity", token); model.addAttribute("entity", token);
return "tokenIntrospection"; return "tokenIntrospection";
} else { } else {
boolean scopesConsistent = true;
for (String ts : scopes){
if (!authClient.getScope().contains(scopeService.baseScopeString(ts))){
scopesConsistent = false;
break;
}
}
if (scopesConsistent) {
model.addAttribute("entity", token);
return "tokenIntrospection";
}
logger.error("Verify failed; client tried to introspect a token of an incorrect scope"); logger.error("Verify failed; client tried to introspect a token of an incorrect scope");
model.addAttribute("code", HttpStatus.FORBIDDEN); model.addAttribute("code", HttpStatus.FORBIDDEN);
return "httpCodeView"; return "httpCodeView";

Loading…
Cancel
Save