-
Notifications
You must be signed in to change notification settings - Fork 294
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
Integrated code lifecycle
: Add access tokens for authentication to LocalVC repositories
#8929
Integrated code lifecycle
: Add access tokens for authentication to LocalVC repositories
#8929
Conversation
WalkthroughThe updates enhance the management of Version Control System (VCS) access tokens in the Artemis system by renaming the configuration parameter for clarity, introducing new services for streamlined token operations, and improving user interactions with VCS access. Key functionalities now include creating, retrieving, and deleting tokens, along with new options for token-based authentication in the user interface. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UserResource
participant ParticipationVCSAccessTokenService
participant ParticipationVCSAccessTokenRepository
User ->> UserResource: GET /users/vcsToken?participationId=...
UserResource ->> ParticipationVCSAccessTokenService: getVcsAccessToken(participationId)
ParticipationVCSAccessTokenService ->> ParticipationVCSAccessTokenRepository: findByUserIdAndParticipationId
ParticipationVCSAccessTokenRepository -->> ParticipationVCSAccessTokenService: Optional<ParticipationVCSAccessToken>
ParticipationVCSAccessTokenService -->> UserResource: Optional<ParticipationVCSAccessToken>
UserResource -->> User: VCS Access Token
User ->> UserResource: PUT /users/vcsToken?participationId=...
UserResource ->> ParticipationVCSAccessTokenService: createVcsAccessToken(participationId)
ParticipationVCSAccessTokenService ->> ParticipationVCSAccessTokenRepository: createParticipationVCSAccessToken
ParticipationVCSAccessTokenRepository -->> ParticipationVCSAccessTokenService: ParticipationVCSAccessToken
ParticipationVCSAccessTokenService -->> UserResource: ParticipationVCSAccessToken
UserResource -->> User: Created VCS Access Token
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
…n-for-participation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 11
Outside diff range comments (13)
src/main/webapp/app/shared/layouts/profiles/profile.service.ts (5)
Line range hint
99-99
: Use strict equality check.Use
!==
instead of!=
to avoid type coercion issues.- return this.profileInfo.pipe(filter((x) => x != undefined) as OperatorFunction<ProfileInfo | undefined, ProfileInfo>); + return this.profileInfo.pipe(filter((x) => x !== undefined) as OperatorFunction<ProfileInfo | undefined, ProfileInfo>);Tools
Biome
[error] 32-32: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
Line range hint
102-102
: Avoid usingany
type.Specify a different type instead of using
any
.- private mapAllowedOrionVersions(data: any, profileInfo: ProfileInfo) { + private mapAllowedOrionVersions(data: Record<string, unknown>, profileInfo: ProfileInfo) {Tools
Biome
[error] 32-32: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
Line range hint
106-106
: Avoid usingany
type.Specify a different type instead of using
any
.- private mapTestServer(data: any, profileInfo: ProfileInfo) { + private mapTestServer(data: Record<string, unknown>, profileInfo: ProfileInfo) {Tools
Biome
[error] 32-32: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
Line range hint
110-110
: Avoid usingany
type.Specify a different type instead of using
any
.- private mapGuidedTourConfig(data: any, profileInfo: ProfileInfo) { + private mapGuidedTourConfig(data: Record<string, unknown>, profileInfo: ProfileInfo) {Tools
Biome
[error] 32-32: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
Line range hint
119-119
: Avoid usingany
type.Specify a different type instead of using
any
.- private static mapSaml2Config(data: any, profileInfo: ProfileInfo) { + private static mapSaml2Config(data: Record<string, unknown>, profileInfo: ProfileInfo) {Tools
Biome
[error] 32-32: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
src/main/webapp/app/core/auth/account.service.ts (7)
Line range hint
18-18
: Avoid usingany
type.Specify a different type instead of using
any
.- save: (account: any) => Observable<HttpResponse<any>>; + save: (account: User) => Observable<HttpResponse<User>>;
Line range hint
81-81
: Avoid usingany
type.Specify a different type instead of using
any
.- save(user: User): Observable<HttpResponse<any>> { + save(user: User): Observable<HttpResponse<User>> {
Line range hint
90-90
: Avoid using non-null assertion operator.Using non-null assertion operator (
!
) is forbidden. Consider using optional chaining instead.- this.userIdentity!.groups = groups; + this.userIdentity?.groups = groups;
Line range hint
118-119
: Avoid using non-null assertion operator.Using non-null assertion operator (
!
) is forbidden. Consider using optional chaining instead.- const authorities = id!.authorities!; + const authorities = id?.authorities ?? [];
Line range hint
160-160
: Avoid using non-null assertion operator.Using non-null assertion operator (
!
) is forbidden. Consider using optional chaining instead.- const langKey = this.userIdentity.langKey || this.sessionStorage.retrieve('locale'); + const langKey = this.userIdentity?.langKey || this.sessionStorage.retrieve('locale');
Line range hint
165-165
: Avoid using non-null assertion operator.Using non-null assertion operator (
!
) is forbidden. Consider using optional chaining instead.- this.translateService.use(langKey!); + this.translateService.use(langKey);
Line range hint
287-289
: Omit the else clause.This else clause can be omitted because previous branches break early.
- } else { - this.userIdentity = undefined; - } + this.userIdentity = undefined;src/main/java/de/tum/in/www1/artemis/web/rest/ExerciseResource.java (1)
Line range hint
261-262
: Address the TODO comments.The TODO comments indicate that the current implementation retrieves the first token for the user. Ensure that the correct token for the participation is retrieved.
Do you want me to help address these TODO comments and implement the correct retrieval logic?
src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCInfoContributor.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCServletService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCServletService.java
Outdated
Show resolved
Hide resolved
...um/in/www1/artemis/service/connectors/gitlab/GitLabPersonalAccessTokenManagementService.java
Outdated
Show resolved
Hide resolved
Why don't attach the VCS to the user and instead attaching it to the participations? Many Credential managers for git typically save one (!) password per domain. Thus it will be hard to clone the repositories (i.e., solution, test, ...) for instructors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
...um/in/www1/artemis/service/connectors/gitlab/GitLabPersonalAccessTokenManagementService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCInfoContributor.java
Outdated
Show resolved
Hide resolved
.../in/www1/artemis/service/connectors/localvc/LocalVCPersonalAccessTokenManagementService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCServletService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCServletService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCServletService.java
Outdated
Show resolved
Hide resolved
...um/in/www1/artemis/service/connectors/gitlab/GitLabPersonalAccessTokenManagementService.java
Outdated
Show resolved
Hide resolved
.../in/www1/artemis/service/connectors/localvc/LocalVCPersonalAccessTokenManagementService.java
Outdated
Show resolved
Hide resolved
.../in/www1/artemis/service/connectors/localvc/LocalVCPersonalAccessTokenManagementService.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/in/www1/artemis/web/rest/ExerciseResource.java
Outdated
Show resolved
Hide resolved
…n-for-participation
…-exercises/access-token-for-participation' into feature/programming-exercises/access-token-for-participation
Integrated code lifecycle
: Provide Instructors more options to control container configuration
#9487
Checklist
General
Server
Changes affecting Programming Exercises
Motivation and Context
We want to allow users to use access tokens to clone/use localVC repositories.
Description
We added another table which stores tokens for every participation.
Added database table:
How tokens are created:
Case 1: When the student starts the participation, a vcs-access token is created with it. The user then fetches it from the server.
Case 2: When the exercise has started already (e.g. from before this PR), or the token was deleted (for whatever reason), and therefore no token is available, a new token is created when the user tries to fetch it.
A token is now always associated with a user, and a participation.
Steps for Testing
Note: only testable on TS3 and TS4 (only there, the feature is enabled already, and they use localVC)
Exam Mode Testing
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Performance Review
Code Review
Manual Tests
Exam Mode Test
Test Coverage
e2e tests: https://bamboo.ase.in.tum.de/browse/ARTEMIS-AEPTMA702-4
Screenshots
Drop down menu to choose between URLs with HTTPS, SSH and Token:
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Enhancements
Bug Fixes
Tests