|
9 | 9 | import org.gluu.jsf2.service.FacesService; |
10 | 10 | import org.gluu.model.custom.script.conf.CustomScriptConfiguration; |
11 | 11 | import org.gluu.oxauth.i18n.LanguageBean; |
| 12 | +import org.gluu.oxauth.model.authorize.AuthorizeRequestParam; |
| 13 | +import org.gluu.oxauth.model.authorize.ScopeChecker; |
12 | 14 | import org.gluu.oxauth.model.common.SessionId; |
13 | 15 | import org.gluu.oxauth.model.config.Constants; |
14 | 16 | import org.gluu.oxauth.model.configuration.AppConfiguration; |
15 | 17 | import org.gluu.oxauth.service.AuthorizeService; |
16 | 18 | import org.gluu.oxauth.service.ClientService; |
| 19 | +import org.gluu.oxauth.service.SessionIdService; |
17 | 20 | import org.gluu.oxauth.service.common.UserService; |
18 | 21 | import org.gluu.oxauth.service.external.ExternalConsentGatheringService; |
19 | 22 | import org.gluu.oxauth.service.external.context.ConsentGatheringContext; |
@@ -69,6 +72,12 @@ public class ConsentGathererService { |
69 | 72 |
|
70 | 73 | @Inject |
71 | 74 | private ClientService clientService; |
| 75 | + |
| 76 | + @Inject |
| 77 | + private SessionIdService sessionIdService; |
| 78 | + |
| 79 | + @Inject |
| 80 | + private ScopeChecker scopeChecker; |
72 | 81 |
|
73 | 82 | private final Map<String, String> pageAttributes = new HashMap<String, String>(); |
74 | 83 | private ConsentGatheringContext context; |
@@ -295,4 +304,17 @@ public ConsentGatheringContext getContext() { |
295 | 304 | return context; |
296 | 305 | } |
297 | 306 |
|
| 307 | + public List<org.oxauth.persistence.model.Scope> getScopes() { |
| 308 | + if (context == null) { |
| 309 | + return Collections.emptyList(); |
| 310 | + } |
| 311 | + |
| 312 | + SessionId authenticatedSessionId = sessionIdService.getSessionId(); |
| 313 | + // Fix the list of scopes in the authorization page. oxAuth #739 |
| 314 | + Set<String> grantedScopes = scopeChecker.checkScopesPolicy(context.getClient(), authenticatedSessionId.getSessionAttributes().get(AuthorizeRequestParam.SCOPE)); |
| 315 | + String allowedScope = org.gluu.oxauth.model.util.StringUtils.implode(grantedScopes, " "); |
| 316 | + |
| 317 | + return authorizeService.getScopes(allowedScope); |
| 318 | + } |
| 319 | + |
298 | 320 | } |
0 commit comments