Custom menu (#901)
* added way to customize menu * fixed unit mock test * updated release notes * updated release notes * default none exclude
This commit is contained in:
@ -40,6 +40,7 @@ import org.owasp.webgoat.session.WebSession;
|
||||
import org.owasp.webgoat.users.LessonTracker;
|
||||
import org.owasp.webgoat.users.UserTracker;
|
||||
import org.owasp.webgoat.users.UserTrackerRepository;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@ -65,6 +66,12 @@ public class LessonMenuService {
|
||||
private final WebSession webSession;
|
||||
private UserTrackerRepository userTrackerRepository;
|
||||
|
||||
@Value("#{'${exclude.categories}'.split(',')}")
|
||||
private List<String> excludeCategories;
|
||||
|
||||
@Value("#{'${exclude.lessons}'.split(',')}")
|
||||
private List<String> excludeLessons;
|
||||
|
||||
/**
|
||||
* Returns the lesson menu which is used to build the left nav
|
||||
*
|
||||
@ -79,6 +86,9 @@ public class LessonMenuService {
|
||||
UserTracker userTracker = userTrackerRepository.findByUser(webSession.getUserName());
|
||||
|
||||
for (Category category : categories) {
|
||||
if (excludeCategories.contains(category.name())) {
|
||||
continue;
|
||||
}
|
||||
LessonMenuItem categoryItem = new LessonMenuItem();
|
||||
categoryItem.setName(category.getName());
|
||||
categoryItem.setType(LessonMenuItemType.CATEGORY);
|
||||
@ -86,6 +96,9 @@ public class LessonMenuService {
|
||||
List<Lesson> lessons = course.getLessons(category);
|
||||
lessons = lessons.stream().sorted(Comparator.comparing(l -> l.getTitle())).collect(Collectors.toList());
|
||||
for (Lesson lesson : lessons) {
|
||||
if (excludeLessons.contains(lesson.getName())) {
|
||||
continue;
|
||||
}
|
||||
LessonMenuItem lessonItem = new LessonMenuItem();
|
||||
lessonItem.setName(lesson.getTitle());
|
||||
lessonItem.setLink(lesson.getLink());
|
||||
|
@ -50,3 +50,9 @@ spring.jackson.serialization.write-dates-as-timestamps=false
|
||||
|
||||
#For static file refresh ... and faster dev :D
|
||||
spring.devtools.restart.additional-paths=webgoat-container/src/main/resources/static/js,webgoat-container/src/main/resources/static/css
|
||||
|
||||
exclude.categories=${EXCLUDE_CATEGORIES:none,none}
|
||||
#exclude based on the enum of the Category
|
||||
|
||||
exclude.lessons=${EXCLUDE_LESSONS:none,none}
|
||||
#exclude based on the class name of a lesson e.g.: LessonTemplate
|
Reference in New Issue
Block a user