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

5.13.0 Release #351

Merged
merged 25 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f51a739
EPMRPP-94552 || Add scim related user disable check
pbortnik Sep 16, 2024
33320b7
EPMRPP-94552 || Update dao version
pbortnik Sep 16, 2024
e5d8b7d
Merge pull request #337 from reportportal/EPMRPP-89095
pbortnik Sep 16, 2024
02a6fcf
Update Dockerfile
HardNorth Sep 19, 2024
7cfee3b
Merge pull request #338 from reportportal/HardNorth-patch-1
HardNorth Sep 19, 2024
b327ee2
Update Dockerfile
raikbitters Sep 19, 2024
882e3b8
Merge remote-tracking branch 'origin/master' into develop
APiankouski Sep 19, 2024
7e84508
EPMRPP-96070 || Add saml user uuid generation
pbortnik Oct 11, 2024
216d806
Merge pull request #340 from reportportal/EPMRPP-96070-saml-uuid
pbortnik Oct 11, 2024
1098808
EPMRPP-96070 || Add ldap user uuid generation
pbortnik Oct 14, 2024
c81255d
EPMRPP-96070 || Add github user uuid generation
pbortnik Oct 14, 2024
b6c3138
Merge pull request #341 from reportportal/EPMRPP-96070-saml-uuid
pbortnik Oct 14, 2024
d5041f4
EPMRPP-96070 || Provide uuid on user replication by default in db
pbortnik Oct 14, 2024
476d9f0
EPMRPP-96070 || Update build.gradle
pbortnik Oct 15, 2024
ea0fbac
EPMRPP-96070 || Update build.gradle
pbortnik Oct 15, 2024
8695f65
Merge pull request #342 from reportportal/EPMRPP-96070-saml-uuid
pbortnik Oct 15, 2024
8aef132
EPMRPP-96070 || Add default fields to user builder
pbortnik Oct 16, 2024
3219456
Merge pull request #343 from reportportal/EPMRPP-96070-saml-uuid
pbortnik Oct 16, 2024
19d5f5c
EPMRPP-96070 || Fix handling of the locked account
pbortnik Oct 18, 2024
813ba8b
Merge pull request #344 from reportportal/EPMRPP-96070-saml-uuid
pbortnik Oct 18, 2024
f392f7a
Update Spring Security dependencies to version 5.8.16 (#349)
raikbitters Nov 21, 2024
2dfcc44
EPMRPP-95299 update last login time (#348)
grabsefx Nov 22, 2024
94089aa
Update GitHub Actions workflows to use 'ubuntu-latest' as the runner
hlebkanonik Dec 2, 2024
92b8c34
Add user active status checking
raikbitters Dec 4, 2024
a44349a
5.13.0 || Update release version
pbortnik Dec 5, 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
1 change: 1 addition & 0 deletions .github/workflows/build-dev-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ jobs:
image-tag: 'develop-${{ github.run_number }}'
version: 'develop-${{ github.run_number }}'
date: ${{ needs.variables-setup.outputs.date }}
runs-on: ubuntu-latest
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/build-feature-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ jobs:
version: ${{ needs.variables-setup.outputs.tag }}
branch: ${{ github.head_ref }}
date: ${{ needs.variables-setup.outputs.date }}
runs-on: ubuntu-latest
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/build-rc-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ jobs:
build-platforms: ${{ needs.variables-setup.outputs.platforms }}
version: ${{ needs.variables-setup.outputs.version }}
date: ${{ needs.variables-setup.outputs.date }}
runs-on: ubuntu-latest
secrets: inherit
2 changes: 2 additions & 0 deletions .github/workflows/java-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ jobs:
call-java-cheks:
name: Call Java checks
uses: reportportal/.github/.github/workflows/java-checks.yaml@main
with:
runs-on: ubuntu-latest
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

env:
GH_USER_NAME: github.actor
RELEASE_VERSION: 5.12.0
RELEASE_VERSION: 5.13.0

jobs:
release:
Expand Down
16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ext['log4j2.version'] = '2.21.1'

dependencyManagement {
imports {
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:' + '5.12.1' : 'com.epam.reportportal:commons-bom:5.12.1')
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:' + '5.13.0' : 'com.epam.reportportal:commons-bom:5.13.0')
}
}

Expand All @@ -43,8 +43,8 @@ dependencies {
api 'com.epam.reportportal:commons-dao'
api 'com.epam.reportportal:commons'
} else {
api 'com.github.reportportal:commons-dao:acf1ec7'
api 'com.github.reportportal:commons:c8ef09c'
api 'com.github.reportportal:commons-dao:develop-SNAPSHOT'
api 'com.github.reportportal:commons:develop-SNAPSHOT'
}

//Fix CVE-2021-41079, CVE-2022-23181, CVE-2021-33037, CVE-2021-30640, CVE-2022-42252, CVE-2023-46589, CVE-2024-24549
Expand Down Expand Up @@ -72,9 +72,9 @@ dependencies {

///// Security
//https://nvd.nist.gov/vuln/detail/CVE-2020-5407 AND https://nvd.nist.gov/vuln/detail/CVE-2020-5408
implementation 'org.springframework.security:spring-security-core:5.8.14'
implementation 'org.springframework.security:spring-security-config:5.8.14'
implementation 'org.springframework.security:spring-security-web:5.8.14'
implementation 'org.springframework.security:spring-security-core:5.8.16'
implementation 'org.springframework.security:spring-security-config:5.8.16'
implementation 'org.springframework.security:spring-security-web:5.8.16'
implementation 'org.springframework:spring-jdbc:6.1.5'
//

Expand Down Expand Up @@ -144,3 +144,7 @@ jar.archiveClassifier.set('')

publish.dependsOn build
publish.mustRunAfter build

tasks.preTagCommit.enabled = false
tasks.updateVersion.enabled = false
tasks.commitNewVersion.enabled = false
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=5.12.1
version=5.13.0
description=Unified Authorization Trap for all ReportPortal's Services
dockerPrepareEnvironment=
dockerJavaOpts=-Xmx512m -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=70 -Djava.security.egd=file:/dev/./urandom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundEx
.orElseThrow(() -> new UsernameNotFoundException("User not found"));

UserDetails userDetails = org.springframework.security.core.userdetails.User.builder()
.disabled(!user.isEnabled())
.username(user.getUsername())
.password(user.getPassword() == null ? "" : user.getPassword())
.authorities(AuthUtils.AS_AUTHORITIES.apply(user.getUserRole()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
package com.epam.reportportal.auth.event;

import com.epam.reportportal.auth.integration.saml.ReportPortalSamlAuthentication;
import com.epam.reportportal.rules.exception.ErrorType;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.dao.UserRepository;
import com.epam.ta.reportportal.entity.project.Project;
import com.epam.ta.reportportal.entity.user.User;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.util.PersonalProjectService;
import com.epam.reportportal.rules.exception.ErrorType;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.security.authentication.LockedException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -46,20 +45,30 @@ public class UiAuthenticationSuccessEventHandler {

private PersonalProjectService personalProjectService;

/**
* Event handler for successful UI authentication events. Updates the last login date for the user
* and generates a personal project if the user has no projects.
*/
@Autowired
public UiAuthenticationSuccessEventHandler(UserRepository userRepository,
PersonalProjectService personalProjectService) {
this.userRepository = userRepository;
this.personalProjectService = personalProjectService;
}

/**
* Handles the UI user signed-in event. Updates the last login date for the user
* and generates a personal project if the user has no projects.
* Also, if the user is inactive, it will be activated for SAML authentication.
*
* @param event the UI user signed-in event
*/
@EventListener
@Transactional
public void onApplicationEvent(UiUserSignedInEvent event) {
String username = event.getAuthentication().getName();
userRepository.updateLastLoginDate(
Instant.ofEpochMilli(event.getTimestamp()),
username);

userRepository.updateLastLoginDate(username);

if (MapUtils.isEmpty(acquireUser(event.getAuthentication()).getProjectDetails())) {
User user = userRepository.findByLogin(username)
Expand All @@ -71,11 +80,22 @@ public void onApplicationEvent(UiUserSignedInEvent event) {

private ReportPortalUser acquireUser(Authentication authentication) {
if (authentication instanceof ReportPortalSamlAuthentication rpAuth) {
userRepository.findByLogin(rpAuth.getPrincipal())
.filter(user -> !user.getActive())
.ifPresent(user -> {
user.setActive(true);
userRepository.save(user);
});
return userRepository.findUserDetails(rpAuth.getPrincipal())
.orElseThrow(() ->
new ReportPortalException(ErrorType.USER_NOT_FOUND, rpAuth.getPrincipal()));
.orElseThrow(() -> new ReportPortalException(
ErrorType.USER_NOT_FOUND, rpAuth.getPrincipal()
));
} else {
if (!((ReportPortalUser) authentication.getPrincipal()).isEnabled()) {
SecurityContextHolder.clearContext();
throw new LockedException("User account is locked");
}
return (ReportPortalUser) authentication.getPrincipal();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.Date;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -143,8 +144,10 @@ private void updateUser(User user, UserResource userResource, GitHubClient gitHu

private User createUser(UserResource userResource, GitHubClient gitHubClient) {
User user = new User();
String login = normalizeId(userResource.getLogin());
user.setLogin(login);
user.setLogin(normalizeId(userResource.getLogin()));
user.setUuid(UUID.randomUUID());
user.setActive(Boolean.TRUE);

updateUser(user, userResource, gitHubClient);
user.setUserType(UserType.GITHUB);
user.setRole(UserRole.USER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.epam.ta.reportportal.util.PersonalProjectService;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ldap.core.DirContextOperations;
Expand Down Expand Up @@ -101,23 +102,25 @@ private String validateEmail(String email) {

private User createNewUser(DirContextOperations ctx, Map<String, String> syncAttributes,
String email, String login) {
User newUser = new User();
newUser.setLogin(login);
User user = new User();
user.setLogin(login);
user.setUuid(UUID.randomUUID());
user.setActive(Boolean.TRUE);

String fullName = getFullName(ctx, syncAttributes);
newUser.setFullName(fullName);
user.setFullName(fullName);

checkEmail(email);
newUser.setEmail(email);
newUser.setMetadata(defaultMetaData());
newUser.setUserType(UserType.LDAP);
newUser.setRole(UserRole.USER);
newUser.setExpired(false);
user.setEmail(email);
user.setMetadata(defaultMetaData());
user.setUserType(UserType.LDAP);
user.setRole(UserRole.USER);
user.setExpired(false);

final Project project = generatePersonalProject(newUser);
newUser.getProjects().add(project.getUsers().iterator().next());
final Project project = generatePersonalProject(user);
user.getProjects().add(project.getUsers().iterator().next());

return userRepository.save(newUser);
return userRepository.save(user);
}

private String getFullName(DirContextOperations ctx, Map<String, String> syncAttributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
Expand Down Expand Up @@ -102,6 +103,8 @@ public User replicateUser(ReportPortalSamlAuthentication samlAuthentication) {

User user = new User();
user.setLogin(userName);
user.setUuid(UUID.randomUUID());
user.setActive(Boolean.TRUE);

List<Attribute> details = samlAuthentication.getDetails();

Expand Down
Loading