Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming exercises: Provide theia clone information on redirect #9379

Open
wants to merge 72 commits into
base: feature/re-key
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
a0497f3
Move Theia Button to Code Button
iyannsch Sep 23, 2024
2ab444e
Add functionality to pull build config on demand from server
iyannsch Sep 24, 2024
389f5fd
Merge branch 'develop' into feature/programming-exercises/provide-the…
iyannsch Sep 28, 2024
7ce3a49
Add Uri, Token, and landing-page URL to Theia Button
iyannsch Sep 28, 2024
4160302
Add Form test and re-key endpoint
iyannsch Oct 3, 2024
eae2c89
Clean up initTheia method
iyannsch Oct 3, 2024
0f18104
Fix formatting
iyannsch Oct 3, 2024
486b2c5
Fix implicit type expressions
iyannsch Oct 4, 2024
d9bf634
Fix rekey endpoint to be reachable
iyannsch Oct 4, 2024
a643b42
Merge upstream key endpoint
iyannsch Oct 4, 2024
34a84d7
Merge branch 'feature/re-key' into feature/programming-exercises/prov…
iyannsch Oct 4, 2024
4f1a99b
Fix endpoint theia-token connection
iyannsch Oct 4, 2024
4aa5171
Merge branch 'develop' into feature/programming-exercises/provide-the…
iyannsch Oct 8, 2024
7abb02c
Merge branch 'feature/re-key' into feature/programming-exercises/prov…
iyannsch Oct 8, 2024
b7ebea0
Merge upstream bearer branch
iyannsch Oct 8, 2024
685a483
Get Token unconditionally
iyannsch Oct 8, 2024
e8be59c
Merge branch 'develop' into feature/programming-exercises/provide-the…
iyannsch Oct 29, 2024
575379b
Fix failing correct data submission test
iyannsch Oct 29, 2024
2d2a5b7
Remove minus from appDef to align to TS configuration
iyannsch Oct 29, 2024
6207ce8
Fix configuration values to align with new system
iyannsch Nov 7, 2024
a6cc06e
Merge branch 'develop' into feature/programming-exercises/provide-the…
iyannsch Nov 7, 2024
f82d6fb
Merge branch 'feature/re-key' into feature/programming-exercises/prov…
iyannsch Nov 7, 2024
beb3d48
Merge branch 'feature/re-key' of github.com:ls1intum/Artemis into fea…
iyannsch Nov 7, 2024
625216e
Rename endpoint to theia-token
iyannsch Nov 7, 2024
b42126a
Quiz exercises: Disable practice mode for imported exercises (#9683)
Hialus Nov 7, 2024
63f9cca
Programming exercises: Add C# programming language template (#9626)
magaupp Nov 7, 2024
a8ec277
Communication: Add additional input formatting options (#9657)
asliayk Nov 7, 2024
a140b11
Communication: Fix element height in announcement channel (#9664)
PaRangger Nov 7, 2024
d3357f8
Development: Use signals in lecture online and text unit (#9658)
florian-glombik Nov 7, 2024
4d34faa
Development: Use signals in lecture add attachment form (#9656)
florian-glombik Nov 7, 2024
9ad7a35
Programming exercises: Upgrade Haskell container image (#9687)
b-fein Nov 7, 2024
d9a1f91
Development: Update the editor-related screenshots in the documentati…
pzdr7 Nov 7, 2024
3bff129
Programming exercises: Decrease space between lines in the code edito…
chrisknedl Nov 7, 2024
25146ba
Development: Fix client test coverage (#9703)
florian-glombik Nov 8, 2024
bfebf27
Development: Use signals in video unit form component (#9692)
florian-glombik Nov 8, 2024
7a18571
Communication: Group consecutive messages (#9456)
asliayk Nov 8, 2024
e64adb2
Development: Update client dependencies
krusche Nov 9, 2024
c9f0c0d
Development: Update server dependencies
krusche Nov 9, 2024
0d01a40
Development: Use signals in date time picker (#9694)
florian-glombik Nov 9, 2024
64f95cd
Development: Fix course messages e2e tests (#9720)
asliayk Nov 9, 2024
6e37a8f
Communication: Remeber last scroll position when switching conversati…
cremertim Nov 9, 2024
bf2fbbd
Lectures: Fix lecture unit file attachment names (#9721)
SimonEntholzer Nov 10, 2024
cec3866
Communication: Add profile picture to sidebar element and conversatio…
asliayk Nov 10, 2024
afa8543
Programming exercises: Fix code button showing HTTPS link when it sho…
SimonEntholzer Nov 10, 2024
e89f035
Programming exercises: Add information box to exercise details page (…
rabeatwork Nov 10, 2024
395e8df
Programming exercises: Add error categories and categorize feedback i…
az108 Nov 10, 2024
0cc6620
General: Add cleanup service for admins (#9296)
coolchock Nov 10, 2024
5a3ae27
Development: Improve spotless config for pre commit hook (#9600)
krusche Nov 10, 2024
43446ae
Adaptive learning: Fix bulk creation of competencies (#9682)
JohannesStoehr Nov 10, 2024
f75b379
Adaptive learning: Fix import all competencies with relations (#9713)
MaximilianAnzinger Nov 10, 2024
36a182b
Lectures: Add editing functionality to attachment PDF preview (#9265)
eceeeren Nov 10, 2024
110d047
Development: Convert DTOs to records (#9385)
krusche Nov 10, 2024
b932844
Development: Fix issues with admin cleanup service and improve logging
krusche Nov 10, 2024
d5e3b70
Development: Fix typo in jest.config.js
krusche Nov 11, 2024
de36813
Development: Bump version to 7.7.1
krusche Nov 11, 2024
8205b58
Adaptive learning: Visualize competencies linked to exercises correct…
MaximilianAnzinger Nov 12, 2024
7876792
Iris: Fix an error related to Iris settings when tutors navigate to c…
alexjoham Nov 12, 2024
2946389
Merge branch 'feature/re-key' of github.com:ls1intum/Artemis into fea…
iyannsch Nov 12, 2024
c7c5322
Rename endpoint to tool-token
iyannsch Nov 12, 2024
9b0bcc3
Add ArtemisURL to theia query params
iyannsch Nov 12, 2024
c907b0a
Integrated code lifecycle: Add auxiliary repositories in exercise exp…
SimonEntholzer Nov 12, 2024
65bc890
Programming exercises: Fix a performance issue with build log statistics
krusche Nov 12, 2024
749b301
Programming exercise: Speed up version control access log queries wit…
krusche Nov 12, 2024
f2d7aaa
Adaptive learning: Fix an issue with competency progress calculation
krusche Nov 12, 2024
f485527
Lectures: Fix an issue when saving lecture units in guided mode witho…
florian-glombik Nov 12, 2024
1b50466
Adaptive learning: Fix linking attachment units to competencies (#9739)
JohannesStoehr Nov 12, 2024
70ccfc3
Development: Fix server tests related to build log statistics
krusche Nov 13, 2024
054476c
Development: Improve slow query performance (#9727)
krusche Nov 13, 2024
d3817c8
Add gitUser and gitMail to Theia LP
iyannsch Nov 13, 2024
383945a
Development: Refactor competencies management page to signals (#9629)
JohannesWt Nov 13, 2024
ac87b07
Remove debug for artemisUrl
iyannsch Nov 13, 2024
10648b0
Merge branch 'develop' of github.com:ls1intum/Artemis into feature/pr…
iyannsch Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import de.tum.cit.aet.artemis.core.dto.vm.LoginVM;
import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException;
import de.tum.cit.aet.artemis.core.security.SecurityUtils;
import de.tum.cit.aet.artemis.core.security.UserNotActivatedException;
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastStudent;
import de.tum.cit.aet.artemis.core.security.annotations.EnforceNothing;
import de.tum.cit.aet.artemis.core.security.jwt.JWTCookieService;
import de.tum.cit.aet.artemis.core.service.connectors.SAML2Service;
Expand Down Expand Up @@ -94,6 +96,24 @@ public ResponseEntity<Void> authorize(@Valid @RequestBody LoginVM loginVM, @Requ
}
}

/**
* Sends the token back as either a cookie or a bearer token
*
* @param response HTTP response
* @return the ResponseEntity with status 200 (ok), 401 (unauthorized)
*/
@PostMapping("re-key")
@EnforceAtLeastStudent
public ResponseEntity<String> reKey(@RequestParam(value = "as-bearer", defaultValue = "false") boolean asBearer, HttpServletResponse response) {
ResponseCookie responseCookie = jwtCookieService.buildLoginCookie(true);
if (asBearer) {
return ResponseEntity.ok(responseCookie.getValue());
}
response.addHeader(HttpHeaders.SET_COOKIE, responseCookie.toString());

return ResponseEntity.ok().build();
}
iyannsch marked this conversation as resolved.
Show resolved Hide resolved

/**
* Authorizes a User logged in with SAML2
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@Entity
@Table(name = "programming_exercise_build_config")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(value = { "programmingExercise" })
iyannsch marked this conversation as resolved.
Show resolved Hide resolved
public class ProgrammingExerciseBuildConfig extends DomainObject {

private static final Logger log = LoggerFactory.getLogger(ProgrammingExerciseBuildConfig.class);
Expand Down Expand Up @@ -58,7 +59,6 @@ public class ProgrammingExerciseBuildConfig extends DomainObject {
private String dockerFlags;

@OneToOne(mappedBy = "buildConfig")
@JsonIgnoreProperties("buildConfig")
private ProgrammingExercise programmingExercise;

@Column(name = "testwise_coverage_enabled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ default void generateBuildPlanAccessSecretIfNotExists(ProgrammingExerciseBuildCo
default void loadAndSetBuildConfig(ProgrammingExercise programmingExercise) {
programmingExercise.setBuildConfig(getProgrammingExerciseBuildConfigElseThrow(programmingExercise));
}

/**
* Find a build config by its programming exercise's id and throw an Exception if it cannot be found
*
* @param programmingExerciseId of the programming exercise.
* @return The programming exercise related to the given id
*/
default ProgrammingExerciseBuildConfig findByExerciseIdElseThrow(long programmingExerciseId) {
return getValueElseThrow(findByProgrammingExerciseId(programmingExerciseId));
}
iyannsch marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastEditor;
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastInstructor;
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastTutor;
import de.tum.cit.aet.artemis.core.security.annotations.enforceRoleInExercise.EnforceAtLeastStudentInExercise;
import de.tum.cit.aet.artemis.core.security.annotations.enforceRoleInExercise.EnforceAtLeastTutorInExercise;
import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService;
import de.tum.cit.aet.artemis.core.service.CourseService;
Expand All @@ -71,13 +72,15 @@
import de.tum.cit.aet.artemis.plagiarism.service.PlagiarismDetectionConfigHelper;
import de.tum.cit.aet.artemis.programming.domain.AuxiliaryRepository;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseBuildConfig;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage;
import de.tum.cit.aet.artemis.programming.dto.BuildLogStatisticsDTO;
import de.tum.cit.aet.artemis.programming.dto.CheckoutDirectoriesDTO;
import de.tum.cit.aet.artemis.programming.dto.ProgrammingExerciseResetOptionsDTO;
import de.tum.cit.aet.artemis.programming.dto.ProgrammingExerciseTestCaseStateDTO;
import de.tum.cit.aet.artemis.programming.repository.BuildLogStatisticsEntryRepository;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository;
import de.tum.cit.aet.artemis.programming.repository.SolutionProgrammingExerciseParticipationRepository;
Expand Down Expand Up @@ -114,6 +117,8 @@ public class ProgrammingExerciseResource {

private final ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository;

private final ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository;

private final UserRepository userRepository;

private final CourseService courseService;
Expand Down Expand Up @@ -157,9 +162,9 @@ public class ProgrammingExerciseResource {
private final Environment environment;

public ProgrammingExerciseResource(ProgrammingExerciseRepository programmingExerciseRepository, ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository,
UserRepository userRepository, AuthorizationCheckService authCheckService, CourseService courseService,
Optional<ContinuousIntegrationService> continuousIntegrationService, Optional<VersionControlService> versionControlService, ExerciseService exerciseService,
ExerciseDeletionService exerciseDeletionService, ProgrammingExerciseService programmingExerciseService,
ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository, UserRepository userRepository, AuthorizationCheckService authCheckService,
CourseService courseService, Optional<ContinuousIntegrationService> continuousIntegrationService, Optional<VersionControlService> versionControlService,
ExerciseService exerciseService, ExerciseDeletionService exerciseDeletionService, ProgrammingExerciseService programmingExerciseService,
ProgrammingExerciseRepositoryService programmingExerciseRepositoryService, ProgrammingExerciseTaskService programmingExerciseTaskService,
StudentParticipationRepository studentParticipationRepository, StaticCodeAnalysisService staticCodeAnalysisService,
GradingCriterionRepository gradingCriterionRepository, CourseRepository courseRepository, GitService gitService, AuxiliaryRepositoryService auxiliaryRepositoryService,
Expand All @@ -170,6 +175,7 @@ public ProgrammingExerciseResource(ProgrammingExerciseRepository programmingExer
this.programmingExerciseTaskService = programmingExerciseTaskService;
this.programmingExerciseRepository = programmingExerciseRepository;
this.programmingExerciseTestCaseRepository = programmingExerciseTestCaseRepository;
this.programmingExerciseBuildConfigRepository = programmingExerciseBuildConfigRepository;
this.userRepository = userRepository;
this.courseService = courseService;
this.authCheckService = authCheckService;
Expand Down Expand Up @@ -492,6 +498,21 @@ public ResponseEntity<ProgrammingExercise> getProgrammingExercise(@PathVariable
return ResponseEntity.ok().body(programmingExercise);
}

/**
* GET /programming-exercises/:exerciseId/build-config : get the build config of "exerciseId" programmingExercise.
*
* @param exerciseId the id of the programmingExercise to retrieve the config for
* @return the ResponseEntity with status 200 (OK) and with body the programmingExerciseBuildConfig, or with status 404 (Not Found)
*/
@GetMapping("programming-exercises/{exerciseId}/build-config")
@EnforceAtLeastStudentInExercise
public ResponseEntity<ProgrammingExerciseBuildConfig> getBuildConfig(@PathVariable long exerciseId) {
iyannsch marked this conversation as resolved.
Show resolved Hide resolved
log.debug("REST request to get build config of ProgrammingExercise : {}", exerciseId);
var buildConfig = programmingExerciseBuildConfigRepository.findByExerciseIdElseThrow(exerciseId);

return ResponseEntity.ok().body(buildConfig);
}

/**
* GET /programming-exercises/:exerciseId/with-participations/ : get the "exerciseId" programmingExercise.
*
Expand Down
8 changes: 8 additions & 0 deletions src/main/webapp/app/core/auth/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,12 @@ export class AccountService implements IAccountService {
const params = new HttpParams().set('participationId', participationId);
return this.http.put<string>('api/account/participation-vcs-access-token', null, { observe: 'response', params, responseType: 'text' as 'json' });
}

/**
* Trades the current cookie for a new bearer token which is also able to authenticate the user.
* The Cookie stays valid, a new bearer token is generated on every call.
*/
rekeyCookieToBearerToken() {
return this.http.post<string>('api/public/rekey?as-bearer=true', null);
}
iyannsch marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Participation } from 'app/entities/participation/participation.model';
import { PlagiarismResultDTO } from 'app/exercises/shared/plagiarism/types/PlagiarismResultDTO';
import { ImportOptions } from 'app/types/programming-exercises';
import { CheckoutDirectoriesDto } from 'app/entities/programming/checkout-directories-dto';
import { ProgrammingExerciseBuildConfig } from 'app/entities/programming/programming-exercise-build.config';

export type EntityResponseType = HttpResponse<ProgrammingExercise>;
export type EntityArrayResponseType = HttpResponse<ProgrammingExercise[]>;
Expand Down Expand Up @@ -660,6 +661,10 @@ export class ProgrammingExerciseService {
return this.http.get<BuildLogStatisticsDTO>(`${this.resourceUrl}/${exerciseId}/build-log-statistics`);
}

getBuildConfig(exerciseId: number): Observable<ProgrammingExerciseBuildConfig> {
return this.http.get<ProgrammingExerciseBuildConfig>(`${this.resourceUrl}/${exerciseId}/build-config`);
}

/** Imports a programming exercise from a given zip file **/
importFromFile(exercise: ProgrammingExercise, courseId: number): Observable<EntityResponseType> {
let copy = this.convertDataFromClient(exercise);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@
[useParticipationVcsAccessToken]="true"
/>
}
@if (theiaEnabled) {
<a class="btn btn-primary" [class.btn-sm]="smallButtons" (click)="startOnlineIDE()" target="_blank" rel="noopener noreferrer">
<fa-icon [icon]="faDesktop" [fixedWidth]="true" />
<span class="d-none d-md-inline" jhiTranslate="artemisApp.exerciseActions.openOnlineIDE"></span>
</a>
}
@if (exercise.allowFeedbackRequests) {
@if (athenaEnabled) {
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { ProgrammingExercise } from 'app/entities/programming/programming-exerci
import { StudentParticipation } from 'app/entities/participation/student-participation.model';
import { ArtemisQuizService } from 'app/shared/quiz/quiz.service';
import { finalize } from 'rxjs/operators';
import { faCodeBranch, faDesktop, faEye, faFolderOpen, faPenSquare, faPlayCircle, faRedo, faUsers } from '@fortawesome/free-solid-svg-icons';
import { faCodeBranch, faEye, faFolderOpen, faPenSquare, faPlayCircle, faRedo, faUsers } from '@fortawesome/free-solid-svg-icons';
iyannsch marked this conversation as resolved.
Show resolved Hide resolved
import { CourseExerciseService } from 'app/exercises/shared/course-exercises/course-exercise.service';
import { TranslateService } from '@ngx-translate/core';
import { ParticipationService } from 'app/exercises/shared/participation/participation.service';
import dayjs from 'dayjs/esm';
import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model';
import { ProfileService } from 'app/shared/layouts/profiles/profile.service';
import { PROFILE_ATHENA, PROFILE_LOCALVC, PROFILE_THEIA } from 'app/app.constants';
import { PROFILE_ATHENA, PROFILE_LOCALVC } from 'app/app.constants';
import { AssessmentType } from 'app/entities/assessment-type.model';

@Component({
Expand Down Expand Up @@ -60,17 +60,13 @@ export class ExerciseDetailsStudentActionsComponent implements OnInit, OnChanges
routerLink: string;
repositoryLink: string;

theiaEnabled: boolean = false;
theiaPortalURL: string;

// Icons
readonly faFolderOpen = faFolderOpen;
readonly faUsers = faUsers;
readonly faEye = faEye;
readonly faPlayCircle = faPlayCircle;
readonly faRedo = faRedo;
readonly faCodeBranch = faCodeBranch;
readonly faDesktop = faDesktop;
readonly faPenSquare = faPenSquare;

private feedbackSent = false;
Expand Down Expand Up @@ -110,28 +106,6 @@ export class ExerciseDetailsStudentActionsComponent implements OnInit, OnChanges
this.profileService.getProfileInfo().subscribe((profileInfo) => {
this.localVCEnabled = profileInfo.activeProfiles?.includes(PROFILE_LOCALVC);
this.athenaEnabled = profileInfo.activeProfiles?.includes(PROFILE_ATHENA);
// The online IDE is only available with correct SpringProfile and if it's enabled for this exercise
if (profileInfo.activeProfiles?.includes(PROFILE_THEIA) && this.programmingExercise) {
this.theiaEnabled = true;

// Set variables now, sanitize later on
this.theiaPortalURL = profileInfo.theiaPortalURL ?? '';

// Verify that Theia's portal URL is set
if (this.theiaPortalURL === '') {
this.theiaEnabled = false;
}

// Verify that the exercise allows the online IDE
if (!this.programmingExercise.allowOnlineIde) {
this.theiaEnabled = false;
}

// Verify that the exercise has a theia blueprint configured
if (!this.programmingExercise.buildConfig?.theiaImage) {
this.theiaEnabled = false;
}
}
});
} else if (this.exercise.type === ExerciseType.MODELING) {
this.editorLabel = 'openModelingEditor';
Expand All @@ -158,10 +132,6 @@ export class ExerciseDetailsStudentActionsComponent implements OnInit, OnChanges
this.isTeamAvailable = !!(this.exercise.teamMode && this.exercise.studentAssignedTeamIdComputed && this.exercise.studentAssignedTeamId);
}

startOnlineIDE() {
window.open(this.theiaPortalURL, '_blank');
}

receiveNewParticipation(newParticipation: StudentParticipation) {
const studentParticipations = this.exercise.studentParticipations ?? [];
if (studentParticipations.map((participation) => participation.id).includes(newParticipation.id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ <h5>{{ cloneHeadline | artemisTranslate }}</h5>
style="min-width: 100px"
jhiTranslate="{{ wasCopied ? 'artemisApp.exerciseActions.copiedUrl' : 'artemisApp.exerciseActions.copyUrl' }}"
></button>
@if (theiaEnabled) {
<a class="btn btn-primary btn-sm me-2" (click)="startOnlineIDE()" target="_blank" rel="noopener noreferrer">
<span class="d-none d-md-inline" jhiTranslate="artemisApp.exerciseActions.openOnlineIDE"></span>
</a>
}
iyannsch marked this conversation as resolved.
Show resolved Hide resolved
<a
class="btn btn-primary btn-sm"
target="hidden-iframe"
Expand Down
Loading
Loading