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

General: Add SAML2 audit features #9233

Merged
merged 21 commits into from
Sep 14, 2024
Merged

General: Add SAML2 audit features #9233

merged 21 commits into from
Sep 14, 2024

Conversation

dfuchss
Copy link
Contributor

@dfuchss dfuchss commented Aug 19, 2024

⚠️ This is only testable with SAML2 Configuration; It will not influence other deployments by design ⚠️

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I strictly followed the server coding and design guidelines.
  • I documented the Java code using JavaDoc style.

Motivation and Context

The audit log does not contain the human-readable login information if you log in via SAML2. See #9228

Description

Adds SAML2 Events to Audit Log
image

Steps for Testing

Prerequisites:

  • SAML2 Instance
  • Test Login with Password
  • Test Login with SAML2
  • Test Account creation

You should find all related information now readable without duplicates in the AuditLog.

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

  • 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
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced support for SAML2 authentication, enhancing the security and service integration capabilities of the application.
    • Added detailed audit logging for user authentication events to improve tracking and accountability.
  • Bug Fixes

    • Updated configuration properties and annotations for SAML2 management, ensuring consistency and reducing potential errors in configuration.
  • Documentation

    • Enhanced code documentation to clarify the purpose and usage of new constants and configurations related to SAML2.

@dfuchss dfuchss linked an issue Aug 19, 2024 that may be closed by this pull request
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) labels Aug 19, 2024
@dfuchss dfuchss marked this pull request as ready for review August 19, 2024 20:54
@dfuchss dfuchss requested a review from a team as a code owner August 19, 2024 20:54
Copy link

coderabbitai bot commented Aug 19, 2024

Walkthrough

The recent changes enhance the Artemis application by introducing a new constant for the SAML2 profile, improving configuration management and maintainability. Key updates include modifying SAML2 authentication handling to incorporate detailed auditing capabilities and adapting multiple classes to utilize the new constant. Additionally, the audit event repository has been updated to conditionally process events based on the active profile, which collectively contributes to a more robust and flexible SAML2 integration.

Changes

File(s) Change Summary
src/main/java/de/tum/in/www1/artemis/config/Constants.java Added a new constant PROFILE_SAML2 for the SAML2 Spring profile, enhancing configuration flexibility.
src/main/java/de/tum/in/www1/artemis/config/SAML2Configuration.java Updated @Profile annotation to use Constants.PROFILE_SAML2, improving maintainability and readability.
src/main/java/de/tum/in/www1/artemis/config/SAML2Properties.java Changed @ConfigurationProperties to use Constants.PROFILE_SAML2, increasing consistency in property mapping.
src/main/java/de/tum/in/www1/artemis/service/connectors/SAML2Service.java Modified constructor to include AuditEventRepository, updated authentication handling to log detailed events, and adjusted profile annotation for improved maintainability.
src/main/java/de/tum/in/www1/artemis/web/rest/open/PublicUserJwtResource.java Altered authorizeSAML2 method to accept both authentication and principal parameters, enhancing the authentication process.
src/test/java/de/tum/in/www1/artemis/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java Updated @ActiveProfiles to include PROFILE_SAML2, improving test configurability and maintainability.
src/main/java/de/tum/in/www1/artemis/repository/CustomAuditEventRepository.java Added dependency on Environment, modified constructor to include ProfileService, and updated add method for SAML2 authentication checks, enhancing audit event handling.

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dfuchss dfuchss requested a review from b-fein August 19, 2024 20:54
@dfuchss dfuchss added this to the 7.5.1 milestone Aug 19, 2024
@dfuchss dfuchss added the small label Aug 19, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 19, 2024
b-fein
b-fein previously approved these changes Aug 20, 2024
Copy link
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.

Code changes make sense. (Testing later when I find time for it.)

Just to be sure: The screenshot in the description still shows a base64-encoded+encrypted username. Was this just an intermediate version during testing or are there duplicate events now, once with encoded username and once without?

@dfuchss
Copy link
Contributor Author

dfuchss commented Aug 20, 2024

Code changes make sense. (Testing later when I find time for it.)

Just to be sure: The screenshot in the description still shows a base64-encoded+encrypted username. Was this just an intermediate version during testing or are there duplicate events now, once with encoded username and once without?

The problem is that I could try to filter them similar to 1654b27 (#9233) (in the mentioned commit, the type is wrong, but the idea is the same). The problem is that this would mean that I need the information whether SAML2 is active, I.e., I'd need to use a service in a repository. That leads to an architecture violation. Therefore, I reverted that implementation. Currently, the encrypted is shown as well. If you have an idea how to access the active profile without the use of this service, just tell it to me. Then I can add the filtering as well :)

@dfuchss
Copy link
Contributor Author

dfuchss commented Aug 20, 2024

Code changes make sense. (Testing later when I find time for it.)
Just to be sure: The screenshot in the description still shows a base64-encoded+encrypted username. Was this just an intermediate version during testing or are there duplicate events now, once with encoded username and once without?

The problem is that I could try to filter them similar to 1654b27 (#9233) (in the mentioned commit, the type is wrong, but the idea is the same). The problem is that this would mean that I need the information whether SAML2 is active, I.e., I'd need to use a service in a repository. That leads to an architecture violation. Therefore, I reverted that implementation. Currently, the encrypted is shown as well. If you have an idea how to access the active profile without the use of this service, just tell it to me. Then I can add the filtering as well :)

nvm. I have an idea .. :D

@dfuchss dfuchss dismissed stale reviews from b-fein and coderabbitai[bot] via b77f1ca August 20, 2024 07:42
@dfuchss
Copy link
Contributor Author

dfuchss commented Aug 20, 2024

@b-fein now it should work :D -> b77f1ca

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 20, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 20, 2024
# Conflicts:
#	src/main/java/de/tum/cit/aet/artemis/core/repository/CustomAuditEventRepository.java
#	src/main/java/de/tum/cit/aet/artemis/core/service/connectors/SAML2Service.java
#	src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java
b-fein
b-fein previously approved these changes Sep 12, 2024
@dfuchss
Copy link
Contributor Author

dfuchss commented Sep 12, 2024

@BaumiCoder @Strohgelaender @SimonEntholzer could you also re-approve (if I didn't make an error during merge :D )

BaumiCoder
BaumiCoder previously approved these changes Sep 12, 2024
@dfuchss dfuchss dismissed stale reviews from BaumiCoder and b-fein via cd60a33 September 12, 2024 10:09
Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Re-approve code

@krusche krusche changed the title General: SAML2 Audit features General: Add SAML2 audit features Sep 14, 2024
@krusche krusche merged commit d05815e into develop Sep 14, 2024
17 of 22 checks passed
@krusche krusche deleted the feature/saml2-audit branch September 14, 2024 11:21
JohannesWt pushed a commit that referenced this pull request Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge server Pull requests that update Java code. (Added Automatically!) small tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Enhancement of Audit Log: Usernames for SAML Users
6 participants