Skip to content

General: Disable edits of users if saml2 is active#12542

Open
dfuchss wants to merge 14 commits intodevelopfrom
feature/disable-account-profile-change-for-saml2
Open

General: Disable edits of users if saml2 is active#12542
dfuchss wants to merge 14 commits intodevelopfrom
feature/disable-account-profile-change-for-saml2

Conversation

@dfuchss
Copy link
Copy Markdown
Contributor

@dfuchss dfuchss commented Apr 16, 2026

Summary

With SAML2 enabled, users shall not be able to change Name or Mail.
See #12528

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all database calls.
  • I strictly followed the server coding and design guidelines and the REST API guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I documented the Java code using JavaDoc style.

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding guidelines.
  • I strictly followed the AET UI-UX guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Vitest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I translated all newly inserted strings into English and German.

Motivation and Context

Resolve #12528 SAML2 users shall not be able to change their names or mail

Description

Disables (FE/BE) that users can change their Name or Mail if SAML2 is enabled.

Steps for Testing

Prerequisites:

  • 1 Admin
  • 1 Student
  1. Log in to Artemis
  2. Navigate to Account Settings and try to change Name/Mail with SAML2 enabled
  3. Admins shall be able to change names in the admin menu, but in the account settings menu it shall be disabled.

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2

Test Coverage

Client

Class/File Line Coverage Lines Expects Ratio
settings.component.ts 100.00% 119 46 38.7

Server

Class/File Line Coverage Lines
ProfileService.java 81.82% 43
AccountResource.java 92.11% 184

Last updated: 2026-05-07 20:30:19 UTC

Screenshots

Summary by CodeRabbit

  • New Features

    • SAML2-managed profiles: name and email become read-only in account settings when SAML2 is active; language preference remains editable.
    • Settings show an informational alert when SAML2-managed fields are enforced.
  • Documentation

    • Added English and German localization for the SAML2 settings notification.
  • Tests

    • Added unit and integration tests validating SAML2-active form behavior and save handling.

@github-project-automation github-project-automation Bot moved this to Work In Progress in Artemis Development Apr 16, 2026
@github-actions github-actions Bot added tests server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) core Pull requests that affect the corresponding module labels Apr 16, 2026
@dfuchss dfuchss requested a review from Copilot April 16, 2026 03:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Disables editing of user name/email in the account settings when the saml2 profile is active, while still allowing users to change their language preference.

Changes:

  • Server: Short-circuit /api/core/account updates under SAML2 to only persist langKey.
  • Client: Detect active SAML2 profile to disable name/email inputs and only send langKey updates.
  • Tests/i18n: Add integration/unit tests and user-facing info message translations (EN/DE).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/java/de/tum/cit/aet/artemis/core/web/AccountResource.java Enforces SAML2 behavior on the server by limiting updates to langKey.
src/main/java/de/tum/cit/aet/artemis/core/service/ProfileService.java Adds a helper to check whether the saml2 Spring profile is active.
src/main/webapp/app/core/account/settings/settings.component.ts Detects SAML2 profile, disables name/email fields, and avoids updating them in the payload.
src/main/webapp/app/core/account/settings/settings.component.html Shows an informational banner when SAML2 syncing is active.
src/main/webapp/app/core/account/settings/settings.component.spec.ts Adds a unit test ensuring name/email aren’t updated when SAML2 is active.
src/main/webapp/i18n/en/settings.json Adds SAML2 syncing info text (EN).
src/main/webapp/i18n/de/settings.json Adds SAML2 syncing info text (DE).
src/test/java/de/tum/cit/aet/artemis/core/user/AccountResourceIntegrationTest.java Adds integration tests verifying server-side behavior under SAML2.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/de/tum/cit/aet/artemis/core/web/AccountResource.java Outdated
@github-actions
Copy link
Copy Markdown

@dfuchss Test coverage could not be fully measured because some tests failed. Please check the workflow logs for details.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 16, 2026

End-to-End Test Results

Phase Status Details
Phase 1 (Relevant) ✅ Passed
TestsPassed ✅SkippedFailedTime ⏱
Phase 1: E2E Test Report22 ran22 passed0 skipped0 failed3m 1s
Phase 2 (Remaining) ❌ Failed
TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
Phase 2: E2E Test Report232 ran229 passed2 skipped1 failed21m 36s

Test Strategy: Two-phase execution

  • Phase 1: e2e/Login.spec.ts e2e/Logout.spec.ts e2e/SystemHealth.spec.ts e2e/course/CourseManagement.spec.ts
  • Phase 2: e2e/atlas/ e2e/course/CourseChannelMessages.spec.ts e2e/course/CourseDirectMessages.spec.ts e2e/course/CourseExercise.spec.ts e2e/course/CourseGroupChatMessages.spec.ts e2e/course/CourseMessageInteractions.spec.ts e2e/course/CourseOnboarding.spec.ts e2e/exam/ExamAssessment.spec.ts e2e/exam/ExamChecklists.spec.ts e2e/exam/ExamCreationDeletion.spec.ts e2e/exam/ExamDateVerification.spec.ts e2e/exam/ExamManagement.spec.ts e2e/exam/ExamParticipation.spec.ts e2e/exam/ExamResults.spec.ts e2e/exam/ExamTestRun.spec.ts e2e/exam/test-exam/ e2e/exercise/ExerciseImport.spec.ts e2e/exercise/file-upload/ e2e/exercise/modeling/ e2e/exercise/programming/ e2e/exercise/quiz-exercise/ e2e/exercise/text/ e2e/lecture/
❌ Failed Tests (Phase 2)
  • Exam participation › Programming exam with Git submissions › Participates in exam by Git submission using https (9m 48s)

Flakiness Scores for Failed Tests

Test Flakiness Score Default Branch Failure Rate Combined Failure Rate
e2e/exam/ExamParticipation.spec.ts#Exam participation › Programming exam with Git submissions › Participates in exam by Git submission using https 62.9718875502008% 5.0% 0.5%

Overall: ❌ Phase 2 (remaining tests) failed

🔗 Workflow Run · 📊 Test Report Phase 1 · 📊 Test Report Phase 2

@dfuchss dfuchss force-pushed the feature/disable-account-profile-change-for-saml2 branch from e0524d1 to 2d73e4a Compare April 16, 2026 17:29
@dfuchss dfuchss force-pushed the feature/disable-account-profile-change-for-saml2 branch from 2d73e4a to b5c2c8f Compare April 16, 2026 17:35
@github-actions
Copy link
Copy Markdown

@dfuchss Test coverage could not be fully measured because some tests failed. Please check the workflow logs for details.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/de/tum/cit/aet/artemis/core/web/AccountResource.java
Comment thread src/main/webapp/app/core/account/settings/settings.component.ts Outdated
Comment thread src/main/java/de/tum/cit/aet/artemis/core/service/ProfileService.java Outdated
@github-actions
Copy link
Copy Markdown

@dfuchss Test coverage has been automatically updated in the PR description.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 16, 2026
@github-actions
Copy link
Copy Markdown

@dfuchss Test coverage has been automatically updated in the PR description.

…java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 17, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 17, 2026
@github-actions
Copy link
Copy Markdown

@dfuchss Test coverage has been automatically updated in the PR description.

@github-project-automation github-project-automation Bot moved this from Work In Progress to Ready For Review in Artemis Development Apr 22, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/webapp/app/core/account/settings/settings.component.ts`:
- Around line 138-143: The payload currently only blocks name/email updates for
SAML2, but the form disables those controls when !isInternal || isSaml2Active;
change the update guard to match that rule so non-internal users can't submit
tampered name/email. In settings.component.ts replace the condition around
setting userToUpdate.firstName/lastName/email (currently checking
this.isSaml2Active) with the inverse of the disable predicate (i.e. only allow
assignment when this.isInternal && !this.isSaml2Active) so the submitted payload
aligns with the disabled-control logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e5037d88-e563-410a-b695-1e9d094bfa83

📥 Commits

Reviewing files that changed from the base of the PR and between 060e71d and e744f9d.

📒 Files selected for processing (2)
  • src/main/webapp/app/core/account/settings/settings.component.spec.ts
  • src/main/webapp/app/core/account/settings/settings.component.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/webapp/app/core/account/settings/settings.component.spec.ts

Comment thread src/main/webapp/app/core/account/settings/settings.component.ts
@github-actions
Copy link
Copy Markdown

@dfuchss Test coverage has been automatically updated in the PR description.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/webapp/app/core/account/settings/settings.component.html (1)

34-34: Remove redundant [disabled] bindings on reactive form controls.

The component already calls disable()/enable() on these controls via updateNameAndEmailControlState() (lines 111–117), which manages the disabled state through the reactive form API. The [disabled] bindings in the template are redundant—when a FormControl is disabled, Angular automatically renders the disabled attribute in the DOM. Using both triggers an Angular dev-mode warning: "It looks like you're using the disabled attribute with a reactive form directive."

Remove the [disabled] bindings to rely solely on the FormControl state as the single source of truth:

Changes (lines 34, 59, 90)
-                                formControlName="firstName"
-                                [disabled]="!isInternalUser() || isSaml2Active"
+                                formControlName="firstName"

Also applies to: 59, 90

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/webapp/app/core/account/settings/settings.component.html` at line
34, Remove the redundant [disabled] bindings from the template controls that are
already managed by the reactive form API; rely on the FormControl disabled state
set by updateNameAndEmailControlState() instead of using
[disabled]="!isInternalUser() || isSaml2Active". Specifically, delete the
[disabled] attributes referencing isInternalUser() and isSaml2Active on the form
inputs (the ones controlled by updateNameAndEmailControlState()) so Angular's
FormControl.disable()/enable() is the single source of truth and avoids the
dev-mode warning.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main/webapp/app/core/account/settings/settings.component.html`:
- Line 34: Remove the redundant [disabled] bindings from the template controls
that are already managed by the reactive form API; rely on the FormControl
disabled state set by updateNameAndEmailControlState() instead of using
[disabled]="!isInternalUser() || isSaml2Active". Specifically, delete the
[disabled] attributes referencing isInternalUser() and isSaml2Active on the form
inputs (the ones controlled by updateNameAndEmailControlState()) so Angular's
FormControl.disable()/enable() is the single source of truth and avoids the
dev-mode warning.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3492cc8e-23e5-4fe9-8fdc-6c29e1e1aadc

📥 Commits

Reviewing files that changed from the base of the PR and between e744f9d and 45579e9.

📒 Files selected for processing (2)
  • src/main/webapp/app/core/account/settings/settings.component.html
  • src/main/webapp/app/core/account/settings/settings.component.ts

@github-actions
Copy link
Copy Markdown

@dfuchss Test coverage has been automatically updated in the PR description.

Copy link
Copy Markdown
Contributor

@Claudia-Anthropica Claudia-Anthropica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dfuchss Nice clean feature — the server/client split and tests all look solid. One issue though: the SAML2 guard sits after the registration-disabled check, which means SAML2 users can't even change their language when registration is disabled. See inline comment.

Comment thread src/main/java/de/tum/cit/aet/artemis/core/web/AccountResource.java
Copy link
Copy Markdown
Contributor

@b-fein b-fein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on a Uni Passau test system with SAML2. Works as intended.

@dfuchss dfuchss added this to the 9.1.2 milestone Apr 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@Claudia-Anthropica Claudia-Anthropica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dfuchss All feedback addressed — SAML2 users are indeed internal so the ordering concern doesn't apply. Nice clean implementation, approving.

@github-actions
Copy link
Copy Markdown

@dfuchss Test coverage has been automatically updated in the PR description.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

@dfuchss Test coverage has been automatically updated in the PR description.

@bensofficial bensofficial modified the milestones: 9.1.2, 9.2.0, 9.1.3 May 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

@dfuchss Test coverage has been automatically updated in the PR description.

@helios-aet helios-aet Bot temporarily deployed to artemis-test4.artemis.cit.tum.de May 7, 2026 13:07 Inactive
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

@dfuchss Test coverage has been automatically updated in the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Pull requests that update TypeScript code. (Added Automatically!) core Pull requests that affect the corresponding module ready for review server Pull requests that update Java code. (Added Automatically!) tests

Projects

Status: Ready For Review

Development

Successfully merging this pull request may close these issues.

Artemis Settings allow setting names

5 participants