-
Notifications
You must be signed in to change notification settings - Fork 301
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
: Disable access to personal VCS access tokens in account settings for students
#9397
Integrated code lifecycle
: Disable access to personal VCS access tokens in account settings for students
#9397
Conversation
todo
disable access to personal VCS access token settings for studentsIntegrated code lifecycle
: Disable access to personal VCS access tokens in account settings for students
WalkthroughThe changes involve modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 using PR comments)
Other keywords and placeholders
Documentation and Community
|
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: 4
🧹 Outside diff range comments (2)
src/test/javascript/spec/component/account/user-settings-container.component.spec.ts (1)
Line range hint
45-59
: LGTM: Comprehensive test cases addedThe new test cases effectively cover the scenarios with and without the localVC profile, aligning with the PR objectives. The use of
toBeTrue()
andtoBeFalse()
matchers is consistent with the coding guidelines.For consistency with other tests and improved readability, consider using
async/await
syntax in both test cases:it('should initialize with localVC profile', async () => { await comp.ngOnInit(); expect(profileServiceMock.getProfileInfo).toHaveBeenCalled(); expect(comp.localVCEnabled).toBeTrue(); }); it('should initialize with no localVC profile set', async () => { profileServiceMock.getProfileInfo.mockReturnValue(of({ activeProfiles: [] })); await comp.ngOnInit(); expect(profileServiceMock.getProfileInfo).toHaveBeenCalled(); expect(comp.localVCEnabled).toBeFalse(); });This ensures consistent handling of asynchronous operations across all tests.
src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.html (1)
Line range hint
1-62
: *Consider updating older ngIf syntax in future refactoring.While not directly related to the current changes, I noticed that other parts of the file are still using the older
*ngIf
syntax. For consistency and to align with the latest Angular best practices, consider updating these instances to use the@if
syntax in a future refactoring task.This would involve changing occurrences like:
<div *ngIf="someCondition">to:
@if (someCondition) { <div> }This suggestion is purely for future consideration and doesn't affect the current PR's objectives.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
📒 Files selected for processing (4)
- src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.html (1 hunks)
- src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (2 hunks)
- src/main/webapp/app/shared/user-settings/user-settings.module.ts (0 hunks)
- src/test/javascript/spec/component/account/user-settings-container.component.spec.ts (2 hunks)
💤 Files with no reviewable changes (1)
- src/main/webapp/app/shared/user-settings/user-settings.module.ts
🧰 Additional context used
📓 Path-based instructions (3)
src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.html (1)
Pattern
src/main/webapp/**/*.html
: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (1)
src/test/javascript/spec/component/account/user-settings-container.component.spec.ts (1)
Pattern
src/test/javascript/spec/**/*.ts
: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}
🔇 Additional comments (6)
src/test/javascript/spec/component/account/user-settings-container.component.spec.ts (2)
7-7
: LGTM: Appropriate mock service import addedThe addition of MockTranslateService is consistent with the test setup and aligns with the guideline to mock irrelevant dependencies.
Line range hint
1-59
: Overall assessment: Changes align with PR objectives and improve test qualityThe modifications to this test file effectively support the PR objective of handling different user roles (with and without localVC profile). The changes improve test coverage, clarity, and adhere to coding guidelines. The suggestions provided are minor and aimed at further enhancing consistency and readability.
src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.html (1)
34-42
: LGTM! Changes align well with PR objectives.The modifications effectively implement the requirement to restrict access to VCS Access Token Settings for students. By adding the
isAtLeastTutor
condition, the link is now only visible to users with tutor or higher roles, which directly addresses the PR's main objective.The implementation:
- Uses the correct
@if
syntax as per the coding guidelines.- Maintains proper indentation and structure.
- Correctly uses the translation key for internationalization.
These changes should successfully prevent confusion among students regarding personal access tokens while maintaining access for appropriate user roles.
src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (3)
8-10
: Imports are correctly added for standalone componentThe imports for
TranslateDirective
,RouterModule
, andFontAwesomeModule
are appropriately included, and they are necessary for the component functionality.
18-20
: Component metadata correctly updated for standalone componentThe
standalone: true
property and theimports
array are properly configured, enabling the component to function as a standalone component. This aligns with Angular's best practices for standalone components.
31-31
: PropertyisAtLeastTutor
is appropriately initializedThe property
isAtLeastTutor
is correctly initialized tofalse
, preparing it for use in access control logic.
src/test/javascript/spec/component/account/user-settings-container.component.spec.ts
Show resolved
Hide resolved
...webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts
Show resolved
Hide resolved
...webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts
Outdated
Show resolved
Hide resolved
...webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts
Outdated
Show resolved
Hide resolved
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
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (1)
📓 Learnings (1)
src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (1)
Learnt from: SimonEntholzer PR: ls1intum/Artemis#9397 File: src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts:1-1 Timestamp: 2024-10-01T13:58:26.805Z Learning: In this project, refrain from suggesting the replacement of the `inject()` function with constructor injection in components.
🔇 Additional comments (3)
src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (3)
18-20
: Component correctly converted to standalone with proper importsThe component is appropriately marked as standalone, and the necessary modules are correctly imported within the
imports
array.
23-24
: Dependencies are correctly injected usinginject()
The services
ProfileService
andAccountService
are properly injected using theinject()
function, adhering to the project's guidelines.
49-51
: Previous suggestion on role checking logic remains applicableThe earlier review comment regarding the role checking logic in
authorizeTutor()
is still valid. Refactoring the logic to explicitly check for tutor and higher roles would ensure accurate access control.
...webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts
Outdated
Show resolved
Hide resolved
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.
Should the relevant server endpoint(s) also be changed to be accessible only to tutors and above?
...webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts
Outdated
Show resolved
Hide resolved
...webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts
Outdated
Show resolved
Hide resolved
...bapp/app/shared/user-settings/user-settings-container/user-settings-container.component.html
Show resolved
Hide resolved
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
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
📒 Files selected for processing (2)
- src/main/webapp/app/core/auth/account.service.ts (1 hunks)
- src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/main/webapp/app/core/auth/account.service.ts (1)
src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (1)
📓 Learnings (1)
src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (1)
Learnt from: SimonEntholzer PR: ls1intum/Artemis#9397 File: src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts:1-1 Timestamp: 2024-10-01T13:58:26.805Z Learning: In this project, refrain from suggesting the replacement of the `inject()` function with constructor injection in components.
🔇 Additional comments (7)
src/main/webapp/app/core/auth/account.service.ts (1)
227-229
: Verify complete implementation of PR objectivesThe
isAtLeastTutor()
method provides a good foundation for implementing the PR objective of restricting access to VCS tokens for students. However, this method alone doesn't fully implement the described functionality.To ensure the complete implementation of the PR objectives, please run the following script to check for usage of this method in relation to VCS token access:
This script will help verify if the
isAtLeastTutor()
method is being used to restrict access to VCS tokens as intended in the PR objectives.src/main/webapp/app/shared/user-settings/user-settings-container/user-settings-container.component.ts (6)
1-1
: Import of 'inject' function is appropriateIncluding the
inject
function from@angular/core
aligns with the usage of dependency injection in this component.
8-10
: Necessary module imports added for standalone componentThe imports of
TranslateDirective
,RouterModule
, andFontAwesomeModule
are correctly included to support the standalone component functionality.
18-20
: Standalone component configuration is correctly appliedSetting
standalone: true
and specifying theimports
array in the component decorator is appropriate and follows Angular's guidelines for standalone components.
23-24
: Dependency injection using 'inject()' function is properly implementedUsing the
inject()
function to obtain instances ofProfileService
andAccountService
is suitable for this context.
31-31
: Initialization of 'isAtLeastTutor' propertyInitializing
isAtLeastTutor
tofalse
ensures a defined state before any user authentication logic is executed.
40-45
: Authentication state handling and role assignment are correctly implementedThe use of the
tap
operator to assigncurrentUser
and determineisAtLeastTutor
usingthis.accountService.isAtLeastTutor()
is appropriate and enhances code readability.
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.
Tested on TS4. Works as expected!
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.
Code
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.
Code LGTM
Just a note about security: As far as I know, when students (or any user) create their own tokens, they can set an expiration date, which is not possible on the participation tokens. So when a participation token gets leaked, everyone who has access to the token can access the submission as long as the exercise exists. I agree with hiding the tokens from the students, but maybe then there should be a feature to control the expiration date of the participation tokens to prevent such cases. |
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.
Tested in testing session, works as expected
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.
code
That's a good point, I'll keep that in mind for a follow up 👍 |
I would not implement this. The idea of an access token per participation is that the scope is really tiny. If a student really accidentally leaks such a token, only the affected exercise could be manipulated, nothing else. An exercise is typically open for a short amount of time when it's graded. For practice exercises, there is almost no harm, as they are not graded at all. When we add an expiration date for graded exercises that is shorter than the due date, it could be the case that students suddenly get permission errors (in the worst case shortly before the deadline) without understanding what's going. Getting a new token and using it in the respective context would be quite cumbersome and some students might not even understand the issue. |
Checklist
General
Client
authorities
to all new routes and checked the course groups for displaying navigation elements (links, buttons).Motivation and Context
The newly introduced personal access tokens, could confuse students, as they do not really need them, as they can only access their own repositories.
Description
Only enable VCS access token creation for users which are at least tutors.
Steps for Testing
Prerequisites:
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
Code Review
Manual Tests
Test Coverage
Screenshots
As privileged user:
Users who is only a student:
Summary by CodeRabbit
UserSettingsContainerComponent
to utilize Angular's standalone component feature.UserSettingsContainerComponent
.