Skip to content

Commit

Permalink
fix: LTI use RunAsSystem when LTI Node is embedded in lms and user ha…
Browse files Browse the repository at this point in the history
…s SingleUseNodeId permission
  • Loading branch information
Daniel Rudolph committed Oct 11, 2024
1 parent c008689 commit 66f5565
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -669,16 +669,19 @@ public Response generateLoginInitiationFormResourceLink(@Parameter(description =
@Context HttpServletRequest req){
try{

if(jwt != null){
Jws<Claims> claimsJws = LTIJWTUtil.validateJWT(jwt, ApplicationInfoList.getHomeRepository());
String jwtNodeId = (String)claimsJws.getBody().get(CCConstants.NODEID);
if(jwtNodeId == null){
throw new Exception("nodeId not found in validated jwt");
}
if(!jwtNodeId.equals(nodeId)){
throw new Exception("wrong nodeId found in validated jwt");
if(jwt != null || org.edu_sharing.alfresco.repository.server.authentication.Context.getCurrentInstance().isSingleUseNodeId(nodeId)){
if(jwt != null){
Jws<Claims> claimsJws = LTIJWTUtil.validateJWT(jwt, ApplicationInfoList.getHomeRepository());
String jwtNodeId = (String)claimsJws.getBody().get(CCConstants.NODEID);
if(jwtNodeId == null){
throw new Exception("nodeId not found in validated jwt");
}
if(!jwtNodeId.equals(nodeId)){
throw new Exception("wrong nodeId found in validated jwt");
}
}
return AuthenticationUtil.runAsSystem(() -> generateLoginInitationResouceLinkRaw(nodeId, editMode, version, launchPresentation, req));

}else{
return generateLoginInitationResouceLinkRaw(nodeId, editMode, version, launchPresentation, req);
}
Expand Down

0 comments on commit 66f5565

Please sign in to comment.